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

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

Issue 737463002: [Telemetry] Move more browser specific logic to shared_page_state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 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
11 11
12 from telemetry import decorators 12 from telemetry import decorators
13 from telemetry.core import browser_info
14 from telemetry.core import exceptions 13 from telemetry.core import exceptions
15 from telemetry.core import util 14 from telemetry.core import util
16 from telemetry.core import wpr_modes 15 from telemetry.core import wpr_modes
17 from telemetry.core.platform.profiler import profiler_finder 16 from telemetry.core.platform.profiler import profiler_finder
18 from telemetry.page import shared_page_state 17 from telemetry.page import shared_page_state
19 from telemetry.page import page_filter 18 from telemetry.page import page_filter
20 from telemetry.page import page_test 19 from telemetry.page import page_test
21 from telemetry.page.actions import page_action 20 from telemetry.page.actions import page_action
22 from telemetry.results import results_options 21 from telemetry.results import results_options
23 from telemetry.util import cloud_storage 22 from telemetry.util import cloud_storage
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 def ProcessError(): 82 def ProcessError():
84 if expectation == 'fail': 83 if expectation == 'fail':
85 msg = 'Expected exception while running %s' % page.url 84 msg = 'Expected exception while running %s' % page.url
86 exception_formatter.PrintFormattedException(msg=msg) 85 exception_formatter.PrintFormattedException(msg=msg)
87 else: 86 else:
88 msg = 'Exception while running %s' % page.url 87 msg = 'Exception while running %s' % page.url
89 results.AddValue(failure.FailureValue(page, sys.exc_info())) 88 results.AddValue(failure.FailureValue(page, sys.exc_info()))
90 89
91 try: 90 try:
92 state.WillRunPage(page, page_set) 91 state.WillRunPage(page, page_set)
93 if not page.CanRunOnBrowser(browser_info.BrowserInfo(state.browser)): 92 expectation, skip_value = state.GetPageExpectationAndSkipValue(expectations)
94 logging.info('Skip test for page %s because browser is not supported.' 93 if expectation == 'skip':
95 % page.url) 94 assert skip_value
tonyg 2014/11/17 18:35:10 We probably want an error message w/ this assert.
nednguyen 2014/11/17 19:38:00 results.AddValue(skip_value) does display skip_val
95 results.AddValue(skip_value)
96 return 96 return
97 expectation = expectations.GetExpectationForPage(state.browser, page)
98
99 if expectation == 'skip':
100 logging.debug('Skipping test: Skip expectation for %s', page.url)
101 results.AddValue(skip.SkipValue(page, 'Skipped by test expectations'))
102 return
103
104 state.PreparePage()
105 state.ImplicitPageNavigation()
106 state.RunPage(results) 97 state.RunPage(results)
107 except page_test.TestNotSupportedOnPlatformFailure: 98 except page_test.TestNotSupportedOnPlatformFailure:
108 raise 99 raise
109 except (page_test.Failure, util.TimeoutException, exceptions.LoginException, 100 except (page_test.Failure, util.TimeoutException, exceptions.LoginException,
110 exceptions.ProfilingException): 101 exceptions.ProfilingException):
111 ProcessError() 102 ProcessError()
112 except (exceptions.TabCrashException, exceptions.BrowserGoneException): 103 except (exceptions.TabCrashException, exceptions.BrowserGoneException):
113 ProcessError() 104 ProcessError()
114 state.TearDown() 105 state.TearDown()
115 if test.is_multi_tab_test: 106 if test.is_multi_tab_test:
116 logging.error('Aborting multi-tab test after browser or tab crashed at ' 107 logging.error('Aborting multi-tab test after browser or tab crashed at '
117 'page %s' % page.url) 108 'page %s' % page.url)
118 test.RequestExit() 109 test.RequestExit()
119 return 110 return
120 except page_action.PageActionNotSupported as e: 111 except page_action.PageActionNotSupported as e:
121 results.AddValue(skip.SkipValue(page, 'Unsupported page action: %s' % e)) 112 results.AddValue(skip.SkipValue(page, 'Unsupported page action: %s' % e))
122 except Exception: 113 except Exception:
123 exception_formatter.PrintFormattedException( 114 exception_formatter.PrintFormattedException(
124 msg='Unhandled exception while running %s' % page.url) 115 msg='Unhandled exception while running %s' % page.url)
125 results.AddValue(failure.FailureValue(page, sys.exc_info())) 116 results.AddValue(failure.FailureValue(page, sys.exc_info()))
126 else: 117 else:
127 if expectation == 'fail': 118 if expectation == 'fail':
128 logging.warning('%s was expected to fail, but passed.\n', page.url) 119 logging.warning('%s was expected to fail, but passed.\n', page.url)
129 finally: 120 finally:
130 state.CleanUpPage()
131 state.DidRunPage() 121 state.DidRunPage()
132 122
133 123
134 @decorators.Cache 124 @decorators.Cache
135 def _UpdatePageSetArchivesIfChanged(page_set): 125 def _UpdatePageSetArchivesIfChanged(page_set):
136 # Scan every serving directory for .sha1 files 126 # Scan every serving directory for .sha1 files
137 # and download them from Cloud Storage. Assume all data is public. 127 # and download them from Cloud Storage. Assume all data is public.
138 all_serving_dirs = page_set.serving_dirs.copy() 128 all_serving_dirs = page_set.serving_dirs.copy()
139 # Add individual page dirs to all serving dirs. 129 # Add individual page dirs to all serving dirs.
140 for page in page_set: 130 for page in page_set:
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 logging.warning('Device is thermally throttled before running ' 290 logging.warning('Device is thermally throttled before running '
301 'performance tests, results will vary.') 291 'performance tests, results will vary.')
302 292
303 293
304 def _CheckThermalThrottling(platform): 294 def _CheckThermalThrottling(platform):
305 if not platform.CanMonitorThermalThrottling(): 295 if not platform.CanMonitorThermalThrottling():
306 return 296 return
307 if platform.HasBeenThermallyThrottled(): 297 if platform.HasBeenThermallyThrottled():
308 logging.warning('Device has been thermally throttled during ' 298 logging.warning('Device has been thermally throttled during '
309 'performance tests, results will vary.') 299 'performance tests, results will vary.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698