mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
nixos/tests: fix succeed() with multiple commands
we previously immediately returned the first commands output, and didn't execute any of the other commands. Now, return the last commands output. This should be documented in the method docstring.
This commit is contained in:
parent
1782f6c826
commit
a8e9a93493
1 changed files with 5 additions and 3 deletions
|
@ -381,15 +381,17 @@ class Machine:
|
|||
|
||||
def succeed(self, *commands):
|
||||
"""Execute each command and check that it succeeds."""
|
||||
output = ""
|
||||
for command in commands:
|
||||
with self.nested("must succeed: {}".format(command)):
|
||||
status, output = self.execute(command)
|
||||
(status, out) = self.execute(command)
|
||||
if status != 0:
|
||||
self.log("output: {}".format(output))
|
||||
self.log("output: {}".format(out))
|
||||
raise Exception(
|
||||
"command `{}` failed (exit code {})".format(command, status)
|
||||
)
|
||||
return output
|
||||
output += out
|
||||
return output
|
||||
|
||||
def fail(self, *commands):
|
||||
"""Execute each command and check that it fails."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue