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

Unified Diff: scripts/slave/recipes/chromium_trybot.py

Issue 427073003: Adds ability to filter the set of tests that are run by a bot (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: merge to trunk Created 6 years, 4 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
Index: scripts/slave/recipes/chromium_trybot.py
diff --git a/scripts/slave/recipes/chromium_trybot.py b/scripts/slave/recipes/chromium_trybot.py
index 0f7c560f1f924a3e96605808a98b628780a9690a..229264fba114dcab376d21657dd2ee01ae39e0ae 100644
--- a/scripts/slave/recipes/chromium_trybot.py
+++ b/scripts/slave/recipes/chromium_trybot.py
@@ -407,6 +407,7 @@ def add_swarming_builder(original, swarming, server):
conf['enable_swarming'] = True
BUILDERS[server]['builders'][swarming] = conf
+
def should_filter_builder(name, regexs):
"""Returns true if the builder |name| should be filtered. |regexs| is a list
of the regular expressions specifying the builders that should *not* be
@@ -418,6 +419,23 @@ def should_filter_builder(name, regexs):
return False
return True
+
+def get_test_names(gtest_tests, swarming_tests):
+ """Returns the names of each of the tests in |gtest_tests| and
+ |swarming_tests|. These are lists of GTestTest and SwarmingGTestTest."""
+ return [test.name for test in gtest_tests + swarming_tests]
+
+
+def filter_tests(possible_tests, needed_tests):
+ """Returns a list of all the tests in |possible_tests| whose name is in
+ |needed_tests|."""
+ result = []
+ for test in possible_tests:
+ if test.name in needed_tests:
+ result.append(test)
+ return result
+
+
add_swarming_builder('linux_chromium_rel', 'linux_chromium_rel_swarming',
'tryserver.chromium.linux')
add_swarming_builder('linux_chromium_chromeos_rel',
@@ -546,17 +564,6 @@ def GenSteps(api):
step_result.presentation.step_text = 'path: %s' % test_spec_path
test_spec = step_result.json.output
- runhooks_env = bot_config.get('runhooks_env', {})
-
- # See if the patch needs to compile on the current platform.
- if isinstance(test_spec, dict) and should_filter_builder(
- buildername, test_spec.get('non_filter_builders', [])):
- api.filter.does_patch_require_compile(
- exclusions=test_spec.get('gtest_tests_filter_exclusions', []),
- env=runhooks_env)
- if not api.filter.result:
- return
-
def should_use_test(test):
"""Given a test dict from test spec returns True or False."""
if 'platforms' in test:
@@ -576,6 +583,22 @@ def GenSteps(api):
bot_config.get('enable_swarming'),
should_use_test)
+ runhooks_env = bot_config.get('runhooks_env', {})
+
+ # See if the patch needs to compile on the current platform.
+ if isinstance(test_spec, dict) and should_filter_builder(
+ buildername, test_spec.get('non_filter_builders', [])):
+ api.filter.does_patch_require_compile(
+ exclusions=test_spec.get('gtest_tests_filter_exclusions', []),
+ exes=get_test_names(gtest_tests, swarming_tests),
+ env=runhooks_env)
+ if not api.filter.result:
+ return
+ # Patch needs compile. Filter the list of test targets.
+ if buildername in test_spec.get('filter_tests_builders', []):
+ gtest_tests = filter_tests(gtest_tests, api.filter.matching_exes)
+ swarming_tests = filter_tests(swarming_tests, api.filter.matching_exes)
+
# Swarming uses Isolate to transfer files to swarming bots.
# set_isolate_environment modifies GYP_DEFINES to enable test isolation.
if bot_config.get('use_isolate') or swarming_tests:
@@ -952,5 +975,61 @@ def GenTests(api):
) +
api.override_step_data(
'analyze',
- api.raw_io.stream_output('Found dependency'))
+ api.json.output({'status': 'Found dependency', 'targets': []}))
+ )
+
+ # Tests analyze module by way of not specifying non_filter_builders and
+ # analyze result returning true along with a smaller set of tests.
+ yield (
+ api.test('compile_because_of_analyze_with_filtered_tests_no_builder') +
+ props(buildername='linux_chromium_rel') +
+ api.platform.name('linux') +
+ api.override_step_data('read test spec', api.json.output({
+ 'gtest_tests': [
+ {
+ 'test': 'base_unittests',
+ 'swarming': {'can_use_on_swarming_builders': True},
+ },
+ {
+ 'test': 'browser_tests',
+ },
+ {
+ 'test': 'unittests',
+ },
+ ],
+ })
+ ) +
+ api.override_step_data(
+ 'analyze',
+ api.json.output({'status': 'Found dependency',
+ 'targets': ['browser_tests', 'base_unittests']}))
+ )
+
+ # Tests analyze module by way of not specifying non_filter_builders and
+ # analyze result returning true along with a smaller set of tests. This
+ # specifices a 'filter_test_builder', so that this bot uses the filtered set.
+ yield (
+ api.test('compile_because_of_analyze_with_filtered_tests') +
+ props(buildername='linux_chromium_rel') +
+ api.platform.name('linux') +
+ api.override_step_data('read test spec', api.json.output({
+ 'filter_tests_builders': 'linux_chromium_rel',
+ 'gtest_tests': [
+ {
+ 'test': 'base_unittests',
+ 'swarming': {'can_use_on_swarming_builders': True},
+ },
+ {
+ 'test': 'browser_tests',
+ },
+ {
+ 'test': 'unittests',
+ },
+ ],
+ })
+ ) +
+ api.override_step_data(
+ 'analyze',
+ api.json.output({'status': 'Found dependency',
+ 'targets': ['browser_tests', 'base_unittests']}))
)

Powered by Google App Engine
This is Rietveld 408576698