I was setting up a yesod scaffolded site using the yesod init
command, and I named my project yesodtry
. I proceeded to setup a scaffolded site using this command, which was given by yesod init
:
cd yesodtry && cabal sandbox init && cabal install && yesod devel
Everything went smoothly, and I accessed the demo site at 127.0.0.1:3000
. Out of curiosity, I tried to try the yesod test
command. Here's the output I got:
Resolving dependencies...
Configuring yesodtry-0.0.0...
cabal: At least the following dependencies are missing:
hspec -any, yesod-test ==1.2.*
Seeing how the yesodtry.cabal
file has a test
section, I tried executing cabal build test
, and this is the output:
cabal: Cannot build the test suite 'test' because test suites are not enabled.
Run configure with the flag --enable-tests
Ok... so it tells me to run cabal configure --enable-tests
. And here's the output:
Resolving dependencies...
Configuring yesodtry-0.0.0...
cabal: At least the following dependencies are missing:
hspec -any, yesod-test ==1.2.*
I see this line in yesodtry.cabal
, for the build-depends
of the test-suite test
"section":
yesod-test >= 1.2 && < 1.3
It seems like cabal is not installing the dependencies here. How do I do that?
Thank you.
Ok, I think I found the answer on this Haskell-cafe thread.
We have to do:
cabal configure --enable-tests
cabal install --only-dependencies --enable-tests
And the dependencies for the test-suite test
section will be installed.
I then ran yesod test
, and here's the last few lines of the output:
Linking dist/build/test/test ...
Building yesodtry-0.0.0...
Preprocessing library yesodtry-0.0.0...
In-place registering yesodtry-0.0.0...
Preprocessing test suite 'test' for yesodtry-0.0.0...
Linking dist/build/test/test ...
Running 1 test suites...
Test suite test: RUNNING...
Test suite test: PASS
Test suite logged to: dist/test/yesodtry-0.0.0-test.log
1 of 1 test suites (1 of 1 test cases) passed.
Hopefully this will help anyone who encounters the same problem in the future.