3
0
Fork 0
forked from mirrors/nixpkgs

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
This commit is contained in:
Janne Heß 2020-08-21 21:28:24 +02:00
parent a02b4af726
commit ff03800d3b
No known key found for this signature in database
GPG key ID: 69165158F05265DF

View file

@ -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.