Skip to content

stack ghci with a test component does not build test dependencies #4031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
parsonsmatt opened this issue May 18, 2018 · 6 comments
Closed

stack ghci with a test component does not build test dependencies #4031

parsonsmatt opened this issue May 18, 2018 · 6 comments

Comments

@parsonsmatt
Copy link
Contributor

parsonsmatt commented May 18, 2018

General summary/comments (optional)

stack ghci doesn't load dependencies from the test-suite if you select a test-suite target and the test-suite has not been built yet.

This may also require the package having not been built at all in the global package cache yet.

More observations:

If you do a stack ghci in the reproduction repo before doing a stack build, it loads the library component fine. But if you do a stack ghci stack-ghci-repro:test:stack-ghci-repro-test, it fails to load the library as a dependency.

Steps to reproduce

$ git clone https://www.github.com/parsonsmatt/stack-ghci-repro
$ cd stack-ghci-repro
$ stack ghci stack-ghci-repro:test:stack-ghci-repro-test
< observe the problem>
$ stack test
$ stack ghci stack-ghci-repro:tests:stack-ghci-repro-test
< note that it is fixed >

Expected

I expected it to notice that it was in a test-suite, ensure that it has loaded and downloaded all of the test suite dependencies, and launched a GHCi shell correctly.

Actual

$ stack ghci stack-ghci-repro:test:stack-ghci-repro-test
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: stack-ghci-repro
Using main module: 1. Package `stack-ghci-repro' component test:stack-ghci-repro-test with main-is file: /home/matt/Projects/stack-ghci-repro/test/Spec.hs
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package hedgehog-0.5.1
    (use -v for more information)

Stack version

$ stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2

Method of installation

  • Official binary, downloaded from stackage.org or fpcomplete's package repository
@ncaq
Copy link
Contributor

ncaq commented May 22, 2018

Is reproduce correct?
stack ghci require file path.

% stack ghci stack-ghci-repro:tests:stack-ghci-repro-test
Error parsing targets: Directory not found: stack-ghci-repro:tests:stack-ghci-repro-test
Note that to specify options to be passed to GHCi, use the --ghci-options flag

@parsonsmatt
Copy link
Contributor Author

Good catch @ncaq I've fixed the reproduction steps.

@mgsloan
Copy link
Contributor

mgsloan commented Jun 11, 2018 via email

@parsonsmatt
Copy link
Contributor Author

It's not exactly a duplicate -- in that case, it seems like the problem is the missing library dependency. But in this case, it's an entry in the build-depends of the test-suite.

@mgsloan
Copy link
Contributor

mgsloan commented Jun 11, 2018

Ah, interesting! Yes, I think this is a related issue, not a duplicate.

@mpilgrem
Copy link
Member

mpilgrem commented Apr 1, 2024

I am closing this issue given the passage of time and because I could not reproduce it with Stack 2.15.5. A simple one-package project foo has a test suite that depends on the main library:

> stack new foo
> cd foo
> stack ide targets
> stack ghci foo:test:foo-test
Using main module:
1.  Package foo, component foo:test:foo-test, with main-is file: ...\foo\test\Spec.hs.

foo> configure (lib + test)
foo> build (lib + test) with ghc-9.6.4
foo> copy/register
foo> Test running disabled by --no-run-tests flag.
Configuring GHCi with the following packages: foo.
Ok, two modules loaded.
Loaded GHCi configuration from ...\ghci-script\30a2d50d\ghci-script
ghci> main
Test suite not yet implemented
ghci>

@mpilgrem mpilgrem closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants