Should I repeat all dependencies in the test configuration?
This bothers me from time to time, mainly if I create test-suite
in the cabal config, I add the project files src
to the test cases section hs-source-dirs
and repeat all dependencies in the build-depends
. A typical project might look like this:
-- in file "foo.cabal"
library
build-depends: a, b, c
exposed-modules: Foo, Bar
hs-source-dirs: src
test-suite tests
build-depends: foo, a, b, c
hs-source-dirs: test
Another option is to include src
in the test suite hs-source-dirs
.
Both of them require me to specify all build dependencies in a test case as far as I know. Is there a way to get around this?
source to share
It should work as is, but there is a reported bug when you use it withcabal repl
In general it works with cabal test
, but if you try to load the test file in cabal repl
, you may get an error like this:
Could not find module ‘XYZ’
It is a member of the hidden package ‘XZY-[ver]’.
Perhaps you need to add ‘XYZ’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
So now it might be a good idea to actually copy the dependencies, but hopefully this will be fixed soon.
source to share