diff options
author | Samuel Dionne-Riel <samuel@dionne-riel.com> | 2019-02-14 16:55:16 -0500 |
---|---|---|
committer | xeji <36407913+xeji@users.noreply.github.com> | 2019-02-14 22:55:16 +0100 |
commit | 98419a0f6453a99e9f57da7edcc53d662561a4f2 (patch) | |
tree | b4ea98c530691cc84f815c2c5f435a7f4299dd28 | |
parent | 4a340dbfa781b7fbc4c5ff8378013df9cae9b24b (diff) |
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.
-rw-r--r-- | nixos/tests/switch-test.nix | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix index 32010838e67b..0dba3697980f 100644 --- a/nixos/tests/switch-test.nix +++ b/nixos/tests/switch-test.nix @@ -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"); ''; }) |