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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import re 5 import re
6 6
7 DEPS = [ 7 DEPS = [
8 'bot_update', 8 'bot_update',
9 'chromium', 9 'chromium',
10 'filter', 10 'filter',
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 """Returns true if the builder |name| should be filtered. |regexs| is a list 417 """Returns true if the builder |name| should be filtered. |regexs| is a list
418 of the regular expressions specifying the builders that should *not* be 418 of the regular expressions specifying the builders that should *not* be
419 filtered. If |name| completely matches one of the regular expressions than 419 filtered. If |name| completely matches one of the regular expressions than
420 false is returned, otherwise true.""" 420 false is returned, otherwise true."""
421 for regex in regexs: 421 for regex in regexs:
422 match = re.match(regex, name) 422 match = re.match(regex, name)
423 if match and match.end() == len(name): 423 if match and match.end() == len(name):
424 return False 424 return False
425 return True 425 return True
426 426
427 def get_test_names(gtest_tests, swarming_tests):
428 """Returns the names of each of the tests in |gtest_tests| and
429 |swarming_tests|. These are lists of GTestTest and SwarmingGTestTest."""
430 return [test.name for test in gtest_tests + swarming_tests]
431
432 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.
433 """Returns a list of all the tests in |possible_tests| whose name is in
434 |needed_tests|."""
435 result = []
436 for test in possible_tests:
437 if test.name in needed_tests:
438 result.append(test)
439 return result
440
427 add_swarming_builder('linux_chromium_rel', 'linux_chromium_rel_swarming', 441 add_swarming_builder('linux_chromium_rel', 'linux_chromium_rel_swarming',
428 'tryserver.chromium.linux') 442 'tryserver.chromium.linux')
429 add_swarming_builder('linux_chromium_chromeos_rel', 443 add_swarming_builder('linux_chromium_chromeos_rel',
430 'linux_chromium_chromeos_rel_swarming', 444 'linux_chromium_chromeos_rel_swarming',
431 'tryserver.chromium.linux') 445 'tryserver.chromium.linux')
432 add_swarming_builder('win_chromium_rel', 'win_chromium_rel_swarming', 446 add_swarming_builder('win_chromium_rel', 'win_chromium_rel_swarming',
433 'tryserver.chromium.win') 447 'tryserver.chromium.win')
434 add_swarming_builder('mac_chromium_rel', 'mac_chromium_rel_swarming', 448 add_swarming_builder('mac_chromium_rel', 'mac_chromium_rel_swarming',
435 'tryserver.chromium.mac') 449 'tryserver.chromium.mac')
436 450
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 }, 559 },
546 { 560 {
547 'test': 'browser_tests', 561 'test': 'browser_tests',
548 'exclude_builders': ['tryserver.chromium.win:win_chromium_x64_rel'], 562 'exclude_builders': ['tryserver.chromium.win:win_chromium_x64_rel'],
549 }, 563 },
550 ]), 564 ]),
551 ) 565 )
552 step_result.presentation.step_text = 'path: %s' % test_spec_path 566 step_result.presentation.step_text = 'path: %s' % test_spec_path
553 test_spec = step_result.json.output 567 test_spec = step_result.json.output
554 568
555 # See if the patch needs to compile on the current platform.
556 if isinstance(test_spec, dict) and should_filter_builder(
557 buildername, test_spec.get('non_filter_builders', [])):
558 api.filter.does_patch_require_compile(
559 exclusions=test_spec.get('gtest_tests_filter_exclusions', []))
560 if not api.filter.result:
561 return
562
563 def should_use_test(test): 569 def should_use_test(test):
564 """Given a test dict from test spec returns True or False.""" 570 """Given a test dict from test spec returns True or False."""
565 if 'platforms' in test: 571 if 'platforms' in test:
566 if api.platform.name not in test['platforms']: 572 if api.platform.name not in test['platforms']:
567 return False 573 return False
568 if 'chromium_configs' in test: 574 if 'chromium_configs' in test:
569 if bot_config['chromium_config'] not in test['chromium_configs']: 575 if bot_config['chromium_config'] not in test['chromium_configs']:
570 return False 576 return False
571 if 'exclude_builders' in test: 577 if 'exclude_builders' in test:
572 if '%s:%s' % (mastername, buildername) in test['exclude_builders']: 578 if '%s:%s' % (mastername, buildername) in test['exclude_builders']:
573 return False 579 return False
574 return True 580 return True
575 581
576 # Parse test spec file into list of Test instances. 582 # Parse test spec file into list of Test instances.
577 compile_targets, gtest_tests, swarming_tests = parse_test_spec( 583 compile_targets, gtest_tests, swarming_tests = parse_test_spec(
578 test_spec, 584 test_spec,
579 bot_config.get('enable_swarming'), 585 bot_config.get('enable_swarming'),
580 should_use_test) 586 should_use_test)
581 587
588 # See if the patch needs to compile on the current platform.
589 if isinstance(test_spec, dict) and should_filter_builder(
590 buildername, test_spec.get('non_filter_builders', [])):
591 api.filter.does_patch_require_compile(
592 exclusions=test_spec.get('gtest_tests_filter_exclusions', []),
593 exes=get_test_names(gtest_tests, swarming_tests))
594 if not api.filter.result:
595 return
596 # Patch needs compile. Filter the list of test targets.
597 if buildername in test_spec.get('filter_tests_builders', []):
598 gtest_tests = filter_tests(gtest_tests, api.filter.matching_exes)
599 swarming_tests = filter_tests(swarming_tests, api.filter.matching_exes)
600
582 # Swarming uses Isolate to transfer files to swarming bots. 601 # Swarming uses Isolate to transfer files to swarming bots.
583 # set_isolate_environment modifies GYP_DEFINES to enable test isolation. 602 # set_isolate_environment modifies GYP_DEFINES to enable test isolation.
584 if bot_config.get('use_isolate') or swarming_tests: 603 if bot_config.get('use_isolate') or swarming_tests:
585 api.isolate.set_isolate_environment(api.chromium.c) 604 api.isolate.set_isolate_environment(api.chromium.c)
586 605
587 # If going to use swarming_client (pinned in src/DEPS), ensure it is 606 # If going to use swarming_client (pinned in src/DEPS), ensure it is
588 # compatible with what recipes expect. 607 # compatible with what recipes expect.
589 if swarming_tests: 608 if swarming_tests:
590 api.swarming.check_client_version() 609 api.swarming.check_client_version()
591 610
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 api.isolate.output_json(['base_unittests'])) 938 api.isolate.output_json(['base_unittests']))
920 ) 939 )
921 940
922 # Tests analyze module by not specifying a non_filter_builders. 941 # Tests analyze module by not specifying a non_filter_builders.
923 yield ( 942 yield (
924 api.test('no_compile_because_of_analyze') + 943 api.test('no_compile_because_of_analyze') +
925 props(buildername='linux_chromium_rel') + 944 props(buildername='linux_chromium_rel') +
926 api.platform.name('linux') + 945 api.platform.name('linux') +
927 api.override_step_data('read test spec', api.json.output({ 946 api.override_step_data('read test spec', api.json.output({
928 }) 947 })
929 ) 948 ) +
949 api.override_step_data(
950 'analyze',
951 stdout=api.json.output({'status': 'No dependency',
952 'targets': []}))
930 ) 953 )
931 954
932 # Tests analyze module by way of not specifying non_filter_builders and file 955 # Tests analyze module by way of not specifying non_filter_builders and file
933 # matching exclusion list. This should result in a compile. 956 # matching exclusion list. This should result in a compile.
934 yield ( 957 yield (
935 api.test('compile_because_of_analyze_matching_exclusion') + 958 api.test('compile_because_of_analyze_matching_exclusion') +
936 props(buildername='linux_chromium_rel') + 959 props(buildername='linux_chromium_rel') +
937 api.platform.name('linux') + 960 api.platform.name('linux') +
938 api.override_step_data('read test spec', api.json.output({ 961 api.override_step_data('read test spec', api.json.output({
939 'gtest_tests_filter_exclusions': ['f.*'], 962 'gtest_tests_filter_exclusions': ['f.*'],
940 }) 963 })
941 ) 964 )
942 ) 965 )
943 966
944 # Tests analyze module by way of not specifying non_filter_builders and 967 # Tests analyze module by way of not specifying non_filter_builders and
945 # analyze result returning true. This should result in a compile. 968 # analyze result returning true. This should result in a compile.
946 yield ( 969 yield (
947 api.test('compile_because_of_analyze') + 970 api.test('compile_because_of_analyze') +
948 props(buildername='linux_chromium_rel') + 971 props(buildername='linux_chromium_rel') +
949 api.platform.name('linux') + 972 api.platform.name('linux') +
950 api.override_step_data('read test spec', api.json.output({ 973 api.override_step_data('read test spec', api.json.output({
951 }) 974 })
952 ) + 975 ) +
953 api.override_step_data( 976 api.override_step_data(
954 'analyze', 977 'analyze',
955 api.raw_io.stream_output('Found dependency')) 978 stdout=api.json.output({'status': 'Found dependency',
979 'targets': []}))
956 ) 980 )
981
982 # Tests analyze module by way of not specifying non_filter_builders and
983 # analyze result returning true along with a smaller set of tests.
984 yield (
985 api.test('compile_because_of_analyze_with_filtered_tests_no_builder') +
986 props(buildername='linux_chromium_rel') +
987 api.platform.name('linux') +
988 api.override_step_data('read test spec', api.json.output({
989 'gtest_tests': [
990 {
991 'test': 'base_unittests',
992 'swarming': {'can_use_on_swarming_builders': True},
993 },
994 {
995 'test': 'browser_tests',
996 },
997 {
998 'test': 'unittests',
999 },
1000 ],
1001 })
1002 ) +
1003 api.override_step_data(
1004 'analyze',
1005 stdout=api.json.output({'status': 'Found dependency',
1006 'targets': ['browser_tests', 'base_unittests']}))
1007 )
1008
1009 # Tests analyze module by way of not specifying non_filter_builders and
1010 # analyze result returning true along with a smaller set of tests. This
1011 # specifices a 'filter_test_builder', so that this bot uses the filtered set.
1012 yield (
1013 api.test('compile_because_of_analyze_with_filtered_tests') +
1014 props(buildername='linux_chromium_rel') +
1015 api.platform.name('linux') +
1016 api.override_step_data('read test spec', api.json.output({
1017 'filter_tests_builders': 'linux_chromium_rel',
1018 'gtest_tests': [
1019 {
1020 'test': 'base_unittests',
1021 'swarming': {'can_use_on_swarming_builders': True},
1022 },
1023 {
1024 'test': 'browser_tests',
1025 },
1026 {
1027 'test': 'unittests',
1028 },
1029 ],
1030 })
1031 ) +
1032 api.override_step_data(
1033 'analyze',
1034 stdout=api.json.output({'status': 'Found dependency',
1035 'targets': ['browser_tests', 'base_unittests']}))
1036 )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698