Import from a child directory in a ghci session (import modules from tests into yesod)

When you create a construction site in yesod, it puts the tests in a separate directory as follows:

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

So now I want to run ghci and import the code from YourProj/tests/main.hs or YourProj/tests/FooTests.hs for playback. How can 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, although I managed to add a subdirectory, I'm still having problems due to the configuration configuration in the build-depends parameter cache in the cabal file for the test suite.

How do I run cabal-dev ghci and import the code from the tests into Yesod?

+4
source share
1 answer

So the answer is:

  • add all the missing modules inside your cabal file from the build-depends your test suite to the build-depends your application at the top.
  • run cabal-dev ghci inside the application root and do :set -itests

Then you can do something like :load tests/EntriesTest.hs fine.

+4
source

Source: https://habr.com/ru/post/1488007/


All Articles