Chromium Code Reviews| Index: tools/telemetry/telemetry/page_runner.py |
| diff --git a/tools/telemetry/telemetry/page_runner.py b/tools/telemetry/telemetry/page_runner.py |
| index 6600ce664e0245fe0777dd38a5aff32cca5140d1..6bc4f70504284c5cd88af890d3797aeac984ba7a 100644 |
| --- a/tools/telemetry/telemetry/page_runner.py |
| +++ b/tools/telemetry/telemetry/page_runner.py |
| @@ -3,7 +3,6 @@ |
| # found in the LICENSE file. |
| import logging |
| import os |
| -import re |
| import time |
| import traceback |
| import urlparse |
| @@ -35,7 +34,7 @@ class _RunState(object): |
| self.browser.Close() |
| self.browser = None |
| -def _ShuffleAndFilterPageSet(page_set, options): |
| +def _ShufflePageSet(page_set, options): |
| if options.test_shuffle_order_file and not options.test_shuffle: |
| raise Exception('--test-shuffle-order-file requires --test-shuffle.') |
| @@ -43,13 +42,6 @@ def _ShuffleAndFilterPageSet(page_set, options): |
| return page_set.ReorderPageSet(options.test_shuffle_order_file) |
| pages = page_set.pages[:] |
| - if options.page_filter: |
| - try: |
| - page_regex = re.compile(options.page_filter) |
| - except re.error: |
| - raise Exception('--page-filter: invalid regex') |
| - pages = [page for page in pages if page_regex.search(page.url)] |
| - |
| if options.test_shuffle: |
| random.Random().shuffle(pages) |
| return [page |
| @@ -69,30 +61,26 @@ class PageRunner(object): |
| self.Close() |
| def Run(self, options, possible_browser, test, results): |
| - # Set up WPR mode. |
| - if not self.page_set.archive_path: |
| - archive_path = '' |
| - if not self.page_set.ContainsOnlyFileURLs(): |
| + # Check if we can run against WPR. |
| + for page in self.page_set.pages: |
| + parsed_url = urlparse.urlparse(page.url) |
| + if parsed_url.scheme == 'file': |
| + continue |
| + if not page.archive_path: |
| logging.warning(""" |
| - No page set archive provided for the chosen page set. Benchmarking against |
| - live sites! Results won't be repeatable or comparable. |
| -""") |
| - else: |
| - archive_path = os.path.abspath(os.path.join(self.page_set.base_dir, |
| - self.page_set.archive_path)) |
| - if options.wpr_mode == wpr_modes.WPR_OFF: |
| - if os.path.isfile(archive_path): |
| - possible_browser.options.wpr_mode = wpr_modes.WPR_REPLAY |
| - else: |
| - possible_browser.options.wpr_mode = wpr_modes.WPR_OFF |
| - if not self.page_set.ContainsOnlyFileURLs(): |
| - logging.warning(""" |
| - The page set archive %s does not exist, benchmarking against live sites! |
| + No page set archive provided for the page %s. Benchmarking against live sites! |
| Results won't be repeatable or comparable. |
| +""", page.url) |
| + elif options.wpr_mode == wpr_modes.WPR_OFF: |
| + # The page has an archive, and we're not recording. |
| + if not os.path.isfile(page.archive_path): |
| + logging.warning(""" |
| + The page set archive %s for page %s does not exist, benchmarking against live |
| + sites! Results won't be repeatable or comparable. |
| To fix this, either add svn-internal to your .gclient using |
| http://goto/read-src-internal, or create a new archive using record_wpr. |
| - """, os.path.relpath(archive_path)) |
| + """, os.path.relpath(page.archive_path), page.url) |
| # Verify credentials path. |
| credentials_path = None |
| @@ -120,17 +108,27 @@ class PageRunner(object): |
| raise Exception('Trace directory isn\'t empty: %s' % options.trace_dir) |
| # Reorder page set based on options. |
| - pages = _ShuffleAndFilterPageSet(self.page_set, options) |
| + pages = _ShufflePageSet(self.page_set, options) |
| state = _RunState() |
| + last_archive_path = None |
| try: |
| for page in pages: |
| + if options.wpr_mode == wpr_modes.WPR_OFF: |
|
dtu
2013/01/23 21:07:02
I think "!= wpr_modes.WPR_RECORD" is clearer
marja
2013/01/24 16:03:33
Done.
|
| + if os.path.isfile(page.archive_path): |
| + possible_browser.options.wpr_mode = wpr_modes.WPR_REPLAY |
| + else: |
| + possible_browser.options.wpr_mode = wpr_modes.WPR_OFF |
| + if last_archive_path != page.archive_path: |
| + state.Close() |
| + state = _RunState() |
| + last_archive_path = page.archive_path |
| tries = 3 |
| while tries: |
| try: |
| if not state.browser: |
| self._SetupBrowser(state, test, possible_browser, |
| - credentials_path, archive_path) |
| + credentials_path, page.archive_path) |
| if not state.tab: |
| if len(state.browser.tabs) == 0: |
| state.browser.tabs.New() |