git.iko.soy/typeable/nixpkgs
on master help sign in
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

commitff03800d3bdcea31d21e624680e3ee34cad442aa authorJanne Heß <janne@hess.ooo> dateFri 21 Aug 2020, 21:28 (6 years ago) parenta02b4af
1 file changed+5−2
nixos/lib/test-driver/test-driver.py+5−2
nixos/lib/test-driver/test-driver.py+5−2
@@ -424,15 +424,18 @@ class Machine:
424424 output += out
425425 return output
426426
427− def fail(self, *commands: str) -> None:
427+ def fail(self, *commands: str) -> str:
428428 """Execute each command and check that it fails."""
429+ output = ""
429430 for command in commands:
430431 with self.nested("must fail: {}".format(command)):
431− status, output = self.execute(command)
432+ (status, out) = self.execute(command)
432433 if status == 0:
433434 raise Exception(
434435 "command `{}` unexpectedly succeeded".format(command)
435436 )
437+ output += out
438+ return output
436439
437440 def wait_until_succeeds(self, command: str) -> str:
438441 """Wait until a command returns success and return its output.