Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1354)

Unified Diff: build/android/pylib/local/device/local_device_test_run.py

Issue 2134523002: [Android] Revise SIGTERM and unknown test result handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Always catch TestTerminated. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/base/base_test_result.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/local/device/local_device_test_run.py
diff --git a/build/android/pylib/local/device/local_device_test_run.py b/build/android/pylib/local/device/local_device_test_run.py
index 544fbf0e41107c40545c0875c8c99e30a963dbf5..81b855b3830ca28d893f66217347431fd4abcaf3 100644
--- a/build/android/pylib/local/device/local_device_test_run.py
+++ b/build/android/pylib/local/device/local_device_test_run.py
@@ -123,38 +123,54 @@ class LocalDeviceTestRun(test_run.TestRun):
logging.info('Finished running tests on this device.')
+ class TestsTerminated(Exception):
+ pass
+
def stop_tests(_signum, _frame):
+ logging.critical('Received SIGTERM. Stopping test execution.')
exit_now.set()
-
- with signal_handler.AddSignalHandler(signal.SIGTERM, stop_tests):
- tries = 0
- results = []
- while tries < self._env.max_tries and tests:
- logging.info('STARTING TRY #%d/%d', tries + 1, self._env.max_tries)
- logging.info('Will run %d tests on %d devices: %s',
- len(tests), len(self._env.devices),
- ', '.join(str(d) for d in self._env.devices))
- for t in tests:
- logging.debug(' %s', t)
-
- try_results = base_test_result.TestRunResults()
- if self._ShouldShard():
- tc = test_collection.TestCollection(self._CreateShards(tests))
- self._env.parallel_devices.pMap(
- run_tests_on_device, tc, try_results).pGet(None)
- else:
- self._env.parallel_devices.pMap(
- run_tests_on_device, tests, try_results).pGet(None)
-
- results.append(try_results)
- tries += 1
- tests = self._GetTestsToRetry(tests, try_results)
-
- logging.info('FINISHED TRY #%d/%d', tries, self._env.max_tries)
- if tests:
- logging.info('%d failed tests remain.', len(tests))
- else:
- logging.info('All tests completed.')
+ raise TestsTerminated()
+
+ try:
+ with signal_handler.AddSignalHandler(signal.SIGTERM, stop_tests):
+ tries = 0
+ results = []
+ while tries < self._env.max_tries and tests:
+ logging.info('STARTING TRY #%d/%d', tries + 1, self._env.max_tries)
+ logging.info('Will run %d tests on %d devices: %s',
+ len(tests), len(self._env.devices),
+ ', '.join(str(d) for d in self._env.devices))
+ for t in tests:
+ logging.debug(' %s', t)
+
+ try_results = base_test_result.TestRunResults()
+ test_names = (self._GetUniqueTestName(t) for t in tests)
+ try_results.AddResults(
+ base_test_result.BaseTestResult(
+ t, base_test_result.ResultType.UNKNOWN)
+ for t in test_names if not t.endswith('*'))
+
+ try:
+ if self._ShouldShard():
+ tc = test_collection.TestCollection(self._CreateShards(tests))
+ self._env.parallel_devices.pMap(
+ run_tests_on_device, tc, try_results).pGet(None)
+ else:
+ self._env.parallel_devices.pMap(
+ run_tests_on_device, tests, try_results).pGet(None)
+ finally:
+ results.append(try_results)
+
+ tries += 1
+ tests = self._GetTestsToRetry(tests, try_results)
+
+ logging.info('FINISHED TRY #%d/%d', tries, self._env.max_tries)
+ if tests:
+ logging.info('%d failed tests remain.', len(tests))
+ else:
+ logging.info('All tests completed.')
+ except TestsTerminated:
+ pass
return results
« no previous file with comments | « build/android/pylib/base/base_test_result.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698