Skip to content

Commit

Permalink
Isolate work directory for 'stack test' (#995)
Browse files Browse the repository at this point in the history
Closes #936.

With this change, `stack build` should be invoked as normal, but to run tests one should invoke the new script, which will place compilation artifacts in a separate directory so as to not stomp on the previous `stack build` artifacts.

## Demo

```
stack build
./scripts/run-tests.sh
stack build
```
All perform incremental compilation rather than from-scratch.
  • Loading branch information
kostmo authored Jan 10, 2023
1 parent f2fa93e commit 68c992a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cabal.project.local
hie.yaml

.stack-work/
.stack-work-test/
stack.yaml.lock
.hie/
stan.html
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ check the `hie.yaml.stack` file. Pure Cabal should work fine with the defaults,
but you might want to [add a GHC flag](https://haskell-language-server.readthedocs.io/en/latest/features.html)
to build docs into `cabal.project.local`.

**TIP:** To run tests, you can use the [`scripts/run-tests.sh` script](scripts/run-tests.sh) to avoid problems with incremental compilation in alternation with `stack build`.

### Conventions

We follow a few conventions to help keep everyone on the same page.
Expand Down
7 changes: 7 additions & 0 deletions scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -ex

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR/..

# See https://github.com/swarm-game/swarm/issues/936
STACK_WORK=.stack-work-test stack test $@

0 comments on commit 68c992a

Please sign in to comment.