| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 logging | 5 import logging |
| 6 | 6 |
| 7 from telemetry.testing import serially_executed_browser_test_case | 7 from telemetry.testing import serially_executed_browser_test_case |
| 8 | 8 |
| 9 from gpu_tests import exception_formatter | 9 from gpu_tests import exception_formatter |
| 10 from gpu_tests import gpu_test_expectations | 10 from gpu_tests import gpu_test_expectations |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): | 23 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): |
| 24 | 24 |
| 25 _cached_expectations = None | 25 _cached_expectations = None |
| 26 | 26 |
| 27 @classmethod | 27 @classmethod |
| 28 def GenerateTestCases__RunGpuTest(cls, options): | 28 def GenerateTestCases__RunGpuTest(cls, options): |
| 29 for test_name, url, args in cls.GenerateGpuTests(options): | 29 for test_name, url, args in cls.GenerateGpuTests(options): |
| 30 yield test_name, (url, test_name, args) | 30 yield test_name, (url, test_name, args) |
| 31 | 31 |
| 32 def _RestartBrowser(self, reason): | 32 def _RestartBrowser(self, reason): |
| 33 logging.warning('Restarting browser due to ' + reason) | 33 for x in range(0, 3): |
| 34 self.StopBrowser() | 34 try: |
| 35 self.SetBrowserOptions(self._finder_options) | 35 restart_attempt = ('Restarting browser %d time due to ' |
| 36 self.StartBrowser() | 36 % (x + 1)) |
| 37 self.tab = self.browser.tabs[0] | 37 logging.warning(restart_attempt + reason) |
| 38 self.StopBrowser() |
| 39 self.SetBrowserOptions(self._finder_options) |
| 40 self.StartBrowser() |
| 41 self.tab = self.browser.tabs[0] |
| 42 return |
| 43 except Exception: |
| 44 # If we are on the last try and there is an exception raise it |
| 45 if x == 2: |
| 46 raise |
| 38 | 47 |
| 39 def _RunGpuTest(self, url, test_name, args): | 48 def _RunGpuTest(self, url, test_name, args): |
| 40 temp_page = _EmulatedPage(url, test_name) | 49 temp_page = _EmulatedPage(url, test_name) |
| 41 expectations = self.__class__.GetExpectations() | 50 expectations = self.__class__.GetExpectations() |
| 42 expectation = expectations.GetExpectationForPage( | 51 expectation = expectations.GetExpectationForPage( |
| 43 self.browser, temp_page) | 52 self.browser, temp_page) |
| 44 if expectation == 'skip': | 53 if expectation == 'skip': |
| 45 # skipTest in Python's unittest harness raises an exception, so | 54 # skipTest in Python's unittest harness raises an exception, so |
| 46 # aborts the control flow here. | 55 # aborts the control flow here. |
| 47 self.skipTest('SKIPPING TEST due to test expectations') | 56 self.skipTest('SKIPPING TEST due to test expectations') |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 136 |
| 128 def setUp(self): | 137 def setUp(self): |
| 129 try: | 138 try: |
| 130 self.tab = self.browser.tabs[0] | 139 self.tab = self.browser.tabs[0] |
| 131 except Exception: | 140 except Exception: |
| 132 # restart the browser to make sure a failure in a test doesn't | 141 # restart the browser to make sure a failure in a test doesn't |
| 133 # propagate to the next test iteration. | 142 # propagate to the next test iteration. |
| 134 logging.exception("Failure during browser startup") | 143 logging.exception("Failure during browser startup") |
| 135 self._RestartBrowser('failure in setup') | 144 self._RestartBrowser('failure in setup') |
| 136 raise | 145 raise |
| OLD | NEW |