OLD | NEW |
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 400 |
401 def add_swarming_builder(original, swarming, server): | 401 def add_swarming_builder(original, swarming, server): |
402 """Duplicates builder config on |server|, adding 'enable_swarming: True'.""" | 402 """Duplicates builder config on |server|, adding 'enable_swarming: True'.""" |
403 assert server in BUILDERS | 403 assert server in BUILDERS |
404 assert original in BUILDERS[server]['builders'] | 404 assert original in BUILDERS[server]['builders'] |
405 assert swarming not in BUILDERS[server]['builders'] | 405 assert swarming not in BUILDERS[server]['builders'] |
406 conf = BUILDERS[server]['builders'][original].copy() | 406 conf = BUILDERS[server]['builders'][original].copy() |
407 conf['enable_swarming'] = True | 407 conf['enable_swarming'] = True |
408 BUILDERS[server]['builders'][swarming] = conf | 408 BUILDERS[server]['builders'][swarming] = conf |
409 | 409 |
| 410 |
410 def should_filter_builder(name, regexs): | 411 def should_filter_builder(name, regexs): |
411 """Returns true if the builder |name| should be filtered. |regexs| is a list | 412 """Returns true if the builder |name| should be filtered. |regexs| is a list |
412 of the regular expressions specifying the builders that should *not* be | 413 of the regular expressions specifying the builders that should *not* be |
413 filtered. If |name| completely matches one of the regular expressions than | 414 filtered. If |name| completely matches one of the regular expressions than |
414 false is returned, otherwise true.""" | 415 false is returned, otherwise true.""" |
415 for regex in regexs: | 416 for regex in regexs: |
416 match = re.match(regex, name) | 417 match = re.match(regex, name) |
417 if match and match.end() == len(name): | 418 if match and match.end() == len(name): |
418 return False | 419 return False |
419 return True | 420 return True |
420 | 421 |
| 422 |
| 423 def get_test_names(gtest_tests, swarming_tests): |
| 424 """Returns the names of each of the tests in |gtest_tests| and |
| 425 |swarming_tests|. These are lists of GTestTest and SwarmingGTestTest.""" |
| 426 return [test.name for test in gtest_tests + swarming_tests] |
| 427 |
| 428 |
| 429 def filter_tests(possible_tests, needed_tests): |
| 430 """Returns a list of all the tests in |possible_tests| whose name is in |
| 431 |needed_tests|.""" |
| 432 result = [] |
| 433 for test in possible_tests: |
| 434 if test.name in needed_tests: |
| 435 result.append(test) |
| 436 return result |
| 437 |
| 438 |
421 add_swarming_builder('linux_chromium_rel', 'linux_chromium_rel_swarming', | 439 add_swarming_builder('linux_chromium_rel', 'linux_chromium_rel_swarming', |
422 'tryserver.chromium.linux') | 440 'tryserver.chromium.linux') |
423 add_swarming_builder('linux_chromium_chromeos_rel', | 441 add_swarming_builder('linux_chromium_chromeos_rel', |
424 'linux_chromium_chromeos_rel_swarming', | 442 'linux_chromium_chromeos_rel_swarming', |
425 'tryserver.chromium.linux') | 443 'tryserver.chromium.linux') |
426 add_swarming_builder('win_chromium_rel', 'win_chromium_rel_swarming', | 444 add_swarming_builder('win_chromium_rel', 'win_chromium_rel_swarming', |
427 'tryserver.chromium.win') | 445 'tryserver.chromium.win') |
428 add_swarming_builder('mac_chromium_rel', 'mac_chromium_rel_swarming', | 446 add_swarming_builder('mac_chromium_rel', 'mac_chromium_rel_swarming', |
429 'tryserver.chromium.mac') | 447 'tryserver.chromium.mac') |
430 | 448 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 }, | 557 }, |
540 { | 558 { |
541 'test': 'browser_tests', | 559 'test': 'browser_tests', |
542 'exclude_builders': ['tryserver.chromium.win:win_chromium_x64_rel'], | 560 'exclude_builders': ['tryserver.chromium.win:win_chromium_x64_rel'], |
543 }, | 561 }, |
544 ]), | 562 ]), |
545 ) | 563 ) |
546 step_result.presentation.step_text = 'path: %s' % test_spec_path | 564 step_result.presentation.step_text = 'path: %s' % test_spec_path |
547 test_spec = step_result.json.output | 565 test_spec = step_result.json.output |
548 | 566 |
549 runhooks_env = bot_config.get('runhooks_env', {}) | |
550 | |
551 # See if the patch needs to compile on the current platform. | |
552 if isinstance(test_spec, dict) and should_filter_builder( | |
553 buildername, test_spec.get('non_filter_builders', [])): | |
554 api.filter.does_patch_require_compile( | |
555 exclusions=test_spec.get('gtest_tests_filter_exclusions', []), | |
556 env=runhooks_env) | |
557 if not api.filter.result: | |
558 return | |
559 | |
560 def should_use_test(test): | 567 def should_use_test(test): |
561 """Given a test dict from test spec returns True or False.""" | 568 """Given a test dict from test spec returns True or False.""" |
562 if 'platforms' in test: | 569 if 'platforms' in test: |
563 if api.platform.name not in test['platforms']: | 570 if api.platform.name not in test['platforms']: |
564 return False | 571 return False |
565 if 'chromium_configs' in test: | 572 if 'chromium_configs' in test: |
566 if bot_config['chromium_config'] not in test['chromium_configs']: | 573 if bot_config['chromium_config'] not in test['chromium_configs']: |
567 return False | 574 return False |
568 if 'exclude_builders' in test: | 575 if 'exclude_builders' in test: |
569 if '%s:%s' % (mastername, buildername) in test['exclude_builders']: | 576 if '%s:%s' % (mastername, buildername) in test['exclude_builders']: |
570 return False | 577 return False |
571 return True | 578 return True |
572 | 579 |
573 # Parse test spec file into list of Test instances. | 580 # Parse test spec file into list of Test instances. |
574 compile_targets, gtest_tests, swarming_tests = parse_test_spec( | 581 compile_targets, gtest_tests, swarming_tests = parse_test_spec( |
575 test_spec, | 582 test_spec, |
576 bot_config.get('enable_swarming'), | 583 bot_config.get('enable_swarming'), |
577 should_use_test) | 584 should_use_test) |
578 | 585 |
| 586 runhooks_env = bot_config.get('runhooks_env', {}) |
| 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 env=runhooks_env) |
| 595 if not api.filter.result: |
| 596 return |
| 597 # Patch needs compile. Filter the list of test targets. |
| 598 if buildername in test_spec.get('filter_tests_builders', []): |
| 599 gtest_tests = filter_tests(gtest_tests, api.filter.matching_exes) |
| 600 swarming_tests = filter_tests(swarming_tests, api.filter.matching_exes) |
| 601 |
579 # Swarming uses Isolate to transfer files to swarming bots. | 602 # Swarming uses Isolate to transfer files to swarming bots. |
580 # set_isolate_environment modifies GYP_DEFINES to enable test isolation. | 603 # set_isolate_environment modifies GYP_DEFINES to enable test isolation. |
581 if bot_config.get('use_isolate') or swarming_tests: | 604 if bot_config.get('use_isolate') or swarming_tests: |
582 api.isolate.set_isolate_environment(api.chromium.c) | 605 api.isolate.set_isolate_environment(api.chromium.c) |
583 | 606 |
584 # If going to use swarming_client (pinned in src/DEPS), ensure it is | 607 # If going to use swarming_client (pinned in src/DEPS), ensure it is |
585 # compatible with what recipes expect. | 608 # compatible with what recipes expect. |
586 if swarming_tests: | 609 if swarming_tests: |
587 api.swarming.check_client_version() | 610 api.swarming.check_client_version() |
588 | 611 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ) |
OLD | NEW |