Skip to content

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

@PierreVDL

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

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