aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-12-09 15:16:18 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-02-23 11:31:44 -0500
commit5dbbf233327bff1c89088ed0fc45882563240b1a (patch)
treea5d98be9b1cb9566efaa6acb8e43aac59aaceabd
parent4a921ba43b8ea9a37763cd4bd4bc491928cc55c2 (diff)
Make init.sh safe to run twice
`init.sh` is tested on its own. We used to do that. I deleted it in 4720853129b6866775edd9f90ad6f10701f98a3c but I am not sure why. Better to just restore it; at one point working on this every other test passed, so seems good to check whether `init.sh` can be run twice. We don't *need* to run `init.sh` twice, but I want to try to make our tests as robust as possible so that manual debugging (where tests for better or worse might be run ways that we didn't expect) is less fragile.
-rwxr-xr-x[-rw-r--r--]tests/init.sh6
-rw-r--r--tests/local.mk1
2 files changed, 7 insertions, 0 deletions
diff --git a/tests/init.sh b/tests/init.sh
index 3c6d5917d..da0568ed9 100644..100755
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -1,8 +1,14 @@
+set -e -o pipefail
+
source common.sh
test -n "$TEST_ROOT"
if test -d "$TEST_ROOT"; then
chmod -R u+w "$TEST_ROOT"
+ # We would delete any daemon socket, so let's stop the daemon first.
+ if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
+ killDaemon
+ fi
rm -rf "$TEST_ROOT"
fi
mkdir "$TEST_ROOT"
diff --git a/tests/local.mk b/tests/local.mk
index b3135fd4d..4ef071f96 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -1,4 +1,5 @@
nix_tests = \
+ init.sh \
flakes/flakes.sh \
flakes/run.sh \
flakes/mercurial.sh \