[#548] Enable doctest in morley
Description
This MR enables doctest
in morley.
There's now a new doctest-morley
build step in the CI. Example logs:
- passing: https://gitlab.com/morley-framework/morley/-/jobs/1031191603
- failing: https://gitlab.com/morley-framework/morley/-/jobs/1030223889
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 forlorentz:lib
(and potentially others) too. At that point, we should probably generalize the code incode/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 inMain.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'sdist-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
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.
Edited by Diogo Castro