Chromium Code Reviews| Index: build/android/pylib/base/shard.py |
| diff --git a/build/android/pylib/base/shard.py b/build/android/pylib/base/shard.py |
| index 03c72ef912c5540c8869859fe928caac1ea30895..b5fa84420eb79ae4b4bda1a59810e83677582ddb 100644 |
| --- a/build/android/pylib/base/shard.py |
| +++ b/build/android/pylib/base/shard.py |
| @@ -116,7 +116,8 @@ class _TestCollection(object): |
| yield r |
| -def _RunTestsFromQueue(runner, test_collection, out_results, watcher): |
| +def _RunTestsFromQueue(runner, test_collection, out_results, watcher, |
| + num_retries): |
| """Runs tests from the test_collection until empty using the given runner. |
| Adds TestRunResults objects to the out_results list and may add tests to the |
| @@ -127,6 +128,7 @@ def _RunTestsFromQueue(runner, test_collection, out_results, watcher): |
| test_collection: A _TestCollection from which to get _Test objects to run. |
| out_results: A list to add TestRunResults to. |
| watcher: A watchdog_timer.WatchdogTimer object, used as a shared timeout. |
| + num_retries: Number of retries for a test. |
| """ |
| for test in test_collection: |
| watcher.Reset() |
| @@ -138,7 +140,7 @@ def _RunTestsFromQueue(runner, test_collection, out_results, watcher): |
| raise android_commands.errors.DeviceUnresponsiveError(msg) |
| result, retry = runner.RunTest(test.test) |
| test.tries += 1 |
| - if retry and test.tries <= 3: |
| + if retry and test.tries <= num_retries: |
| # Retry non-passing results, only record passing results. |
| pass_results = base_test_result.TestRunResults() |
| pass_results.AddResults(result.GetPass()) |
| @@ -187,7 +189,7 @@ def _SetUp(runner_factory, device, out_runners, threadsafe_counter): |
| logging.warning('Failed to create shard for %s: [%s]', device, e) |
| -def _RunAllTests(runners, tests, timeout=None): |
| +def _RunAllTests(runners, tests, num_retries, timeout=None): |
| """Run all tests using the given TestRunners. |
| Args: |
| @@ -204,9 +206,10 @@ def _RunAllTests(runners, tests, timeout=None): |
| results = [] |
| watcher = watchdog_timer.WatchdogTimer(timeout) |
| workers = reraiser_thread.ReraiserThreadGroup( |
| - [reraiser_thread.ReraiserThread(_RunTestsFromQueue, |
| - [r, tests_collection, results, watcher], |
| - name=r.device[-4:]) |
| + [reraiser_thread.ReraiserThread( |
| + _RunTestsFromQueue, |
| + [r, tests_collection, results, watcher, num_retries], |
| + name=r.device[-4:]) |
| for r in runners]) |
| workers.StartAll() |
| workers.JoinAll(watcher) |
| @@ -259,7 +262,8 @@ def _TearDownRunners(runners, timeout=None): |
| def ShardAndRunTests(runner_factory, devices, tests, build_type='Debug', |
| test_timeout=DEFAULT_TIMEOUT, |
| - setup_timeout=DEFAULT_TIMEOUT): |
| + setup_timeout=DEFAULT_TIMEOUT, |
| + num_retries=2): |
|
craigdh
2013/04/12 21:20:35
add documentation for the new arg
nilesh
2013/04/12 21:42:55
Done.
|
| """Run all tests on attached devices, retrying tests that don't pass. |
| Args: |
| @@ -279,7 +283,7 @@ def ShardAndRunTests(runner_factory, devices, tests, build_type='Debug', |
| forwarder.Forwarder.KillHost(build_type) |
| runners = _CreateRunners(runner_factory, devices, setup_timeout) |
| try: |
| - return _RunAllTests(runners, tests, test_timeout) |
| + return _RunAllTests(runners, tests, num_retries, test_timeout) |
| finally: |
| try: |
| _TearDownRunners(runners, setup_timeout) |