Make init.sh safe to run twice

`init.sh` is tested on its own. We used to do that. I deleted it in
4720853129 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.
This commit is contained in:
John Ericson 2021-12-09 15:16:18 +00:00
parent 4a921ba43b
commit 5dbbf23332
2 changed files with 7 additions and 0 deletions

6
tests/init.sh Normal file → Executable file
View file

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

View file

@ -1,4 +1,5 @@
nix_tests = \
init.sh \
flakes/flakes.sh \
flakes/run.sh \
flakes/mercurial.sh \