stack and test-suite #640
Description
Build project with stack. Test dependencies in test-suite (for example hspec) are not recognized by ghc-mod. If I put same dependencies in library section, ghc-mod does not complain anymore.
ghc-mod debug
Warning: resolveModule "/home/rik/haskell/projects/quicksort/test/Spec.hs":
could not execute: hspec-discover
Root directory: /home/rik/haskell/projects/quicksort
Current directory: /home/rik/haskell/projects/quicksort
GHC Package flags:
-hide-all-packages -no-user-package-db -package-db
/home/rik/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/pkgdb/
-package-db
/home/rik/haskell/projects/quicksort/.stack-work/install/x86_64-linux/lts-3.4/7.10.2/pkgdb/
-package-id QuickCheck-2.8.1-b8cde035baf86e10569b5c8f1da0c941
-package-id base-4.8.1.0-4f7206fd964c629946bb89db72c80011
-package-id hspec-2.1.10-d1430dd5c99e21ed2da59fe60fa379d9
GHC System libraries: /opt/ghc/7.10.2/lib/ghc-7.10.2
GHC user options:
Stack ghc executable: Just "/opt/ghc/7.10.2/bin/ghc"
Stack ghc-pkg executable:Just "/opt/ghc/7.10.2/bin/ghc-pkg"
Cabal file: Just "/home/rik/haskell/projects/quicksort/quicksort.cabal"
Project: StackProject (StackEnv {seDistDir = ".stack-work/dist/x86_64-linux/Cabal-1.22.4.0", seBinPath = ["/home/rik/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/bin","/home/rik/bin","/usr/local/sbin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin","/usr/games","/usr/local/games","/home/rik/bin","/home/rik/.local/bin/","/home/rik/.cabal/bin","/opt/ghc/7.10.2/bin","."], seSnapshotPkgDb = "/home/rik/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/pkgdb", seLocalPkgDb = "/home/rik/haskell/projects/quicksort/.stack-work/install/x86_64-linux/lts-3.4/7.10.2/pkgdb"})
Cabal entrypoints:
Setup.hs
Main (/home/rik/haskell/projects/quicksort/Setup.hs)
library
Quicksort (/home/rik/haskell/projects/quicksort/src/Quicksort.hs)
test:spec
Cabal components:
Setup.hs
Main (/home/rik/haskell/projects/quicksort/Setup.hs)
library
Quicksort (/home/rik/haskell/projects/quicksort/src/Quicksort.hs)
test:spec
GHC Cabal options:
Setup.hs
library
-fbuilding-cabal-package -O -outputdir
.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build -odir
.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build -hidir
.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build -stubdir
.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build -i
-i.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build -isrc
-i.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen
-I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen
-I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build -optP-include
-optP.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h
-hide-all-packages -no-user-package-db -package-db
/home/rik/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/pkgdb/
-package-db
/home/rik/haskell/projects/quicksort/.stack-work/install/x86_64-linux/lts-3.4/7.10.2/pkgdb/
-package-id base-4.8.1.0-4f7206fd964c629946bb89db72c80011
-XHaskell2010 -Wall
test:spec
-fbuilding-cabal-package -O -outputdir
.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/spec/spec-tmp
-odir
.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/spec/spec-tmp
-hidir
.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/spec/spec-tmp
-stubdir
.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/spec/spec-tmp -i
-i.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/spec/spec-tmp
-itest -isrc
-i.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen
-I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen
-I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/spec/spec-tmp
-optP-include
-optP.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h
-hide-all-packages -no-user-package-db -package-db
/home/rik/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/pkgdb/
-package-db
/home/rik/haskell/projects/quicksort/.stack-work/install/x86_64-linux/lts-3.4/7.10.2/pkgdb/
-package-id QuickCheck-2.8.1-b8cde035baf86e10569b5c8f1da0c941
-package-id base-4.8.1.0-4f7206fd964c629946bb89db72c80011
-package-id hspec-2.1.10-d1430dd5c99e21ed2da59fe60fa379d9
-XHaskell2010 -Wall -Werror
GHC search path options:
Setup.hs
library
-i -i.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build -isrc
-i.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen
-I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen
-I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build -optP-include
-optP.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h
test:spec
-i
-i.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/spec/spec-tmp
-itest -isrc
-i.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen
-I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen
-I.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/spec/spec-tmp
-optP-include
-optP.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h
Activity
rikvdkleij commentedon Oct 3, 2015
Hmm, I solved problem by removing the Setup.hs file. Do not understand why.....
rikvdkleij commentedon Oct 3, 2015
It's weird. It was working and suddenly not anymore.
rikvdkleij commentedon Oct 4, 2015
If you need more information let me know.
DanielG commentedon Oct 6, 2015
Can you try running
stack test
before trying to run ghc-mod on any of your test modules. I think that should do the equivalent ofcabal configure --enable-tests
so cabal-helper can pick up the right dependencies from the Cabal setup-config. I'm not actually sure though since I haven't tested this and no-one has confirmed that this works so far.DanielG commentedon Oct 6, 2015
Oh
stack test --only-configure
should do the trick actually. Regrettably there isn't a way to get the state of the --enable/disable-{tests,benchmarks,..} flags out of LocalBuildInfo so every time ghc-mod decides to reconfigure the project you might have to re-run that.rikvdkleij commentedon Oct 6, 2015
Sorry, I tried different combinations but I do not get it solved.
rikvdkleij commentedon Oct 6, 2015
Hmm, while
check
is complaining:test/QuicksortSpec.hs:4:18:Could not find module ‘Test.Hspec’Use -v to see a list of the files searched for.
test/QuicksortSpec.hs:5:18:Could not find module ‘Test.QuickCheck’Use -v to see a list of the files searched for.
info
andtype
are returning results for identifiers in test file.alanz commentedon Oct 6, 2015
Have you configured to enable the tests? Else ghc-mod will not know about them, or their dependencies
alanz commentedon Oct 6, 2015
@dxld I am beginning to wonder if ghc-mod should not have a private
dist
directory where it configures with all targets enabled. Perhaps it is just a problem when using it from the APIrikvdkleij commentedon Oct 6, 2015
@alanz Which command do I have run to enable the tests? I'm using stack and not cabal. I already tried the ones which @DanielG had proposed.
rikvdkleij commentedon Oct 6, 2015
stack test
is running without problems.alanz commentedon Oct 6, 2015
I do not use stack much, but perhaps run
stack test
. Not sure if there isan option to configure only
On Tue, Oct 6, 2015 at 10:19 PM, Rik notifications@github.com wrote:
alanz commentedon Oct 6, 2015
What happens if you run the ghc-mod check command after
stack test
?24 remaining items