sol / doctest

An implementation of Python's doctest for Haskell
https://hackage.haskell.org/package/doctest
MIT License
373 stars 73 forks source link

Add `cabal-doctest` #428

Open sol opened 4 months ago

sol commented 4 months ago

Initial implementation: https://github.com/sol/doctest/pull/425 Based on: https://github.com/mpickering/cabal-doctest-demo/blob/master/cabal-doctest

Related discussions:

TODO:

hsyl20 commented 3 months ago

Thanks for your work on this!

I've just noticed that there is an issue when multi-repl: True is present in a cabal.project. The repl loads the target but doesn't run the tests:

Example from https://github.com/haskus/packages/actions/runs/10195092999/job/28203068431:

Run cabal doctest
Resolving dependencies...
Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - doctest-0.22.9 (lib) (requires build)
 - doctest-0.22.9 (exe:doctest) (requires build)
Starting     doctest-0.22.9 (lib)
Building     doctest-0.22.9 (lib)
Installing   doctest-0.22.9 (lib)
Completed    doctest-0.22.9 (lib)
Starting     doctest-0.22.9 (exe:doctest)
Building     doctest-0.22.9 (exe:doctest)
Installing   doctest-0.22.9 (exe:doctest)
Completed    doctest-0.22.9 (exe:doctest)
Copying 'doctest' to
'/home/runner/.cabal/doctest/ghc-9.8.2-6fbce3708d1cdaa02b114e8244ac58f9/doctest-0.22.9'
doctest version 0.22.9
using version 9.8.2 of the GHC API
using /usr/local/.ghcup/ghc/9.8.2/bin/ghc-9.8.2
Resolving dependencies...
Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - haskus-utils-data-1.4 (interactive) (lib) (configuration changed)
 - haskus-utils-data-1.4 (interactive) (test:tests) (configuration changed)
Configuring library for haskus-utils-data-1.4...
Configuring test suite 'tests' for haskus-utils-data-1.4...
Preprocessing test suite 'tests' for haskus-utils-data-1.4...
Preprocessing library for haskus-utils-data-1.4...
GHCi, version 9.8.2: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/runner/.cabal/doctest/ghc-9.8.2-6fbce3708d1cdaa02b114e8244ac58f9/init-ghci-0.22.9
[ 1 of 12] Compiling Haskus.Utils.Either[haskus-utils-data-1.4-inplace]
[ 2 of 12] Compiling Haskus.Utils.Functor[haskus-utils-data-1.4-inplace]
[ 3 of 12] Compiling Haskus.Utils.InfList[haskus-utils-data-1.4-inplace]
[ 4 of 12] Compiling Haskus.Utils.List[haskus-utils-data-1.4-inplace]
[ 5 of 12] Compiling Haskus.Utils.Map[haskus-utils-data-1.4-inplace]
[ 6 of 12] Compiling Haskus.Utils.Map.Strict[haskus-utils-data-1.4-inplace]
[ 7 of 12] Compiling Haskus.Utils.Maybe[haskus-utils-data-1.4-inplace]
[ 8 of 12] Compiling Haskus.Utils.Monad[haskus-utils-data-1.4-inplace]
[ 9 of 12] Compiling Haskus.Utils.Tuple[haskus-utils-data-1.4-inplace]
[10 of 12] Compiling Haskus.Utils.HList[haskus-utils-data-1.4-inplace]
[11 of 12] Compiling Main[haskus-utils-data-1.4-inplace-tests]
Ok, 11 modules loaded.
ghci> Leaving GHCi.
Examples: 0  Tried: 0  Errors: 0  Failures: 0

Similarly, when I try cabal doctest all it requires multi-repl: True but if enabled it just drops me into a repl with all the modules loaded.

sol commented 3 months ago

@hsyl20 does passing --disable-multi-repl to cabal doctest on the command line work as a workaround?

hsyl20 commented 3 months ago

@sol Yes it does