Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1456)

Side by Side Diff: tools/telemetry/telemetry/page/page_runner.py

Issue 390233002: Kill AddError/AddErrorMessage from PageTestResults. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 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 collections 5 import collections
6 import copy 6 import copy
7 import logging 7 import logging
8 import optparse 8 import optparse
9 import os 9 import os
10 import random 10 import random
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 while state.repeat_state.ShouldRepeatPage(): 416 while state.repeat_state.ShouldRepeatPage():
417 results = _PrepareAndRunPage( 417 results = _PrepareAndRunPage(
418 test, page_set, expectations, finder_options, browser_options, 418 test, page_set, expectations, finder_options, browser_options,
419 page, credentials_path, possible_browser, results, state) 419 page, credentials_path, possible_browser, results, state)
420 state.repeat_state.DidRunPage() 420 state.repeat_state.DidRunPage()
421 test.DidRunPageRepeats(page) 421 test.DidRunPageRepeats(page)
422 if (not test.max_failures is None and 422 if (not test.max_failures is None and
423 len(results.failures) > test.max_failures): 423 len(results.failures) > test.max_failures):
424 logging.error('Too many failures. Aborting.') 424 logging.error('Too many failures. Aborting.')
425 test.RequestExit() 425 test.RequestExit()
426 if (not test.max_errors is None and
427 len(results.errors) > test.max_errors):
428 logging.error('Too many errors. Aborting.')
429 test.RequestExit()
430 if test.IsExiting(): 426 if test.IsExiting():
431 break 427 break
432 state.repeat_state.DidRunPageSet() 428 state.repeat_state.DidRunPageSet()
433 429
434 test.DidRunTest(state.browser, results) 430 test.DidRunTest(state.browser, results)
435 finally: 431 finally:
436 state.StopBrowser() 432 state.StopBrowser()
437 433
438 return results 434 return results
439 435
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 'against live sites, pass the flag --use-live-sites.') 489 'against live sites, pass the flag --use-live-sites.')
494 if pages_missing_archive_data: 490 if pages_missing_archive_data:
495 logging.warning('The page set archives for some pages are missing. ' 491 logging.warning('The page set archives for some pages are missing. '
496 'Someone forgot to check them in, or they were deleted. ' 492 'Someone forgot to check them in, or they were deleted. '
497 'Skipping those pages. To fix this, record those pages ' 493 'Skipping those pages. To fix this, record those pages '
498 'using record_wpr. To ignore this warning and run ' 494 'using record_wpr. To ignore this warning and run '
499 'against live sites, pass the flag --use-live-sites.') 495 'against live sites, pass the flag --use-live-sites.')
500 496
501 for page in pages_missing_archive_path + pages_missing_archive_data: 497 for page in pages_missing_archive_path + pages_missing_archive_data:
502 results.StartTest(page) 498 results.StartTest(page)
503 results.AddErrorMessage(page, 'Page set archive doesn\'t exist.') 499 results.AddFailureMessage(page, 'Page set archive doesn\'t exist.')
504 results.StopTest(page) 500 results.StopTest(page)
505 501
506 return [page for page in pages if page not in 502 return [page for page in pages if page not in
507 pages_missing_archive_path + pages_missing_archive_data] 503 pages_missing_archive_path + pages_missing_archive_data]
508 504
509 505
510 def _RunPage(test, page, state, expectation, results, finder_options): 506 def _RunPage(test, page, state, expectation, results, finder_options):
511 if expectation == 'skip': 507 if expectation == 'skip':
512 logging.debug('Skipping test: Skip expectation for %s', page.url) 508 logging.debug('Skipping test: Skip expectation for %s', page.url)
513 results.AddSkip(page, 'Skipped by test expectations') 509 results.AddSkip(page, 'Skipped by test expectations')
514 return 510 return
515 511
516 logging.info('Running %s', page.url) 512 logging.info('Running %s', page.url)
517 513
518 page_state = PageState(page, test.TabForPage(page, state.browser)) 514 page_state = PageState(page, test.TabForPage(page, state.browser))
519 515
520 def ProcessError(): 516 def ProcessError():
521 if expectation == 'fail': 517 if expectation == 'fail':
522 msg = 'Expected exception while running %s' % page.url 518 msg = 'Expected exception while running %s' % page.url
523 results.AddSuccess(page) 519 results.AddSuccess(page)
524 else: 520 else:
525 msg = 'Exception while running %s' % page.url 521 msg = 'Exception while running %s' % page.url
526 results.AddError(page, sys.exc_info()) 522 results.AddFailure(page, sys.exc_info())
527 exception_formatter.PrintFormattedException(msg=msg) 523 exception_formatter.PrintFormattedException(msg=msg)
528 524
529 try: 525 try:
530 page_state.PreparePage(test) 526 page_state.PreparePage(test)
531 if state.repeat_state.ShouldNavigate( 527 if state.repeat_state.ShouldNavigate(
532 finder_options.skip_navigate_on_repeat): 528 finder_options.skip_navigate_on_repeat):
533 page_state.ImplicitPageNavigation(test) 529 page_state.ImplicitPageNavigation(test)
534 test.RunPage(page, page_state.tab, results) 530 test.RunPage(page, page_state.tab, results)
535 util.CloseConnections(page_state.tab) 531 util.CloseConnections(page_state.tab)
536 except page_test.TestNotSupportedOnPlatformFailure: 532 except page_test.TestNotSupportedOnPlatformFailure:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 logging.warning('Device is thermally throttled before running ' 576 logging.warning('Device is thermally throttled before running '
581 'performance tests, results will vary.') 577 'performance tests, results will vary.')
582 578
583 579
584 def _CheckThermalThrottling(platform): 580 def _CheckThermalThrottling(platform):
585 if not platform.CanMonitorThermalThrottling(): 581 if not platform.CanMonitorThermalThrottling():
586 return 582 return
587 if platform.HasBeenThermallyThrottled(): 583 if platform.HasBeenThermallyThrottled():
588 logging.warning('Device has been thermally throttled during ' 584 logging.warning('Device has been thermally throttled during '
589 'performance tests, results will vary.') 585 'performance tests, results will vary.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698