Search code examples
haskellcabalghcid

How to run test suite in ghcid with cabal?


I've found a reference for doing this in stack in https://www.parsonsmatt.org/2018/05/19/ghcid_for_the_win.html and some mention of it here: https://github.com/ndmitchell/ghcid/issues/128

What I've tried:

[nix-shell:~/NewProjects/orgmode-parse]$ cabal v2-repl test
cabal: Cannot open a repl for the package test, it is not in this project
(either directly or indirectly). If you want to add it to the project then
edit the cabal.project file.

[nix-shell:~/NewProjects/orgmode-parse]$ cabal v2-repl Test.test
cabal: Unknown target 'Test.test'.
There is no component 'Test.test'.


[nix-shell:~/NewProjects/orgmode-parse]$ cabal v2-repl Test.test
cabal: Unknown target 'Test.test'.
There is no component 'Test.test'.

Solution

  • ghcid --command='cabal v2-repl test:tests' --test 'Main.main'
    

    Where tests is the name of the test-suite defined in the cabal file. And Main.main refers to the Main module's main function.