diff mbox

[Branch,~linaro-validation/lava-test/trunk] Rev 98: fix bug 833632 - lava-test now returns fail status when the test exits

Message ID 20111004183113.26904.28970.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Paul Larson Oct. 4, 2011, 6:31 p.m. UTC
Merge authors:
  Le Chi Thu le.chi.thu@linaro.org <le.chi.thu@linaro.org>
Related merge proposals:
  https://code.launchpad.net/~le-chi-thu/lava-test/fix-833632/+merge/77229
  proposed by: Le Chi Thu (le-chi-thu)
------------------------------------------------------------
revno: 98 [merge]
committer: Paul Larson <paul.larson@canonical.com>
branch nick: lava-test
timestamp: Tue 2011-10-04 13:28:14 -0500
message:
  fix bug 833632 - lava-test now returns fail status when the test exits
modified:
  lava_test/api/delegates.py
  lava_test/core/runners.py
  lava_test/core/tests.py
  lava_test/main.py


--
lp:lava-test
https://code.launchpad.net/~linaro-validation/lava-test/trunk

You are subscribed to branch lp:lava-test.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-test/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_test/api/delegates.py'
--- lava_test/api/delegates.py	2011-09-12 09:19:10 +0000
+++ lava_test/api/delegates.py	2011-09-27 20:07:52 +0000
@@ -80,6 +80,7 @@ 
             performed by the test runner.
         :type observer: :class:`~lava_test.api.observers.ITestRunnerObserver` 
 
+        :return true if any test step return none-zero return code
         .. versionadded:: 0.2
         """
 

=== modified file 'lava_test/core/runners.py'
--- lava_test/core/runners.py	2011-09-12 09:19:10 +0000
+++ lava_test/core/runners.py	2011-09-27 20:07:52 +0000
@@ -44,14 +44,17 @@ 
         stderr = open(artifacts.stderr_pathname, 'at')
         delegate = DisplayDelegate(stdout, stderr, observer)
         extcmd = ExternalCommandWithDelegate(delegate)
+        run_failed = False
         try:
             for cmd in self.steps:
                 if observer: observer.about_to_run_shell_command(cmd)
                 returncode = extcmd.call(cmd, shell=True)
                 if observer: observer.did_run_shell_command(cmd, returncode)
+                if (returncode != 00): run_failed = True
         finally:
             stdout.close()
             stderr.close()
+        return run_failed
 
     def run(self, artifacts, observer=None):
         """
@@ -62,5 +65,6 @@ 
             :meth:`~lava_test.api.delegates.TestRunner.run`
         """
         self.starttime = datetime.datetime.utcnow()
-        self._run_lava_test_steps(artifacts, observer)
+        run_failed = self._run_lava_test_steps(artifacts, observer)
         self.endtime = datetime.datetime.utcnow()
+        return run_failed

=== modified file 'lava_test/core/tests.py'
--- lava_test/core/tests.py	2011-09-12 09:19:10 +0000
+++ lava_test/core/tests.py	2011-09-27 20:07:52 +0000
@@ -126,7 +126,10 @@ 
             logging.debug(
                 "Invoking %r.run_and_store_artifacts(...)",
                 self.runner, observer)
-            self.runner.run(artifacts, observer)
+            run_fail = self.runner.run(artifacts, observer)
+            if run_fail:
+                raise RuntimeError('Some of test steps returned non-zero exit code')
+            
         return artifacts
 
     def parse(self, artifacts):

=== modified file 'lava_test/main.py'
--- lava_test/main.py	2011-09-13 22:43:20 +0000
+++ lava_test/main.py	2011-09-27 20:07:52 +0000
@@ -48,4 +48,5 @@ 
     import sys
     arg_only = sys.argv
     arg_only.remove(arg_only[0])
-    LAVATestDispatcher().dispatch(arg_only)
\ No newline at end of file
+    code = LAVATestDispatcher().dispatch(arg_only)
+    if (code != 0): exit(code)
\ No newline at end of file