diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-11-24 18:01:02 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-11-24 18:24:58 +0100 |
commit | 445ee1fa4a9e82250d21c66ba957a1e19077efd9 (patch) | |
tree | 6efbe6a5fe6fcad0da3b57443b246f53eaa81588 /tests/infrastructure/default.nix | |
parent | fix(modules/nvim/opts): Ensure a consistent fileformat (diff) | |
download | nixos-config-445ee1fa4a9e82250d21c66ba957a1e19077efd9.tar.gz nixos-config-445ee1fa4a9e82250d21c66ba957a1e19077efd9.zip |
tests(infrastructure/driver): Support setting the golden file
Diffstat (limited to 'tests/infrastructure/default.nix')
-rw-r--r-- | tests/infrastructure/default.nix | 15 |
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") |