From 726f74d9ec7d6b31ff124ceaddc7ac22b423055f Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sun, 12 Dec 2021 17:08:16 +0100 Subject: [PATCH] tests: restore the initial generation before each test When developing it can happen to break the nix-on-droid script. If so, this fix will ensure that each test has a working nix-on-droid script available. --- tests/on-device/.run.sh | 7 +++++++ tests/on-device/lib.bash | 3 +++ 2 files changed, 10 insertions(+) diff --git a/tests/on-device/.run.sh b/tests/on-device/.run.sh index fc3588a..f4ff032 100755 --- a/tests/on-device/.run.sh +++ b/tests/on-device/.run.sh @@ -6,8 +6,11 @@ set -ueo pipefail SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" +PROFILE_DIRECTORY="/nix/var/nix/profiles/nix-on-droid" + SELF_TEST_DIR="$HOME/.cache/nix-on-droid-self-test" CONFIRMATION_FILE="$SELF_TEST_DIR/confirmation-granted" +DEFAULT_ACTIVATE_SCRIPT="$SELF_TEST_DIR/default-activate" mkdir -p "$SELF_TEST_DIR" if [[ ! -e "$CONFIRMATION_FILE" ]]; then @@ -21,6 +24,10 @@ if [[ ! -e "$CONFIRMATION_FILE" ]]; then touch "$CONFIRMATION_FILE" fi +if [[ ! -e "$DEFAULT_ACTIVATE_SCRIPT" ]]; then + ln -sn "$(readlink -f "$PROFILE_DIRECTORY/activate")" "$DEFAULT_ACTIVATE_SCRIPT" +fi + if [[ ! -d ~/.config.bak ]]; then mv ~/.config ~/.config.bak cp -r ~/.config.bak ~/.config diff --git a/tests/on-device/lib.bash b/tests/on-device/lib.bash index e179e15..f22ad35 100644 --- a/tests/on-device/lib.bash +++ b/tests/on-device/lib.bash @@ -23,6 +23,9 @@ setup() { ON_DEVICE_TESTS_SETUP=1 fi + + # restore to pre-testing generation before the start of each test + $DEFAULT_ACTIVATE_SCRIPT } assert_command() {