4

cabal test will compile the test suite executable and then run it. However, it removes the console colouring (because it logs the result). I'd like to use cabal to build the executable and then run it from a script, but I can't figure out how to just build the executable.

Julian Birch
  • 2,605
  • 1
  • 21
  • 36

1 Answers1

7

If you cabal configure --enable-tests, then cabal build will build not just the library/executables, but also the test suites. You can also build individual test suites by name, saying cabal build name-of-test-suite.

You can run them manually from the appropriate subdirectories under dist/build if you don't want to use cabal test.

Furthermore, if it's e.g. a tasty test suite, you may be able to get color output by saying something like

cabal test --show-details=always --test-option=--color --test-option=always

You can also try --show-details=streaming. I don't know how robust this is, though, and whether it works may also depend on the platform you are on.

kosmikus
  • 19,549
  • 3
  • 51
  • 66