'How do I run the tests that are part of an installed/installing Cabal package?
I have a Haskell package I've installed from Hackage, using cabal
and would like to run the tests suites that are part of the package, but it isn't clear to me from the cabal
documentation how to do this.
I've tried:
cabal install --reinstall --enable-tests --run-tests the-package
and its various combinations and permutations, but no tests seem to run: I get no report about the test running, and none of the output that I know the test should produce is generated.
How do I run the tests that are part of an installed cabal
package, or a package that I'm in the process of installing?
Solution 1:[1]
The --run-tests
flag does not appear to be working in the current version of cabal
. The --enable-tests
flag no longer runs tests as a new feature of cabal
. Until the issue is resolved you can manually verify that a package passes it's test suite by doing the following:
- Use
cabal
to download the package source - Use
cabal
to build the package in a sandbox - Use
cabal
to run the tests in the sandbox
Use this series of cabal commands to run the test for the-package
:
cabal get the-package
cd the-package*
cabal sandbox init
cabal install --dependencies-only
cabal configure --enable-tests
cabal build
cabal test
cd ../
rm -r the-package*
Or use this equivalent one-liner:
cabal get the-package && cd the-package* && cabal sandbox init && cabal install --dependencies-only && cabal configure --enable-tests && cabal build && cabal test && cd ../ && rm -r the-package*
Solution 2:[2]
The answer below no long works as noted in its comments. The following works for me with cabal 3.6.2:
cabal get the-package
cd the-package*
cabal v2-test
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 |