Skip to content

Building tests can cause unnecessary recompilation #2800

@crockeea

Description

@crockeea

The following steps cause the library portion of a project to be unnecessarily recompiled:

>stack build foo
>stack test foo

when the testsuite has a build-depend that isn't in the library.

For example, with this cabal file:

name:                foo
version:             0.1.1.0
stability:           experimental
build-type:          Simple
cabal-version:       >= 1.10

library
  default-language: Haskell2010
  exposed-modules:  Foo
  build-depends:    base
test-suite testfoo
  type:             exitcode-stdio-1.0
  default-language: Haskell2010
  main-is:          Main.hs
  build-depends:    base, data-default

I get the following:

> stack build foo
foo-0.1.1.0: configure
Configuring foo-0.1.1.0...
foo-0.1.1.0: build
Preprocessing library foo-0.1.1.0...
[1 of 1] Compiling Foo              ( Foo.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/Foo.o )
foo-0.1.1.0: copy/register
Installing library in ...
Registering foo-0.1.1.0...

> stack test foo
**foo-0.1.1.0: unregistering (dependencies changed)**
foo-0.1.1.0: configure (lib + test)
Configuring foo-0.1.1.0...
foo-0.1.1.0: build (lib + test)
Preprocessing library foo-0.1.1.0...
Preprocessing test suite 'testfoo' for foo-0.1.1.0...
[1 of 1] Compiling Main             ( Main.hs, .stack-work/dist/x86_64-linux/Cabal-.24.0.0/build/testfoo/testfoo-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/testfoo/testfoo ...
foo-0.1.1.0: copy/register

I get foo-0.1.1.0: unregistering (missing dependencies: data-default) when the additional dependency has not yet been build, or foo-0.1.1.0: unregistering (dependencies changed) if the additional dependency has already been built. There's no need to unregister the library if it has already been built and I would like to additionally build the tests.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions