Skip to content

[#548] Enable doctest in morley

Diogo Castro requested to merge diogo/doctest into master

Description

This MR enables doctest in morley.

There's now a new doctest-morley build step in the CI. Example logs:

To run it locally, you can just run it like you would any normal test suite:

stack test morley:test:doctests

Or

cd code/morley
make doctests

It doesn't support cabal yet though. In order to run doctests, we need to know where the GHC package dabatase used to compile morley is located. With stack, that's pretty easy, you just run stack path. With cabal, it's not so easy. See this issue. There probably is a solution, but I think having support for nix and stack is our main priority right now, so we can look into supporting cabal when that becomes an issue.

Note:

  • This currently only checks morley:lib. We'll probably want to enable this for lorentz:lib (and potentially others) too. At that point, we should probably generalize the code in code/morley/doctests/Main.hs to make it more reusable (although it's already pretty generic).
  • There is a project named cabal-doctest which automates much of the code I wrote in Main.hs, but it doesn't support nix
  • There is another project by the same author named cabal-docspec but I suspect we'd run into similar issues. AFAICT, cabal-docspec needs to access cabal's dist-newstyle folder, which is not available in the CI.

Huge thanks to @balsoft for his help!

Related issue(s)

Resolves #548 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Diogo Castro

Merge request reports