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

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: fg 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 406
407 def add_swarming_builder(original, swarming, server): 407 def add_swarming_builder(original, swarming, server):
408 """Duplicates builder config on |server|, adding 'enable_swarming: True'.""" 408 """Duplicates builder config on |server|, adding 'enable_swarming: True'."""
409 assert server in BUILDERS 409 assert server in BUILDERS
410 assert original in BUILDERS[server]['builders'] 410 assert original in BUILDERS[server]['builders']
411 assert swarming not in BUILDERS[server]['builders'] 411 assert swarming not in BUILDERS[server]['builders']
412 conf = BUILDERS[server]['builders'][original].copy() 412 conf = BUILDERS[server]['builders'][original].copy()
413 conf['enable_swarming'] = True 413 conf['enable_swarming'] = True
414 BUILDERS[server]['builders'][swarming] = conf 414 BUILDERS[server]['builders'][swarming] = conf
415 415
416
416 def should_filter_builder(name, regexs): 417 def should_filter_builder(name, regexs):
417 """Returns true if the builder |name| should be filtered. |regexs| is a list 418 """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 419 of the regular expressions specifying the builders that should *not* be
419 filtered. If |name| completely matches one of the regular expressions than 420 filtered. If |name| completely matches one of the regular expressions than
420 false is returned, otherwise true.""" 421 false is returned, otherwise true."""
421 for regex in regexs: 422 for regex in regexs:
422 match = re.match(regex, name) 423 match = re.match(regex, name)
423 if match and match.end() == len(name): 424 if match and match.end() == len(name):
424 return False 425 return False
425 return True 426 return True
426 427
428
429 def get_test_names(gtest_tests, swarming_tests):
430 """Returns the names of each of the tests in |gtest_tests| and
431 |swarming_tests|. These are lists of GTestTest and SwarmingGTestTest."""
432 return [test.name for test in gtest_tests + swarming_tests]
433
434
435 def filter_tests(possible_tests, needed_tests):
436 """Returns a list of all the tests in |possible_tests| whose name is in
437 |needed_tests|."""
438 result = []
439 for test in possible_tests:
440 if test.name in needed_tests:
441 result.append(test)
442 return result
443
444
427 add_swarming_builder('linux_chromium_rel', 'linux_chromium_rel_swarming', 445 add_swarming_builder('linux_chromium_rel', 'linux_chromium_rel_swarming',
428 'tryserver.chromium.linux') 446 'tryserver.chromium.linux')
429 add_swarming_builder('linux_chromium_chromeos_rel', 447 add_swarming_builder('linux_chromium_chromeos_rel',
430 'linux_chromium_chromeos_rel_swarming', 448 'linux_chromium_chromeos_rel_swarming',
431 'tryserver.chromium.linux') 449 'tryserver.chromium.linux')
432 add_swarming_builder('win_chromium_rel', 'win_chromium_rel_swarming', 450 add_swarming_builder('win_chromium_rel', 'win_chromium_rel_swarming',
433 'tryserver.chromium.win') 451 'tryserver.chromium.win')
434 add_swarming_builder('mac_chromium_rel', 'mac_chromium_rel_swarming', 452 add_swarming_builder('mac_chromium_rel', 'mac_chromium_rel_swarming',
435 'tryserver.chromium.mac') 453 'tryserver.chromium.mac')
436 454
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 }, 563 },
546 { 564 {
547 'test': 'browser_tests', 565 'test': 'browser_tests',
548 'exclude_builders': ['tryserver.chromium.win:win_chromium_x64_rel'], 566 'exclude_builders': ['tryserver.chromium.win:win_chromium_x64_rel'],
549 }, 567 },
550 ]), 568 ]),
551 ) 569 )
552 step_result.presentation.step_text = 'path: %s' % test_spec_path 570 step_result.presentation.step_text = 'path: %s' % test_spec_path
553 test_spec = step_result.json.output 571 test_spec = step_result.json.output
554 572
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): 573 def should_use_test(test):
564 """Given a test dict from test spec returns True or False.""" 574 """Given a test dict from test spec returns True or False."""
565 if 'platforms' in test: 575 if 'platforms' in test:
566 if api.platform.name not in test['platforms']: 576 if api.platform.name not in test['platforms']:
567 return False 577 return False
568 if 'chromium_configs' in test: 578 if 'chromium_configs' in test:
569 if bot_config['chromium_config'] not in test['chromium_configs']: 579 if bot_config['chromium_config'] not in test['chromium_configs']:
570 return False 580 return False
571 if 'exclude_builders' in test: 581 if 'exclude_builders' in test:
572 if '%s:%s' % (mastername, buildername) in test['exclude_builders']: 582 if '%s:%s' % (mastername, buildername) in test['exclude_builders']:
573 return False 583 return False
574 return True 584 return True
575 585
576 # Parse test spec file into list of Test instances. 586 # Parse test spec file into list of Test instances.
577 compile_targets, gtest_tests, swarming_tests = parse_test_spec( 587 compile_targets, gtest_tests, swarming_tests = parse_test_spec(
578 test_spec, 588 test_spec,
579 bot_config.get('enable_swarming'), 589 bot_config.get('enable_swarming'),
580 should_use_test) 590 should_use_test)
581 591
592 # See if the patch needs to compile on the current platform.
593 if isinstance(test_spec, dict) and should_filter_builder(
594 buildername, test_spec.get('non_filter_builders', [])):
595 api.filter.does_patch_require_compile(
596 exclusions=test_spec.get('gtest_tests_filter_exclusions', []),
597 exes=get_test_names(gtest_tests, swarming_tests))
598 if not api.filter.result:
599 return
600 # Patch needs compile. Filter the list of test targets.
601 if buildername in test_spec.get('filter_tests_builders', []):
602 gtest_tests = filter_tests(gtest_tests, api.filter.matching_exes)
603 swarming_tests = filter_tests(swarming_tests, api.filter.matching_exes)
604
582 # Swarming uses Isolate to transfer files to swarming bots. 605 # Swarming uses Isolate to transfer files to swarming bots.
583 # set_isolate_environment modifies GYP_DEFINES to enable test isolation. 606 # set_isolate_environment modifies GYP_DEFINES to enable test isolation.
584 if bot_config.get('use_isolate') or swarming_tests: 607 if bot_config.get('use_isolate') or swarming_tests:
585 api.isolate.set_isolate_environment(api.chromium.c) 608 api.isolate.set_isolate_environment(api.chromium.c)
586 609
587 # If going to use swarming_client (pinned in src/DEPS), ensure it is 610 # If going to use swarming_client (pinned in src/DEPS), ensure it is
588 # compatible with what recipes expect. 611 # compatible with what recipes expect.
589 if swarming_tests: 612 if swarming_tests:
590 api.swarming.check_client_version() 613 api.swarming.check_client_version()
591 614
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 api.json.output({'status': 'Found dependency', 'targets': []}))
956 ) 979 )
980
981 # Tests analyze module by way of not specifying non_filter_builders and
982 # analyze result returning true along with a smaller set of tests.
983 yield (
984 api.test('compile_because_of_analyze_with_filtered_tests_no_builder') +
985 props(buildername='linux_chromium_rel') +
986 api.platform.name('linux') +
987 api.override_step_data('read test spec', api.json.output({
988 'gtest_tests': [
989 {
990 'test': 'base_unittests',
991 'swarming': {'can_use_on_swarming_builders': True},
992 },
993 {
994 'test': 'browser_tests',
995 },
996 {
997 'test': 'unittests',
998 },
999 ],
1000 })
1001 ) +
1002 api.override_step_data(
1003 'analyze',
1004 api.json.output({'status': 'Found dependency',
1005 'targets': ['browser_tests', 'base_unittests']}))
1006 )
1007
1008 # Tests analyze module by way of not specifying non_filter_builders and
1009 # analyze result returning true along with a smaller set of tests. This
1010 # specifices a 'filter_test_builder', so that this bot uses the filtered set.
1011 yield (
1012 api.test('compile_because_of_analyze_with_filtered_tests') +
1013 props(buildername='linux_chromium_rel') +
1014 api.platform.name('linux') +
1015 api.override_step_data('read test spec', api.json.output({
1016 'filter_tests_builders': 'linux_chromium_rel',
1017 'gtest_tests': [
1018 {
1019 'test': 'base_unittests',
1020 'swarming': {'can_use_on_swarming_builders': True},
1021 },
1022 {
1023 'test': 'browser_tests',
1024 },
1025 {
1026 'test': 'unittests',
1027 },
1028 ],
1029 })
1030 ) +
1031 api.override_step_data(
1032 'analyze',
1033 api.json.output({'status': 'Found dependency',
1034 'targets': ['browser_tests', 'base_unittests']}))
1035 )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698