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:
parent
a02b4af726
commit
ff03800d3b
|
@ -424,15 +424,18 @@ class Machine:
|
||||||
output += out
|
output += out
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def fail(self, *commands: str) -> None:
|
def fail(self, *commands: str) -> str:
|
||||||
"""Execute each command and check that it fails."""
|
"""Execute each command and check that it fails."""
|
||||||
|
output = ""
|
||||||
for command in commands:
|
for command in commands:
|
||||||
with self.nested("must fail: {}".format(command)):
|
with self.nested("must fail: {}".format(command)):
|
||||||
status, output = self.execute(command)
|
(status, out) = self.execute(command)
|
||||||
if status == 0:
|
if status == 0:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"command `{}` unexpectedly succeeded".format(command)
|
"command `{}` unexpectedly succeeded".format(command)
|
||||||
)
|
)
|
||||||
|
output += out
|
||||||
|
return output
|
||||||
|
|
||||||
def wait_until_succeeds(self, command: str) -> str:
|
def wait_until_succeeds(self, command: str) -> str:
|
||||||
"""Wait until a command returns success and return its output.
|
"""Wait until a command returns success and return its output.
|
||||||
|
|
Loading…
Reference in New Issue