Skip to content
This repository was archived by the owner on Apr 25, 2020. It is now read-only.
This repository was archived by the owner on Apr 25, 2020. It is now read-only.

stack and test-suite #640

Open
Open
@rikvdkleij

Description

@rikvdkleij

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

rikvdkleij commented on Oct 3, 2015

@rikvdkleij
Author

Hmm, I solved problem by removing the Setup.hs file. Do not understand why.....

rikvdkleij

rikvdkleij commented on Oct 3, 2015

@rikvdkleij
Author

It's weird. It was working and suddenly not anymore.

rikvdkleij

rikvdkleij commented on Oct 4, 2015

@rikvdkleij
Author

If you need more information let me know.

DanielG

DanielG commented on Oct 6, 2015

@DanielG
Owner

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 of cabal 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

DanielG commented on Oct 6, 2015

@DanielG
Owner

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

rikvdkleij commented on Oct 6, 2015

@rikvdkleij
Author

Sorry, I tried different combinations but I do not get it solved.

rikvdkleij

rikvdkleij commented on Oct 6, 2015

@rikvdkleij
Author

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 and type are returning results for identifiers in test file.

alanz

alanz commented on Oct 6, 2015

@alanz
Collaborator

Have you configured to enable the tests? Else ghc-mod will not know about them, or their dependencies

alanz

alanz commented on Oct 6, 2015

@alanz
Collaborator

@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 API

rikvdkleij

rikvdkleij commented on Oct 6, 2015

@rikvdkleij
Author

@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

rikvdkleij commented on Oct 6, 2015

@rikvdkleij
Author

stack test is running without problems.

alanz

alanz commented on Oct 6, 2015

@alanz
Collaborator

I do not use stack much, but perhaps run stack test. Not sure if there is
an option to configure only

On Tue, Oct 6, 2015 at 10:19 PM, Rik notifications@github.com wrote:

@alanz https://github.com/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 https://github.com/DanielG has proposed.


Reply to this email directly or view it on GitHub
#640 (comment)
.

alanz

alanz commented on Oct 6, 2015

@alanz
Collaborator

What happens if you run the ghc-mod check command after stack test?

24 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @enolan@DanielG@alanz@rikvdkleij@mcfilib

        Issue actions

          stack and test-suite · Issue #640 · DanielG/ghc-mod