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

Unified Diff: telemetry/telemetry/testing/browser_test_runner.py

Issue 2122443002: Add a flag for filtering tests after sharding. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: Added unittest. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/testing/browser_test_runner_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/testing/browser_test_runner.py
diff --git a/telemetry/telemetry/testing/browser_test_runner.py b/telemetry/telemetry/testing/browser_test_runner.py
index bfab66a8a584d613bba3da2c1e16e77a9239fa7f..9868e8f41de3985df32a74f979a6f21279c2cd64 100644
--- a/telemetry/telemetry/testing/browser_test_runner.py
+++ b/telemetry/telemetry/testing/browser_test_runner.py
@@ -148,10 +148,18 @@ def _SplitShardsByTime(test_cases, total_shards, test_times,
_TEST_GENERATOR_PREFIX = 'GenerateTestCases_'
def _LoadTests(test_class, finder_options, filter_regex_str,
+ filter_tests_after_sharding,
total_shards, shard_index, test_times,
debug_shard_distributions):
test_cases = []
- filter_regex = re.compile(filter_regex_str)
+ real_regex = re.compile(filter_regex_str)
+ noop_regex = re.compile('')
+ if filter_tests_after_sharding:
+ filter_regex = noop_regex
+ post_filter_regex = real_regex
+ else:
+ filter_regex = real_regex
+ post_filter_regex = noop_regex
for name, method in inspect.getmembers(
test_class, predicate=inspect.ismethod):
if name.startswith('test'):
@@ -179,7 +187,8 @@ def _LoadTests(test_class, finder_options, filter_regex_str,
# Assign tests to shards.
shards = _SplitShardsByTime(test_cases, total_shards, test_times,
debug_shard_distributions)
- return shards[shard_index]
+ return [t for t in shards[shard_index]
+ if post_filter_regex.search(t.shortName())]
else:
test_cases.sort(key=lambda t: t.shortName())
test_range = _TestRangeForShard(total_shards, shard_index, len(test_cases))
@@ -191,7 +200,8 @@ def _LoadTests(test_class, finder_options, filter_regex_str,
# Can edit the code to get 'test_times' passed in here for
# debugging and comparison purposes.
_DebugShardDistributions(tmp_shards, None)
- return test_cases[test_range[0]:test_range[1]]
+ return [t for t in test_cases[test_range[0]:test_range[1]]
+ if post_filter_regex.search(t.shortName())]
class TestRunOptions(object):
@@ -234,6 +244,10 @@ def Run(project_config, test_run_options, args):
parser.add_argument('--shard-index', default=0, type=int,
help='Shard index (0..total_shards-1) of this test run.')
parser.add_argument(
+ '--filter-tests-after-sharding', default=False, action='store_true',
+ help=('Apply the test filter after tests are split for sharding. Useful '
+ 'for reproducing bugs related to the order in which tests run.'))
+ parser.add_argument(
'--read-abbreviated-json-results-from', metavar='FILENAME',
action='store', help=(
'If specified, reads abbreviated results from that path in json form. '
@@ -277,6 +291,7 @@ def Run(project_config, test_run_options, args):
suite = unittest.TestSuite()
for test in _LoadTests(test_class, options, option.test_filter,
+ option.filter_tests_after_sharding,
option.total_shards, option.shard_index,
test_times, option.debug_shard_distributions):
suite.addTest(test)
« no previous file with comments | « no previous file | telemetry/telemetry/testing/browser_test_runner_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698