Question

When you create a scaffolded site in yesod, it puts tests into separate directory like this:

YourProj/
YourProj/SomeModule.hs
YourProj/Handlers/FooHandler.hs
...
YourProj/tests/main.hs
YourProj/tests/FooTests.hs

So, now I want to fire ghci and import some code from YourProj/tests/main.hs or YourProj/tests/FooTests.hs to play with. How do I do it? I tried:

cabal-dev ghci
> :set -itests
> :load tests/TestImport.hs
tests/TestImport.hs:15:8:
    Could not find module `Control.Monad.IO.Class'
    It is a member of the hidden package `transformers-0.3.0.0'.
    Perhaps you need to add `transformers' to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

So, while I succeeded adding subdirectory, I still have problems because of different cabal configuration of build-depends parameter in cabal file for test-suite.

How would I launch cabal-dev ghci and import some code from tests in Yesod?

Était-ce utile?

La solution

Ok, so the answer is this:

  1. add all missing modules inside your cabal file from build-depends of your test-suite into build-depends of your app on top.
  2. run cabal-dev ghci inside app's root and do :set -itests

You should then be able to do something like :load tests/EntriesTest.hs fine.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top