From 68c992aa2d289818adfb16980819f787af04704f Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Tue, 10 Jan 2023 10:34:18 -0800 Subject: [PATCH] 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. --- .gitignore | 1 + CONTRIBUTING.md | 2 ++ scripts/run-tests.sh | 7 +++++++ 3 files changed, 10 insertions(+) create mode 100755 scripts/run-tests.sh diff --git a/.gitignore b/.gitignore index c7160fcc..85f3ac0b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ cabal.project.local hie.yaml .stack-work/ +.stack-work-test/ stack.yaml.lock .hie/ stan.html diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a830310..eb45b551 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh new file mode 100755 index 00000000..1e4c9e4f --- /dev/null +++ b/scripts/run-tests.sh @@ -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 $@