I am trying to debug tests with cabal repl and observe strange behavior.
cabal repl is working for the application code.
cabal repl
but doesn't for test suit:
cabal repl tests
fails:
Loaded GHCi configuration from /home/user/myapp/.ghci
<no location info>: warning: [-Wmissing-home-modules]
These modules are needed for compilation but not listed in your .cabal file's other-modules:
MyApp.X
MyApp.Y
...
src/MyApp/X.hs:8:1: error:
Could not load module ‘Relude’
It is a member of the hidden package ‘relude-1.0.0.1’.
myapp.cabal:
name: myapp
version: 0.5.0
library
exposed-modules:
MyApp.X
MyApp.Y
hs-source-dirs:
src
build-depends:
relude >=1.0.0.1
test-suite tests
type: exitcode-stdio-1.0
main-is: Driver.hs
other-modules:
MyApp.Test.X
hs-source-dirs:
test
ghc-options: -rtsopts -threaded
build-depends:
HUnit
, base
, myapp
cabal --version
cabal-install version 3.4.0.0
compiled using version 3.4.0.0 of the Cabal library
Due some reason cabal repl loads modules from src folder not from test one. Test suit doesn't depend on relude dependency. It is hidden for test suit and of course ghc fails.
A college recommended workaround:
:set -package bytestring
:set -package tasty
:set -package envy
:set -package tasty-hunit
:set -itest
:set -package HUnit
import Tasty (defaultMain) -- this may fail, ignore it