commercialhaskell / commercialhaskell/stack

Building tests can cause unnecessary recompilation

Open
#2,800 11 comments 6 reactions 0 assignees View on GitHub
component: build resolution: upstream issue type: bug
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.