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 logging | 5 import logging |
6 import optparse | 6 import optparse |
7 import os | 7 import os |
8 import random | 8 import random |
9 import sys | 9 import sys |
10 import time | 10 import time |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 | 190 |
191 def Run(test, user_story_set, expectations, finder_options, results, | 191 def Run(test, user_story_set, expectations, finder_options, results, |
192 max_failures=None): | 192 max_failures=None): |
193 """Runs a given test against a given page_set with the given options. | 193 """Runs a given test against a given page_set with the given options. |
194 | 194 |
195 Stop execution for unexpected exceptions such as KeyboardInterrupt. | 195 Stop execution for unexpected exceptions such as KeyboardInterrupt. |
196 We "white list" certain exceptions for which the user story runner | 196 We "white list" certain exceptions for which the user story runner |
197 can continue running the remaining user stories. | 197 can continue running the remaining user stories. |
198 """ | 198 """ |
199 test.ValidatePageSet(user_story_set) | 199 # TODO(slamm): Remove special-case for PageTest. https://crbug.com/440101 |
| 200 if isinstance(test, page_test.PageTest): |
| 201 test.ValidatePageSet(user_story_set) |
200 | 202 |
201 # Reorder page set based on options. | 203 # Reorder page set based on options. |
202 user_stories = _ShuffleAndFilterUserStorySet(user_story_set, finder_options) | 204 user_stories = _ShuffleAndFilterUserStorySet(user_story_set, finder_options) |
203 | 205 |
204 if (not finder_options.use_live_sites and | 206 if (not finder_options.use_live_sites and |
205 finder_options.browser_options.wpr_mode != wpr_modes.WPR_RECORD): | 207 finder_options.browser_options.wpr_mode != wpr_modes.WPR_RECORD): |
206 _UpdateUserStoryArchivesIfChanged(user_story_set) | 208 _UpdateUserStoryArchivesIfChanged(user_story_set) |
207 if not _CheckArchives( | 209 if not _CheckArchives( |
208 user_story_set.archive_data_file, user_story_set.wpr_archive_info, | 210 user_story_set.archive_data_file, user_story_set.wpr_archive_info, |
209 user_stories): | 211 user_stories): |
210 return | 212 return |
211 | 213 |
212 for user_story in list(user_stories): | 214 # TODO(slamm): Remove special-case for PageTest. https://crbug.com/440101 |
213 if not test.CanRunForPage(user_story): | 215 if isinstance(test, page_test.PageTest): |
214 results.WillRunPage(user_story) | 216 for user_story in list(user_stories): |
215 logging.debug('Skipping test: it cannot run for %s', | 217 if not test.CanRunForPage(user_story): |
216 user_story.display_name) | 218 results.WillRunPage(user_story) |
217 results.AddValue(skip.SkipValue(user_story, 'Test cannot run')) | 219 logging.debug('Skipping test: it cannot run for %s', |
218 results.DidRunPage(user_story) | 220 user_story.display_name) |
219 user_stories.remove(user_story) | 221 results.AddValue(skip.SkipValue(user_story, 'Test cannot run')) |
| 222 results.DidRunPage(user_story) |
| 223 user_stories.remove(user_story) |
220 | 224 |
221 if not user_stories: | 225 if not user_stories: |
222 return | 226 return |
223 | 227 |
224 # Effective max failures gives priority to command-line flag value. | 228 # Effective max failures gives priority to command-line flag value. |
225 effective_max_failures = finder_options.max_failures | 229 effective_max_failures = finder_options.max_failures |
226 if effective_max_failures is None: | 230 if effective_max_failures is None: |
227 effective_max_failures = max_failures | 231 effective_max_failures = max_failures |
228 | 232 |
229 user_story_groups = GetUserStoryGroupsWithSameSharedUserStoryClass( | 233 user_story_groups = GetUserStoryGroupsWithSameSharedUserStoryClass( |
(...skipping 23 matching lines...) Expand all Loading... |
253 # (The AppCrashException was saved as a failure value.) | 257 # (The AppCrashException was saved as a failure value.) |
254 state.TearDownState(results) | 258 state.TearDownState(results) |
255 finally: | 259 finally: |
256 # Later finally-blocks use state, so ensure it is cleared. | 260 # Later finally-blocks use state, so ensure it is cleared. |
257 state = None | 261 state = None |
258 finally: | 262 finally: |
259 has_existing_exception = sys.exc_info() is not None | 263 has_existing_exception = sys.exc_info() is not None |
260 try: | 264 try: |
261 if state: | 265 if state: |
262 _CheckThermalThrottling(state.platform) | 266 _CheckThermalThrottling(state.platform) |
263 discard_run = (test.discard_first_result and | 267 # TODO(slamm): Make discard_first_result part of user_story API. |
264 user_story not in | 268 # https://crbug.com/440101 |
265 user_story_with_discarded_first_results) | 269 discard_current_run = ( |
266 if discard_run: | 270 getattr(test, 'discard_first_result', False) and |
| 271 user_story not in user_story_with_discarded_first_results) |
| 272 if discard_current_run: |
267 user_story_with_discarded_first_results.add(user_story) | 273 user_story_with_discarded_first_results.add(user_story) |
268 results.DidRunPage(user_story, discard_run=discard_run) | 274 results.DidRunPage(user_story, discard_run=discard_current_run) |
269 except Exception: | 275 except Exception: |
270 if not has_existing_exception: | 276 if not has_existing_exception: |
271 raise | 277 raise |
272 # Print current exception and propagate existing exception. | 278 # Print current exception and propagate existing exception. |
273 exception_formatter.PrintFormattedException( | 279 exception_formatter.PrintFormattedException( |
274 msg='Exception from result processing:') | 280 msg='Exception from result processing:') |
275 if (effective_max_failures is not None and | 281 if (effective_max_failures is not None and |
276 len(results.failures) > effective_max_failures): | 282 len(results.failures) > effective_max_failures): |
277 logging.error('Too many failures. Aborting.') | 283 logging.error('Too many failures. Aborting.') |
278 return | 284 return |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 logging.warning('Device is thermally throttled before running ' | 385 logging.warning('Device is thermally throttled before running ' |
380 'performance tests, results will vary.') | 386 'performance tests, results will vary.') |
381 | 387 |
382 | 388 |
383 def _CheckThermalThrottling(platform): | 389 def _CheckThermalThrottling(platform): |
384 if not platform.CanMonitorThermalThrottling(): | 390 if not platform.CanMonitorThermalThrottling(): |
385 return | 391 return |
386 if platform.HasBeenThermallyThrottled(): | 392 if platform.HasBeenThermallyThrottled(): |
387 logging.warning('Device has been thermally throttled during ' | 393 logging.warning('Device has been thermally throttled during ' |
388 'performance tests, results will vary.') | 394 'performance tests, results will vary.') |
OLD | NEW |