commercialhaskell / commercialhaskell/stack
doctests can't see bindings when run with stack test and GHC 9
- Dominant language
- Haskell
- Stars
- 4.1k
- Forks
- 850
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 4
Description
Initially reported as https://github.com/sol/doctest/issues/301 : hledger-lib's doctest suite is failing because doctests don't see the bindings of their containing module, but only when using GHC 9 and invoked via `stack test`. It works normally when running the test suite's executable from the command line, or when using `cabal test`, or when using GHC 8.10.
## Actual
Test suite fails with `stack test`:
```
$ stack test hledger-lib:test:doctest -v
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4
...
2021-07-20 09:00:57.155745: [info] hledger-lib> test (suite: doctest)
2021-07-20 09:00:57.155824: [info]
2021-07-20 09:00:57.155920: [debug] Run process within /Users/simon/src/hledger/hledger-lib/: /Users/simon/src/hledger/hledger-lib/.stack-work/dist/x86_64-osx/Cabal-3.4.0.0/build/doctest/doctest
Loading and searching for doctests in 50 files, plus any files they import:
Hledger/Read/JournalReader.hs:182: failure in expression `rejp (journalp <* eof) "2015/1/1\n a 0\n"'
expected: Right (Right Journal with 1 transactions, 1 accounts)
but got:
^
:31:1: error:
Variable not in scope: rejp :: f0 a0 -> t0 -> t
:31:7: error: Variable not in scope: journalp :: f0 a0
:31:19: error: Variable not in scope: eof :: f0 b0
...
```
Succeeds when run directly:
```
$ ls -l /Users/simon/src/hledger/hledger-lib/.stack-work/dist/x86_64-osx/Cabal-3.4.0.0/build/doctest/doctest
-rwxr-xr-x 1 simon staff 84444856 Jul 16 18:13 /Users/simon/src/hledger/hledger-lib/.stack-work/dist/x86_64-osx/Cabal-3.4.0.0/build/doctest/doctest
$ (cd hledger-lib; stack exec -- /Users/simon/src/hledger/hledger-lib/.stack-work/dist/x86_64-osx/Cabal-3.4.0.0/build/doctest/doctest)
Loading and searching for doctests in 50 files, plus any files they import:
Examples: 218 Tried: 218 Errors: 0 Failures: 0
```
## Expected
The `stack test` command should have no errors or failures.
Is there a special environment created by `stack test` that GHC 9 might be sensitive to ?
Contributor guide
Assessment
This issue has not been assessed yet.