| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 # the detail to the console. | 62 # the detail to the console. |
| 63 exception_formatter.PrintFormattedException() | 63 exception_formatter.PrintFormattedException() |
| 64 # This failure might have been caused by a browser or renderer | 64 # This failure might have been caused by a browser or renderer |
| 65 # crash, so restart the browser to make sure any state doesn't | 65 # crash, so restart the browser to make sure any state doesn't |
| 66 # propagate to the next test iteration. | 66 # propagate to the next test iteration. |
| 67 self._RestartBrowser('unexpected test failure') | 67 self._RestartBrowser('unexpected test failure') |
| 68 raise | 68 raise |
| 69 elif expectation == 'fail': | 69 elif expectation == 'fail': |
| 70 msg = 'Expected exception while running %s' % test_name | 70 msg = 'Expected exception while running %s' % test_name |
| 71 exception_formatter.PrintFormattedException(msg=msg) | 71 exception_formatter.PrintFormattedException(msg=msg) |
| 72 # Even though this is a known failure, the browser might still |
| 73 # be in a bad state; for example, certain kinds of timeouts |
| 74 # will affect the next test. Restart the browser to prevent |
| 75 # these kinds of failures propagating to the next test. |
| 76 self._RestartBrowser('expected test failure') |
| 72 return | 77 return |
| 73 if expectation != 'flaky': | 78 if expectation != 'flaky': |
| 74 logging.warning( | 79 logging.warning( |
| 75 'Unknown expectation %s while handling exception for %s', | 80 'Unknown expectation %s while handling exception for %s', |
| 76 expectation, test_name) | 81 expectation, test_name) |
| 77 raise | 82 raise |
| 78 # Flaky tests are handled here. | 83 # Flaky tests are handled here. |
| 79 num_retries = expectations.GetFlakyRetriesForPage( | 84 num_retries = expectations.GetFlakyRetriesForPage( |
| 80 self.browser, temp_page) | 85 self.browser, temp_page) |
| 81 if not num_retries: | 86 if not num_retries: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 141 |
| 137 def setUp(self): | 142 def setUp(self): |
| 138 try: | 143 try: |
| 139 self.tab = self.browser.tabs[0] | 144 self.tab = self.browser.tabs[0] |
| 140 except Exception: | 145 except Exception: |
| 141 # restart the browser to make sure a failure in a test doesn't | 146 # restart the browser to make sure a failure in a test doesn't |
| 142 # propagate to the next test iteration. | 147 # propagate to the next test iteration. |
| 143 logging.exception("Failure during browser startup") | 148 logging.exception("Failure during browser startup") |
| 144 self._RestartBrowser('failure in setup') | 149 self._RestartBrowser('failure in setup') |
| 145 raise | 150 raise |
| OLD | NEW |