Merge pull request #73189 from flokli/python-tests-return-multiple

nixos/tests: fix succeed() with multiple commands
This commit is contained in:
Jörg Thalheim 2019-11-11 13:48:45 +00:00 committed by GitHub
commit 556a169f14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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