]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - test/py/multiplexed_log.py
test/py: Provide output from exceptions with RunAndLog()
[people/ms/u-boot.git] / test / py / multiplexed_log.py
index 02c44df883aedc919e479f7ef347bf6a68d08513..35a32fb5c0514fdbd8e697680bac8e338b74edb9 100644 (file)
@@ -101,6 +101,7 @@ class RunAndLog(object):
         self.logfile = logfile
         self.name = name
         self.chained_file = chained_file
+        self.output = None
 
     def close(self):
         """Clean up any resources managed by this object."""
@@ -109,6 +110,9 @@ class RunAndLog(object):
     def run(self, cmd, cwd=None, ignore_errors=False):
         """Run a command as a sub-process, and log the results.
 
+        The output is available at self.output which can be useful if there is
+        an exception.
+
         Args:
             cmd: The command to execute.
             cwd: The directory to run the command in. Can be None to use the
@@ -159,6 +163,9 @@ class RunAndLog(object):
         self.logfile.write(self, output)
         if self.chained_file:
             self.chained_file.write(output)
+
+        # Store the output so it can be accessed if we raise an exception.
+        self.output = output
         if exception:
             raise exception
         return output