From 5dbbf233327bff1c89088ed0fc45882563240b1a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 9 Dec 2021 15:16:18 +0000 Subject: [PATCH] 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. --- tests/init.sh | 6 ++++++ tests/local.mk | 1 + 2 files changed, 7 insertions(+) mode change 100644 => 100755 tests/init.sh diff --git a/tests/init.sh b/tests/init.sh old mode 100644 new mode 100755 index 3c6d5917d..da0568ed9 --- 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 \