Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 513
orome Avatar asked Oct 09 '15 14:10

orome


1 Answers

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:

  1. Use cabal to download the package source
  2. Use cabal to build the package in a sandbox
  3. 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*
like image 78
recursion.ninja Avatar answered Oct 16 '22 02:10

recursion.ninja