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

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: fix Created 6 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
Index: scripts/slave/recipes/chromium_trybot.py
diff --git a/scripts/slave/recipes/chromium_trybot.py b/scripts/slave/recipes/chromium_trybot.py
index d6d59d52821e9446f8d5ffc6e5b209f2c21fc1ce..c40ffa0959f5dcc8ed9e74a0ac87a501933e67d5 100644
--- a/scripts/slave/recipes/chromium_trybot.py
+++ b/scripts/slave/recipes/chromium_trybot.py
@@ -424,6 +424,20 @@ 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):
iannucci 2014/07/30 01:20:37 nit: 2 spaces between module-level definitions
sky 2014/07/30 21:14:16 I assume you mean 2 newlines.
+ """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',
@@ -552,14 +566,6 @@ def GenSteps(api):
step_result.presentation.step_text = 'path: %s' % test_spec_path
test_spec = step_result.json.output
- # 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', []))
- 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:
@@ -579,6 +585,19 @@ def GenSteps(api):
bot_config.get('enable_swarming'),
should_use_test)
+ # 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))
+ 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:
@@ -926,7 +945,11 @@ def GenTests(api):
api.platform.name('linux') +
api.override_step_data('read test spec', api.json.output({
})
- )
+ ) +
+ api.override_step_data(
+ 'analyze',
+ stdout=api.json.output({'status': 'No dependency',
+ 'targets': []}))
)
# Tests analyze module by way of not specifying non_filter_builders and file
@@ -952,5 +975,62 @@ def GenTests(api):
) +
api.override_step_data(
'analyze',
- api.raw_io.stream_output('Found dependency'))
+ stdout=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',
+ stdout=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',
+ stdout=api.json.output({'status': 'Found dependency',
+ 'targets': ['browser_tests', 'base_unittests']}))
)

Powered by Google App Engine
This is Rietveld 408576698