Skip to content

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

Closed

Description

@PierreVDL

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

Activity

  1. begriffs commented on Jan 30, 2017

    @begriffs

    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.

  2. mgsloan commented on Feb 1, 2017

    @mgsloan
    Contributor

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

  3. added a commit that references this issue on Feb 1, 2017
  4. PierreVDL commented on Mar 22, 2017

    @PierreVDL
    Author

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

  5. PierreVDL commented on May 2, 2017

    @PierreVDL
    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.
    
  6. Topsii commented on May 19, 2017

    @Topsii

    This happens for me too.
    I also have windows:

    stack --version
    Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd x86_64 hpack-0.17.0
    
  7. PierreVDL commented on May 24, 2017

    @PierreVDL
    Author

    Can this issue be reopened?

  8. mgsloan commented on Aug 7, 2017

    @mgsloan
    Contributor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions