| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import fnmatch | 5 import fnmatch |
| 6 import functools | 6 import functools |
| 7 import imp | 7 import imp |
| 8 import logging | 8 import logging |
| 9 import signal | 9 import signal |
| 10 import thread | 10 import thread |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 logging.info('%d failed tests remain.', len(tests)) | 169 logging.info('%d failed tests remain.', len(tests)) |
| 170 else: | 170 else: |
| 171 logging.info('All tests completed.') | 171 logging.info('All tests completed.') |
| 172 except TestsTerminated: | 172 except TestsTerminated: |
| 173 pass | 173 pass |
| 174 | 174 |
| 175 return results | 175 return results |
| 176 | 176 |
| 177 def _GetTestsToRetry(self, tests, try_results): | 177 def _GetTestsToRetry(self, tests, try_results): |
| 178 | 178 |
| 179 def is_failure(test_result): | 179 def is_failure_result(test_result): |
| 180 return ( | 180 return ( |
| 181 test_result is None | 181 test_result is None |
| 182 or test_result.GetType() not in ( | 182 or test_result.GetType() not in ( |
| 183 base_test_result.ResultType.PASS, | 183 base_test_result.ResultType.PASS, |
| 184 base_test_result.ResultType.SKIP)) | 184 base_test_result.ResultType.SKIP)) |
| 185 | 185 |
| 186 all_test_results = {r.GetName(): r for r in try_results.GetAll()} | 186 all_test_results = {r.GetName(): r for r in try_results.GetAll()} |
| 187 | 187 |
| 188 def should_retry(name): | 188 def test_failed(name): |
| 189 # When specifying a test filter, names can contain trailing wildcards. | 189 # When specifying a test filter, names can contain trailing wildcards. |
| 190 # See local_device_gtest_run._ExtractTestsFromFilter() | 190 # See local_device_gtest_run._ExtractTestsFromFilter() |
| 191 if name.endswith('*'): | 191 if name.endswith('*'): |
| 192 return any(fnmatch.fnmatch(n, name) and is_failure(t) | 192 return any(fnmatch.fnmatch(n, name) and is_failure_result(t) |
| 193 for n, t in all_test_results.iteritems()) | 193 for n, t in all_test_results.iteritems()) |
| 194 return is_failure(all_test_results.get(name)) | 194 return is_failure_result(all_test_results.get(name)) |
| 195 | 195 |
| 196 return [t for t in tests if should_retry(self._GetUniqueTestName(t))] | 196 failed_tests = (t for t in tests if test_failed(self._GetUniqueTestName(t))) |
| 197 |
| 198 return [t for t in failed_tests if self._ShouldRetry(t)] |
| 197 | 199 |
| 198 def GetTool(self, device): | 200 def GetTool(self, device): |
| 199 if not str(device) in self._tools: | 201 if not str(device) in self._tools: |
| 200 self._tools[str(device)] = valgrind_tools.CreateTool( | 202 self._tools[str(device)] = valgrind_tools.CreateTool( |
| 201 self._env.tool, device) | 203 self._env.tool, device) |
| 202 return self._tools[str(device)] | 204 return self._tools[str(device)] |
| 203 | 205 |
| 204 def _CreateShards(self, tests): | 206 def _CreateShards(self, tests): |
| 205 raise NotImplementedError | 207 raise NotImplementedError |
| 206 | 208 |
| 207 # pylint: disable=no-self-use | |
| 208 def _GetUniqueTestName(self, test): | 209 def _GetUniqueTestName(self, test): |
| 210 # pylint: disable=no-self-use |
| 209 return test | 211 return test |
| 210 | 212 |
| 213 def _ShouldRetry(self, test): |
| 214 # pylint: disable=no-self-use,unused-argument |
| 215 return True |
| 216 |
| 211 def _GetTests(self): | 217 def _GetTests(self): |
| 212 raise NotImplementedError | 218 raise NotImplementedError |
| 213 | 219 |
| 214 def _RunTest(self, device, test): | 220 def _RunTest(self, device, test): |
| 215 raise NotImplementedError | 221 raise NotImplementedError |
| 216 | 222 |
| 217 def _ShouldShard(self): | 223 def _ShouldShard(self): |
| 218 raise NotImplementedError | 224 raise NotImplementedError |
| OLD | NEW |