aboutsummaryrefslogtreecommitdiff
path: root/nixos/lib
diff options
context:
space:
mode:
authorJanne Heß <janne@hess.ooo>2020-08-21 21:28:24 +0200
committerJanne Heß <janne@hess.ooo>2020-08-21 21:28:24 +0200
commitff03800d3bdcea31d21e624680e3ee34cad442aa (patch)
treed096f5096811fe40a83652cccbca83bb2f423989 /nixos/lib
parenta02b4af726ef0a247932f90edc0a691eff8799f5 (diff)
nixos/testing: Fix fail() function
The docs say this behaves as succeed(), but it does not return stdout as succeed() does. This fixes that behaviour
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/test-driver.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index 7b8d5803aa5a..f4e2bb6100f9 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -424,15 +424,18 @@ class Machine:
output += out
return output
- def fail(self, *commands: str) -> None:
+ def fail(self, *commands: str) -> str:
"""Execute each command and check that it fails."""
+ output = ""
for command in commands:
with self.nested("must fail: {}".format(command)):
- status, output = self.execute(command)
+ (status, out) = self.execute(command)
if status == 0:
raise Exception(
"command `{}` unexpectedly succeeded".format(command)
)
+ output += out
+ return output
def wait_until_succeeds(self, command: str) -> str:
"""Wait until a command returns success and return its output.