Closed ysangkok closed 2 years ago
Oops, I did the rebase wrong, it is now fixed @lehins .
Thank you for the quick response. I primarily submitted this PR because I couldn't get the doctests to run. How do you run them? This is what I attempted and how it fails:
$ cabal test doctests --enable-tests
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- doctest-0.19.0 (lib) (requires build)
- random-1.3.0 (lib) (first run)
- random-1.3.0 (test:doctests) (first run)
Configuring library for random-1.3.0..
Starting doctest-0.19.0 (lib)
Building doctest-0.19.0 (lib)
Preprocessing library for random-1.3.0..
Building library for random-1.3.0..
[1 of 4] Compiling System.Random.GFinite ( src/System/Random/GFinite.hs, /home/janus/flipstone/random/dist-newstyle/build/x86_64-linux/ghc-8.6.5/random-1.3.0/build/System/Random/GFinite.o )
[2 of 4] Compiling System.Random.Internal ( src/System/Random/Internal.hs, /home/janus/flipstone/random/dist-newstyle/build/x86_64-linux/ghc-8.6.5/random-1.3.0/build/System/Random/Internal.o )
Installing doctest-0.19.0 (lib)
Completed doctest-0.19.0 (lib)
[3 of 4] Compiling System.Random ( src/System/Random.hs, /home/janus/flipstone/random/dist-newstyle/build/x86_64-linux/ghc-8.6.5/random-1.3.0/build/System/Random.o )
[4 of 4] Compiling System.Random.Stateful ( src/System/Random/Stateful.hs, /home/janus/flipstone/random/dist-newstyle/build/x86_64-linux/ghc-8.6.5/random-1.3.0/build/System/Random/Stateful.o )
Configuring test suite 'doctests' for random-1.3.0..
Preprocessing test suite 'doctests' for random-1.3.0..
Building test suite 'doctests' for random-1.3.0..
[1 of 1] Compiling Main ( test/doctests.hs, /home/janus/flipstone/random/dist-newstyle/build/x86_64-linux/ghc-8.6.5/random-1.3.0/t/doctests/build/doctests/doctests-tmp/Main.o )
Linking /home/janus/flipstone/random/dist-newstyle/build/x86_64-linux/ghc-8.6.5/random-1.3.0/t/doctests/build/doctests/doctests ...
Running 1 test suites...
Test suite doctests: RUNNING...
src/System/Random/Internal.hs:95:1: error:
Could not find module ‘System.Random.SplitMix’
Use -v to see a list of the files searched for.
This is with GHC 8.6.5, which should work, if I understand the existing code correctly.
That is a very good question. The issue comes from the doctests needing ghc's env files. See how it is used on CI https://github.com/haskell/random/blob/c796015598f3eafaddaa9c79ec817ead3c55e936/.github/workflows/ci.yaml#L51-L52
In particular: --write-ghc-environment-files=always
So something like this should do the trick:
$ cabal configure --enable-tests
$ cabal build random:doctests --write-ghc-environment-files=always
$ cabal test random:doctests
Tested using
I have changed the mechanism used to disable these test to using
buildable: False
instead of making the test just quit. That way, the user won't be misled into thinking that the tests were actually run.