How to work with Cabal API

206 views Asked by At

I would like to "interact" with Cabal during the test phase (like exitcode-stdio-1.0) using the relative API (https://www.haskell.org/cabal/release/cabal-latest/doc/API/Cabal/Distribution-Simple-Test-ExeV10.html) to customise for example the final output. How can I do that? I cannot find the right documentation.

1

There are 1 answers

3
JP Moresmau On BEST ANSWER

A exitcode-stdio-1.0 test suite is only an executable, which needs to implement main :: IO(). Cabal test just runs the executable and captures the output in a log file. So if you use a test framework like tasty, you'll get the output the tasty way. Of course, you can just write your own executable, and output what you want. You just need to return the proper error code to tell Cabal if the tests were successful or not.