about summary refs log tree commit diff stats
path: root/tests/infrastructure/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tests/infrastructure/default.nix')
-rw-r--r--tests/infrastructure/default.nix15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/infrastructure/default.nix b/tests/infrastructure/default.nix
index 4f1ec7a2..64a6ad01 100644
--- a/tests/infrastructure/default.nix
+++ b/tests/infrastructure/default.nix
@@ -82,7 +82,7 @@ nixos-lib.runTest {
       ''}")
 
       machine.succeed("sudo -u soispha ${pkgs.writeShellScript "mkGoldenRecord" ''
-        set -e
+        set -ex
 
         # HACK: Prevent zsh from complaining about missing configuration.
         # TODO: These tests should probably just run under bash. <2024-11-22>
@@ -95,6 +95,8 @@ nixos-lib.runTest {
 
         __TEST_EVAL_AWK_CLEAN_FILE="${./clean.awk}"
         __TEST_EVAL_LOG_FILE="${logFile}"
+        __TEST_EVAL_GOLDEN_FILE="$(mktemp)"
+        printf "%s" "${goldenFile}" >"$__TEST_EVAL_GOLDEN_FILE"
 
         . ${./driver.sh}
 
@@ -105,9 +107,16 @@ nixos-lib.runTest {
 
         # Clear the pipe again
         "$__TEST_TMUX" pipe-pane -t "$__TEST_TMUX_PANE"
+
+        # Check if the golden file was changed.
+        if [ "$(cat "$__TEST_EVAL_GOLDEN_FILE")" != "${goldenFile}" ]; then
+          mv "$(cat "$__TEST_EVAL_GOLDEN_FILE")" "${goldenFile}"
+        fi
+
+        rm "$__TEST_EVAL_GOLDEN_FILE"
       ''}")
 
-      machine.succeed("sudo -u soispha ${pkgs.writeShellScript "testHashOfGolden" ''
+      machine.succeed("sudo -u soispha ${pkgs.writeShellScript "testHashOfGolden" (''
           set -e
 
           cd "${testDir}"
@@ -127,7 +136,7 @@ nixos-lib.runTest {
           else
             echo "Hash was successfully checked."
           fi
-        ''}")
+        '')}")
 
 
       machine.copy_from_vm("${goldenFile}", "golden")