summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2021-06-04 14:48:00 +0200
committertalyz <kim.lindberger@gmail.com>2021-06-05 18:44:42 +0200
commitb7749c76715ba96727f7a12bc2514ddfa6847813 (patch)
treea85f4684c53bd0ab4a35787fce95bf64edcce528 /nixos/lib
parentf36a65f6e2e9f3641f12c7d6e48a5ec4b5c5394b (diff)
downloadnixpkgs-b7749c76715ba96727f7a12bc2514ddfa6847813.tar
nixpkgs-b7749c76715ba96727f7a12bc2514ddfa6847813.tar.gz
nixpkgs-b7749c76715ba96727f7a12bc2514ddfa6847813.tar.bz2
nixpkgs-b7749c76715ba96727f7a12bc2514ddfa6847813.tar.lz
nixpkgs-b7749c76715ba96727f7a12bc2514ddfa6847813.tar.xz
nixpkgs-b7749c76715ba96727f7a12bc2514ddfa6847813.tar.zst
nixpkgs-b7749c76715ba96727f7a12bc2514ddfa6847813.zip
nixos/test-driver: Run commands with error handling
Bash's standard behavior of not propagating non-zero exit codes
through a pipeline is unexpected and almost universally
unwanted. Default to setting `pipefail` for the command being run;
it can still be turned off by prefixing the pipeline with
`set +o pipefail` if needed.

Also, set `errexit` and `nonunset` options to make the first command
of consecutive commands separated by `;` fail, and disallow
dereferencing unset variables respectively.
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/test-driver.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index e0e8b0fb71f..ab739ce3222 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -441,7 +441,7 @@ class Machine:
     def execute(self, command: str) -> Tuple[int, str]:
         self.connect()
 
-        out_command = "( {} ); echo '|!=EOF' $?\n".format(command)
+        out_command = "( set -euo pipefail; {} ); echo '|!=EOF' $?\n".format(command)
         self.shell.send(out_command.encode())
 
         output = ""