mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 05:31:22 +00:00
98419a0f64
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.
35 lines
992 B
Nix
35 lines
992 B
Nix
# Test configuration switching.
|
|
|
|
import ./make-test.nix ({ pkgs, ...} : {
|
|
name = "switch-test";
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
|
maintainers = [ gleber ];
|
|
};
|
|
|
|
nodes = {
|
|
machine = { ... }: {
|
|
users.mutableUsers = false;
|
|
};
|
|
other = { ... }: {
|
|
users.mutableUsers = true;
|
|
};
|
|
};
|
|
|
|
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("${stderrRunner} ${originalSystem}/bin/switch-to-configuration test");
|
|
$machine->succeed("${stderrRunner} ${otherSystem}/bin/switch-to-configuration test");
|
|
'';
|
|
})
|