Isolate work directory for 'stack test' (#995)

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.
This commit is contained in:
Karl Ostmo 2023-01-10 10:34:18 -08:00 committed by GitHub
parent f2fa93e33f
commit 68c992aa2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

1
.gitignore vendored
View File

@ -8,6 +8,7 @@ cabal.project.local
hie.yaml
.stack-work/
.stack-work-test/
stack.yaml.lock
.hie/
stan.html

View File

@ -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.

7
scripts/run-tests.sh Executable file
View File

@ -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 $@