about summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2019-11-11 01:24:49 +0100
committerFlorian Klink <flokli@flokli.de>2019-11-11 13:45:11 +0100
commita8e9a93493bca33f59b6c893cd8af459b18ab619 (patch)
treefe294c548eeb2b600b355721ea364d07d53f8b35 /nixos/lib
parent1782f6c8264d20454baa8337c8846721ffb20790 (diff)
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.
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/test-driver.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index c8940d78af4ec..c8d4936ac52a1 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -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."""