Better error message when a test fail to run.
For example, if a test has an incorrect permission, it'll print out
"Error running test <test_path>" with Exception raised.
Also, remove temp directory if it exists.
BUG=None
TEST=manual
1. Change a unittest's permission, e.g. chmod -x py/rule_unittest.py
2. make test
3. make sure that "Error running test <test_path>" is shown.
Change-Id: Ie50ee01c20aa4e2bb929006c9ecfcf256c29974b
Reviewed-on: https://chromium-review.googlesource.com/189423
Commit-Queue: Dean Liao <deanliao@chromium.org>
Tested-by: Dean Liao <deanliao@chromium.org>
Reviewed-by: Ricky Liang <jcliang@chromium.org>
diff --git a/py/tools/run_tests.py b/py/tools/run_tests.py
index c0885c7..20eb8c7 100755
--- a/py/tools/run_tests.py
+++ b/py/tools/run_tests.py
@@ -77,7 +77,8 @@
self.returncode = None
def __del__(self):
- shutil.rmtree(self.cros_factory_root)
+ if os.path.isdir(self.cros_factory_root):
+ shutil.rmtree(self.cros_factory_root)
class RunTests(object):
@@ -174,7 +175,11 @@
max_jobs: maximum number of tests to run in parallel.
"""
for test_name in tests:
- p = _TestProc(test_name, self._GetLogFilename(test_name))
+ try:
+ p = _TestProc(test_name, self._GetLogFilename(test_name))
+ except Exception as e:
+ self._FailMessage('Error running test %r' % test_name)
+ raise e
self._running_proc[p.pid] = p
self._WaitRunningProcessesFewerThan(max_jobs)
# Wait for all running test.