stack ghci foo:test:bar uses library dependencies unless --test is passed #1845

Closed
bergmark opened this Issue Feb 26, 2016 · 5 comments

Projects

None yet

2 participants

@bergmark
Member

stack: Version 1.0.4 x86_64

This took me a while to figure out because the error message isn't clear, it turns out that you need to pass --test when ghci'ing a test suite, otherwise the library dependencies will be in scope instead.

Edit: I would expect --main-is *:test:* to either imply --test or produce an error message without it, the former sounds nicer to me.

$ stack ghci feed --main-is feed:test:tests
Using main module: 1. Package `feed' component test:tests with main-is file: /Users/adam/repos/feed/tests/Main.hs
Configuring GHCi with the following packages: feed
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help

/Users/adam/repos/feed/tests/Main.hs:3:8:
    Could not find module ‘Test.Framework’
    It is a member of the hidden package ‘test-framework-0.8.1.1@testf_4H0ct1ddVB2I2MqugXDYyk’.
    Use -v to see a list of the files searched for.

/Users/adam/repos/feed/tests/Main.hs:4:8:
    Could not find module ‘Text.RSS.Tests’
    Use -v to see a list of the files searched for.

/Users/adam/repos/feed/tests/Main.hs:5:8:
    Could not find module ‘Text.Atom.Tests’
    Perhaps you meant
      Text.Atom.Feed (needs flag -package-key feed-0.3.11.1@feed_8KHXLrW8hznKHgeejBEybf)
    Use -v to see a list of the files searched for.

/Users/adam/repos/feed/tests/Main.hs:6:8:
    Could not find module ‘Text.Feed.Util.Tests’
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.

<no location info>:
    Could not find module ‘Paths_feed’
    It is a member of the hidden package ‘feed-0.3.11.1@feed_8KHXLrW8hznKHgeejBEybf’.
@mgsloan
Collaborator
mgsloan commented Feb 27, 2016

Does stack ghci feed:test:tests not work?

I don't think there's any logic currently that has stack ghci --main-is feed:test:tests imply loading that component. It definitely makes sense to add that.

@bergmark
Member

Does stack ghci feed:test:tests not work?

It works, I wasn't aware that syntax was allowed outside of --main-is.

@mgsloan
Collaborator
mgsloan commented Feb 29, 2016

Yes, stack ghci takes all the arguments that stack build takes, including target selection.

@mgsloan
Collaborator
mgsloan commented Oct 18, 2016

@bergmark This is now fixed! --main-is TARGET will now imply that it is also a plain target.

@mgsloan mgsloan closed this Oct 18, 2016
@mgsloan mgsloan added a commit that referenced this issue Oct 18, 2016
@mgsloan mgsloan ChangeLog update for #1845 5011bb8
@bergmark
Member

Thanks Michael!

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