Commit 45b49113 authored by marja@chromium.org's avatar marja@chromium.org

Telemetry: Allow running only a subset of pages.

This is needed for the upcoming "the Web Page replay data for a page set can be
distributed across multiple .wpr files" feature.

R=nduca
NOTRY=true

BUG=155660

Review URL: https://chromiumcodereview.appspot.com/11829024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176146 0039d316-1c4b-4281-b951-d872f2087c98
parent 3e253bfa
......@@ -103,6 +103,8 @@ class BrowserOptions(optparse.Values):
help='Filename of an output of a previously run test on the current ' +
'pageset. The tests will run in the same order again, overriding ' +
'what is specified by --page-repeat and --pageset-repeat.')
group.add_option('--page-filter', dest='page_filter',
help='Run only pages whose URLs match the given filter regexp.')
parser.add_option_group(group)
# Debugging options
......
......@@ -3,6 +3,7 @@
# found in the LICENSE file.
import logging
import os
import re
import time
import traceback
import urlparse
......@@ -34,7 +35,7 @@ class _RunState(object):
self.browser.Close()
self.browser = None
def _ShufflePageSet(page_set, options):
def _ShuffleAndFilterPageSet(page_set, options):
if options.test_shuffle_order_file and not options.test_shuffle:
raise Exception('--test-shuffle-order-file requires --test-shuffle.')
......@@ -42,6 +43,13 @@ def _ShufflePageSet(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
......@@ -104,7 +112,7 @@ http://goto/read-src-internal, or create a new archive using record_wpr.
raise Exception('Trace directory isn\'t empty: %s' % options.trace_dir)
# Reorder page set based on options.
pages = _ShufflePageSet(self.page_set, options)
pages = _ShuffleAndFilterPageSet(self.page_set, options)
state = _RunState()
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment