Skip to content
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

project with test-only package fails both build and test #2862

Closed
PierreVDL opened this issue Dec 20, 2016 · 7 comments
Closed

project with test-only package fails both build and test #2862

PierreVDL opened this issue Dec 20, 2016 · 7 comments

Comments

@PierreVDL
Copy link

I would like to move my organization to stack.
In my first experiments, I noticed a behaviour that is according to me a bug.
Our projects have tests localized in separate packages:
among other to prevent test dependencies end up as development dependencies.
One can argue whether or not this is a good pattern,
but I can't change it just to get stack accepted.

On Microsoft Windows [Version 6.1.7601]
with stack [Version 1.3.0, Git revision 99b910d x86_64 hpack-0.15.0]
my multi-package project with a test-only package fails to build and to execute the test suite.

Steps to reproduce

The following multi-package project
Multiple.zip
yields for stack build

test-0.1.0.0: configure
src-0.1.0.0: build (lib)
src-0.1.0.0: copy/register
app-0.1.0.0: build (exe)
test-0.1.0.0: build
app-0.1.0.0: copy/register
Completed 3 action(s).
Log files have been written to: C:\multiple\.stack-work\logs\

--  While building package test-0.1.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.0.0_ghc-8.0.1.exe --builddir=.stack-work\dist\b7fec021 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: C:\multiple\.stack-work\logs\test-0.1.0.0.log

    Configuring test-0.1.0.0...
    Cabal-simple_Z6RU0evB_1.24.0.0_ghc-8.0.1.exe: No libraries, executables,
    tests, or benchmarks are enabled for package test-0.1.0.0.

This behaviour surprises me, since

  1. test.cabal specifies a test-suite, so tests should be enabled for package test-0.1.0.0.
  2. Test suite are irrelevant for a build, so build should not fail when only tests (and benchmarks) are available.

And for 'stack test'

test-0.1.0.0: configure (test)
test-0.1.0.0: build (test)
test-0.1.0.0: copy/register
Log files have been written to: C:\multiple\.stack-work\logs\
Progress: 1/2'cabal copy' failed.  Error message:

--  While building package test-0.1.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.0.0_ghc-8.0.1.exe --builddir=.stack-work\dist\b7fec021 copy
    Process exited with code: ExitFailure 1
    Logs have been written to: C:\multiple\.stack-work\logs\test-0.1.0.0.log

    Configuring test-0.1.0.0...
    Preprocessing test suite 'test-test' for test-0.1.0.0...
    Cabal-simple_Z6RU0evB_1.24.0.0_ghc-8.0.1.exe: No executables and no library
    found. Nothing to do.

One possible cause of this issue is:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.

I agree that test-0.1.0.0 contains no executables and no library: yet a test-suite is present that should be executed!

Note: by out commenting line 41 '- test' of stack.yaml 'stack build' and 'stack test' works perfectly.

Method of installation

  • Official binary, downloaded from stackage.org
@begriffs
Copy link

This just happened to me as well. Got the No module named "Main". error on Stack 1.2.0 for a project which has only a test-suite section, no executable or library. I upgraded to Stack 1.3.2 and get the same error.

@mgsloan
Copy link
Contributor

mgsloan commented Feb 1, 2017

I've pushed a fix! It now skips the cabal copy step if there's no lib or exes.

@mgsloan mgsloan closed this as completed Feb 1, 2017
mgsloan added a commit that referenced this issue Feb 1, 2017
@PierreVDL
Copy link
Author

Bug fix confirmed with stack 1.4 !
Thanks for the fix!

@PierreVDL
Copy link
Author

Just noticed the problem reappeared in stack 1.4.0

C:\multiple>stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd x86_64 hpack-0.17.0
C:\multiple>stack build
Downloaded lts-7.14 build plan.
[1 of 2] Compiling Main             ( C:\sr\setup-exe-src\setup-Z6RU0evB.hs, C:\sr\setup-exe
-src\setup-Z6RU0evB.o )
[2 of 2] Compiling StackSetupShim   ( C:\sr\setup-exe-src\setup-shim-Z6RU0evB.hs, C:\sr\setu
p-exe-src\setup-shim-Z6RU0evB.o )
Linking C:\sr\setup-exe-cache\x86_64-windows\tmp-Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.1.ex
e ...
test-0.1.0.0: configure
test-0.1.0.0: build
src-0.1.0.0: configure (lib)
src-0.1.0.0: build (lib)
src-0.1.0.0: copy/register
Log files have been written to: C:\multiple\.stack-work\logs\
Progress: 2/3
--  While building package test-0.1.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.1.exe --builddir=.stack-work\dist\ca59d0ab build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: C:\multiple\.stack-work\logs\test-0.1.0.0.log

    Configuring test-0.1.0.0...
    Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.1.exe: No libraries, executables,
    tests, or benchmarks are enabled for package test-0.1.0.0.

@Topsii
Copy link

Topsii commented May 19, 2017

This happens for me too.
I also have windows:

stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd x86_64 hpack-0.17.0

@PierreVDL
Copy link
Author

Can this issue be reopened?

@mgsloan
Copy link
Contributor

mgsloan commented Aug 7, 2017

@PierreVDL @Topsii I've pushed a fix to master. The solution is to only mark the package as a target if some of its components are targets.

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