nixos/tests/switch-test: Ensures the test fails on failure (#55744)
The `| tee` invocation always masked the return value of the switch-to-configuration test. ``` ~ $ false | tee && echo "oh no" oh no ``` The added wrapper script will still output everything to stderr, while passing failures to the test harness.
This commit is contained in:
parent
4a340dbfa7
commit
98419a0f64
1 changed files with 11 additions and 2 deletions
|
@ -18,8 +18,17 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||
testScript = {nodes, ...}: let
|
||||
originalSystem = nodes.machine.config.system.build.toplevel;
|
||||
otherSystem = nodes.other.config.system.build.toplevel;
|
||||
|
||||
# Ensures failures pass through using pipefail, otherwise failing to
|
||||
# switch-to-configuration is hidden by the success of `tee`.
|
||||
stderrRunner = pkgs.writeScript "stderr-runner" ''
|
||||
#! ${pkgs.stdenv.shell}
|
||||
set -e
|
||||
set -o pipefail
|
||||
exec env -i "$@" | tee /dev/stderr
|
||||
'';
|
||||
in ''
|
||||
$machine->succeed("env -i ${originalSystem}/bin/switch-to-configuration test | tee /dev/stderr");
|
||||
$machine->succeed("env -i ${otherSystem}/bin/switch-to-configuration test | tee /dev/stderr");
|
||||
$machine->succeed("${stderrRunner} ${originalSystem}/bin/switch-to-configuration test");
|
||||
$machine->succeed("${stderrRunner} ${otherSystem}/bin/switch-to-configuration test");
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue