Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cabal test fails (but cabal run doctests works) #22

Open
martijnbastiaan opened this issue Dec 31, 2021 · 2 comments
Open

cabal test fails (but cabal run doctests works) #22

martijnbastiaan opened this issue Dec 31, 2021 · 2 comments
Labels
bug Something isn't working upstream Affected by upstream bug workaround available

Comments

@martijnbastiaan
Copy link
Owner

martijnbastiaan commented Dec 31, 2021

Workaround

cabal build
cabal test

or

cabal run doctests

Issue

Rather annoyingly, if doctests is part of a testsuite it (sometimes) fails to properly run:

$ cabal test
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - example-0.0.0 (test:doctests) (ephemeral targets)
Preprocessing test suite 'doctests' for example-0.0.0..
Building test suite 'doctests' for example-0.0.0..
Running 1 test suites...
Test suite doctests: RUNNING...
Could not import module: Example. This can be caused by a number of issues: 

 1. A module found by GHC contained tests, but was not in 'exposed-modules'.

 2. For Cabal users: Cabal did not generate a GHC environment file. Either:
   * Run with '--write-ghc-environment-files=always'
   * Add 'write-ghc-environment-files: always' to your cabal.project

 3. The testsuite executable does not have a dependency on your project library. Please add it to the 'build-depends' section of the testsuite executable.

See the example project at https://github.com/martijnbastiaan/doctest-parallel/blob/main/example/README.md for more information.
Examples: 2  Tried: 0  Errors: 1  Unexpected output: 0

Test suite doctests: FAIL
Test suite logged to:
/home/martijn/code/doctest-parallel/example/dist-newstyle/build/x86_64-linux/ghc-8.10.7/example-0.0.0/t/doctests/test/example-0.0.0-doctests.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal: Tests failed for test:doctests from example-0.0.0.

Running it with run works just fine though:

$ cabal run doctests
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - example-0.0.0 (test:doctests) (additional components to build)
Preprocessing test suite 'doctests' for example-0.0.0..
Building test suite 'doctests' for example-0.0.0..
Examples: 2  Tried: 2  Errors: 0  Unexpected output: 0

This seems to be the same issue observed by #9. My guess is that environment files get written out "too late". My evidence is that this works:

cabal test # fails
cabal test # works

or:

cabal run doctests # works
cabal test # now also works

or:

cabal build
cabal test
@martijnbastiaan martijnbastiaan added bug Something isn't working workaround available labels Dec 31, 2021
@martijnbastiaan
Copy link
Owner Author

@lehins This is probably what you saw in #9

@martijnbastiaan
Copy link
Owner Author

Reported as bug: haskell/cabal#7889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Affected by upstream bug workaround available
Projects
None yet
Development

No branches or pull requests

1 participant