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 DEPS = [ | 5 DEPS = [ |
6 'bot_update', | 6 'bot_update', |
7 'chromium', | 7 'chromium', |
8 'gclient', | 8 'gclient', |
9 'isolate', | 9 'isolate', |
10 'itertools', | 10 'itertools', |
11 'json', | 11 'json', |
12 'path', | 12 'path', |
13 'platform', | 13 'platform', |
14 'properties', | 14 'properties', |
15 'python', | 15 'python', |
16 'raw_io', | 16 'raw_io', |
17 'step', | 17 'step', |
18 'step_history', | 18 'step_history', |
| 19 'swarming', |
19 'test_utils', | 20 'test_utils', |
20 'tryserver', | 21 'tryserver', |
21 ] | 22 ] |
22 | 23 |
23 | 24 |
24 BUILDERS = { | 25 BUILDERS = { |
25 'tryserver.chromium': { | 26 'tryserver.chromium': { |
26 'builders': { | 27 'builders': { |
27 'linux_arm_cross_compile': { | 28 'linux_arm_cross_compile': { |
28 'GYP_DEFINES': { | 29 'GYP_DEFINES': { |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 'compile_only': False, | 356 'compile_only': False, |
356 'testing': { | 357 'testing': { |
357 'platform': 'win', | 358 'platform': 'win', |
358 }, | 359 }, |
359 }, | 360 }, |
360 }, | 361 }, |
361 }, | 362 }, |
362 } | 363 } |
363 | 364 |
364 | 365 |
| 366 def add_swarming_builder(original, swarming, server='tryserver.chromium'): |
| 367 """Duplicates builder config on |server|, adding 'enable_swarming: True'.""" |
| 368 assert server in BUILDERS |
| 369 assert original in BUILDERS[server]['builders'] |
| 370 assert swarming not in BUILDERS[server]['builders'] |
| 371 conf = BUILDERS[server]['builders'][original].copy() |
| 372 conf['enable_swarming'] = True |
| 373 BUILDERS[server]['builders'][swarming] = conf |
| 374 |
| 375 |
| 376 add_swarming_builder('linux_chromium_rel', 'linux_chromium_rel_swarming') |
| 377 add_swarming_builder('win_chromium_rel', 'win_chromium_rel_swarming') |
| 378 add_swarming_builder('mac_chromium_rel', 'mac_chromium_rel_swarming') |
| 379 |
| 380 |
365 def GenSteps(api): | 381 def GenSteps(api): |
366 class CheckdepsTest(api.test_utils.Test): # pylint: disable=W0232 | 382 class CheckdepsTest(api.test_utils.Test): # pylint: disable=W0232 |
367 name = 'checkdeps' | 383 name = 'checkdeps' |
368 | 384 |
369 @staticmethod | 385 @staticmethod |
370 def compile_targets(): | 386 def compile_targets(): |
371 return [] | 387 return [] |
372 | 388 |
373 @staticmethod | 389 @staticmethod |
374 def run(suffix): | 390 def run(suffix): |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 step_test_data=lambda: api.json.test_api.canned_gtest_output(True)) | 515 step_test_data=lambda: api.json.test_api.canned_gtest_output(True)) |
500 | 516 |
501 def has_valid_results(self, suffix): | 517 def has_valid_results(self, suffix): |
502 step_name = self._step_name(suffix) | 518 step_name = self._step_name(suffix) |
503 gtest_results = api.step_history[step_name].json.gtest_results | 519 gtest_results = api.step_history[step_name].json.gtest_results |
504 if not gtest_results.valid: # pragma: no cover | 520 if not gtest_results.valid: # pragma: no cover |
505 return False | 521 return False |
506 global_tags = gtest_results.raw.get('global_tags', []) | 522 global_tags = gtest_results.raw.get('global_tags', []) |
507 return 'UNRELIABLE_RESULTS' not in global_tags | 523 return 'UNRELIABLE_RESULTS' not in global_tags |
508 | 524 |
509 | |
510 def failures(self, suffix): | 525 def failures(self, suffix): |
511 step_name = self._step_name(suffix) | 526 step_name = self._step_name(suffix) |
512 return api.step_history[step_name].json.gtest_results.failures | 527 return api.step_history[step_name].json.gtest_results.failures |
513 | 528 |
514 | 529 |
| 530 class SwarmingGTestTest(api.test_utils.Test): |
| 531 def __init__(self, name, args=None): |
| 532 api.test_utils.Test.__init__(self) |
| 533 self._name = name |
| 534 self._args = args or [] |
| 535 self._tasks = {} |
| 536 self._results = {} |
| 537 |
| 538 @property |
| 539 def name(self): |
| 540 return self._name |
| 541 |
| 542 def compile_targets(self): |
| 543 # <X>_run target depends on <X>, and then isolates it invoking isolate.py. |
| 544 # It is a convention, not a hard coded rule. |
| 545 return [self._name + '_run'] |
| 546 |
| 547 def pre_run(self, suffix): |
| 548 """Launches the test on Swarming.""" |
| 549 assert suffix not in self._tasks, ( |
| 550 'Test %s was already triggered' % self._step_name(suffix)) |
| 551 |
| 552 # *.isolated may be missing if *_run target is misconfigured. It's a error |
| 553 # in gyp, not a recipe failure. So carry on with recipe execution. |
| 554 isolated_hash = api.isolate.isolated_tests.get(self._name) |
| 555 if not isolated_hash: |
| 556 return api.python.inline( |
| 557 '[error] %s' % self._step_name(suffix), |
| 558 r""" |
| 559 import sys |
| 560 print '*.isolated file for target %s is missing' % sys.argv[1] |
| 561 sys.exit(1) |
| 562 """, |
| 563 args=[self._name], |
| 564 always_run=True) |
| 565 |
| 566 # If rerunning without a patch, run only tests that failed. |
| 567 args = self._args[:] |
| 568 if suffix == 'without patch': |
| 569 failed_tests = sorted(self.failures('with patch')) |
| 570 args.append('--gtest_filter=%s' % ':'.join(failed_tests)) |
| 571 |
| 572 # Trigger the test on swarming. |
| 573 self._tasks[suffix] = api.swarming.gtest_task( |
| 574 title=self._step_name(suffix), |
| 575 isolated_hash=isolated_hash, |
| 576 test_launcher_summary_output=api.json.gtest_results( |
| 577 add_json_log=False), |
| 578 extra_args=args) |
| 579 return api.swarming.trigger([self._tasks[suffix]], always_run=True) |
| 580 |
| 581 def run(self, suffix): # pylint: disable=R0201 |
| 582 """Not used. All logic in pre_run, post_run.""" |
| 583 return [] |
| 584 |
| 585 def post_run(self, suffix): |
| 586 """Waits for launched test to finish and collect the results.""" |
| 587 assert suffix not in self._results, ( |
| 588 'Results of %s were already collected' % self._step_name(suffix)) |
| 589 |
| 590 # Emit error if test wasn't triggered. This happens if *.isolated is not |
| 591 # found. (The build is already red by this moment anyway). |
| 592 if suffix not in self._tasks: |
| 593 return api.python.inline( |
| 594 '[collect error] %s' % self._step_name(suffix), |
| 595 r""" |
| 596 import sys |
| 597 print '%s wasn\'t triggered' % sys.argv[1] |
| 598 sys.exit(1) |
| 599 """, |
| 600 args=[self._name], |
| 601 always_run=True) |
| 602 |
| 603 # Update step presentation, store step results in self._results. |
| 604 def followup_fn(step_result): |
| 605 r = step_result.json.gtest_results |
| 606 p = step_result.presentation |
| 607 if r.valid: |
| 608 p.step_text += api.test_utils.format_step_text([ |
| 609 ['failures:', r.failures] |
| 610 ]) |
| 611 self._results[suffix] = r |
| 612 |
| 613 # Wait for test on swarming to finish. If swarming infrastructure is |
| 614 # having issues, this step produces no valid *.json test summary, and |
| 615 # 'has_valid_results' returns False. |
| 616 return api.swarming.collect( |
| 617 [self._tasks[suffix]], |
| 618 always_run=True, |
| 619 can_fail_build=False, |
| 620 followup_fn=followup_fn) |
| 621 |
| 622 def has_valid_results(self, suffix): |
| 623 # Test wasn't triggered or wasn't collected. |
| 624 if suffix not in self._tasks or not suffix in self._results: |
| 625 return False |
| 626 # Test ran, but failed to produce valid *.json. |
| 627 gtest_results = self._results[suffix] |
| 628 if not gtest_results.valid: # pragma: no cover |
| 629 return False |
| 630 global_tags = gtest_results.raw.get('global_tags', []) |
| 631 return 'UNRELIABLE_RESULTS' not in global_tags |
| 632 |
| 633 def failures(self, suffix): |
| 634 assert self.has_valid_results(suffix) |
| 635 return self._results[suffix].failures |
| 636 |
| 637 |
515 class NaclIntegrationTest(api.test_utils.Test): # pylint: disable=W0232 | 638 class NaclIntegrationTest(api.test_utils.Test): # pylint: disable=W0232 |
516 name = 'nacl_integration' | 639 name = 'nacl_integration' |
517 | 640 |
518 @staticmethod | 641 @staticmethod |
519 def compile_targets(): | 642 def compile_targets(): |
520 return ['chrome'] | 643 return ['chrome'] |
521 | 644 |
522 def run(self, suffix): | 645 def run(self, suffix): |
523 args = [ | 646 args = [ |
524 '--mode', api.chromium.c.build_config_fs, | 647 '--mode', api.chromium.c.build_config_fs, |
525 '--json_build_results_output_file', api.json.output(), | 648 '--json_build_results_output_file', api.json.output(), |
526 ] | 649 ] |
527 return api.python( | 650 return api.python( |
528 self._step_name(suffix), | 651 self._step_name(suffix), |
529 api.path['checkout'].join('chrome', | 652 api.path['checkout'].join('chrome', |
530 'test', | 653 'test', |
531 'nacl_test_injection', | 654 'nacl_test_injection', |
532 'buildbot_nacl_integration.py'), | 655 'buildbot_nacl_integration.py'), |
533 args, | 656 args, |
534 can_fail_build=False, | 657 can_fail_build=False, |
535 step_test_data=lambda: api.m.json.test_api.output([])) | 658 step_test_data=lambda: api.m.json.test_api.output([])) |
536 | 659 |
537 def has_valid_results(self, suffix): | 660 def has_valid_results(self, suffix): |
538 return api.step_history[self._step_name(suffix)].json.output is not None | 661 return api.step_history[self._step_name(suffix)].json.output is not None |
539 | 662 |
540 def failures(self, suffix): | 663 def failures(self, suffix): |
541 failures = api.step_history[self._step_name(suffix)].json.output | 664 failures = api.step_history[self._step_name(suffix)].json.output |
542 return [f['raw_name'] for f in failures] | 665 return [f['raw_name'] for f in failures] |
543 | 666 |
| 667 |
| 668 def parse_test_spec(test_spec, enable_swarming, should_use_test): |
| 669 """Returns a list of tests to run and additional targets to compile. |
| 670 |
| 671 Uses 'should_use_test' callback to figure out what tests should be skipped. |
| 672 |
| 673 Returns triple (compile_targets, gtest_tests, swarming_tests) where |
| 674 gtest_tests is a list of GTestTest |
| 675 swarming_tests is a list of SwarmingGTestTest. |
| 676 """ |
| 677 compile_targets = [] |
| 678 gtest_tests_spec = [] |
| 679 if isinstance(test_spec, dict): |
| 680 compile_targets = test_spec.get('compile_targets', []) |
| 681 gtest_tests_spec = test_spec.get('gtest_tests', []) |
| 682 else: |
| 683 # TODO(nodir): Remove this after |
| 684 # https://codereview.chromium.org/297303012/#ps50001 |
| 685 # lands. |
| 686 gtest_tests_spec = test_spec |
| 687 |
| 688 gtest_tests = [] |
| 689 swarming_tests = [] |
| 690 for test in gtest_tests_spec: |
| 691 test_name = None |
| 692 test_dict = None |
| 693 |
| 694 # Read test_dict for the test, it defines where test can run. |
| 695 if isinstance(test, unicode): |
| 696 test_name = test.encode('utf-8') |
| 697 test_dict = {} |
| 698 elif isinstance(test, dict): |
| 699 if 'test' not in test: # pragma: no cover |
| 700 raise ValueError('Invalid entry in test spec: %r' % test) |
| 701 test_name = test['test'].encode('utf-8') |
| 702 test_dict = test |
| 703 else: # pragma: no cover |
| 704 raise ValueError('Unrecognized entry in test spec: %r' % test) |
| 705 |
| 706 # Should skip it completely? |
| 707 if not test_name or not should_use_test(test_dict): |
| 708 continue |
| 709 |
| 710 # If test can run on swarming, test_dict has a section that defines when |
| 711 # swarming should be used, in same format as main test dict. |
| 712 use_swarming = False |
| 713 if enable_swarming: |
| 714 swarming_spec = test_dict.get('swarming') or {} |
| 715 if not isinstance(swarming_spec, dict): # pragma: no cover |
| 716 raise ValueError('\'swarming\' entry in test spec should be a dict') |
| 717 if swarming_spec.get('can_use_on_swarming_builders'): |
| 718 use_swarming = should_use_test(swarming_spec) |
| 719 |
| 720 test_args = test_dict.get('args') |
| 721 if isinstance(test_args, basestring): |
| 722 test_args = [test_args] |
| 723 |
| 724 if use_swarming: |
| 725 swarming_tests.append(SwarmingGTestTest(test_name, test_args)) |
| 726 else: |
| 727 gtest_tests.append(GTestTest(test_name, test_args)) |
| 728 |
| 729 return compile_targets, gtest_tests, swarming_tests |
| 730 |
| 731 |
544 mastername = api.properties.get('mastername') | 732 mastername = api.properties.get('mastername') |
545 buildername = api.properties.get('buildername') | 733 buildername = api.properties.get('buildername') |
546 master_dict = BUILDERS.get(mastername, {}) | 734 master_dict = BUILDERS.get(mastername, {}) |
547 bot_config = master_dict.get('builders', {}).get(buildername) | 735 bot_config = master_dict.get('builders', {}).get(buildername) |
548 assert bot_config, ( | 736 assert bot_config, ( |
549 'Unrecognized builder name %r for master %r.' % ( | 737 'Unrecognized builder name %r for master %r.' % ( |
550 buildername, mastername)) | 738 buildername, mastername)) |
551 | 739 |
552 # Make sure tests and the recipe specify correct and matching platform. | 740 # Make sure tests and the recipe specify correct and matching platform. |
553 assert api.platform.name == bot_config.get('testing', {}).get('platform') | 741 assert api.platform.name == bot_config.get('testing', {}).get('platform') |
554 | 742 |
555 api.chromium.set_config(bot_config['chromium_config'], | 743 api.chromium.set_config(bot_config['chromium_config'], |
556 **bot_config.get('chromium_config_kwargs', {})) | 744 **bot_config.get('chromium_config_kwargs', {})) |
557 # Settings GYP_DEFINES explicitly because chromium config constructor does | 745 # Settings GYP_DEFINES explicitly because chromium config constructor does |
558 # not support that. | 746 # not support that. |
559 api.chromium.c.gyp_env.GYP_DEFINES.update(bot_config.get('GYP_DEFINES', {})) | 747 api.chromium.c.gyp_env.GYP_DEFINES.update(bot_config.get('GYP_DEFINES', {})) |
560 if bot_config.get('use_isolate'): | |
561 api.isolate.set_isolate_environment(api.chromium.c) | |
562 api.chromium.apply_config('trybot_flavor') | 748 api.chromium.apply_config('trybot_flavor') |
563 api.gclient.set_config('chromium') | 749 api.gclient.set_config('chromium') |
564 api.step.auto_resolve_conflicts = True | 750 api.step.auto_resolve_conflicts = True |
565 | 751 |
566 yield api.bot_update.ensure_checkout() | 752 yield api.bot_update.ensure_checkout() |
567 # The first time we run bot update, remember if bot_update mode is on or off. | 753 # The first time we run bot update, remember if bot_update mode is on or off. |
568 bot_update_mode = api.step_history.last_step().json.output['did_run'] | 754 bot_update_mode = api.step_history.last_step().json.output['did_run'] |
569 if not bot_update_mode: | 755 if not bot_update_mode: |
570 yield api.gclient.checkout( | 756 yield api.gclient.checkout( |
571 revert=True, can_fail_build=False, abort_on_failure=False) | 757 revert=True, can_fail_build=False, abort_on_failure=False) |
(...skipping 30 matching lines...) Expand all Loading... |
602 'args': ['--test-launcher-print-test-stdio=always'], | 788 'args': ['--test-launcher-print-test-stdio=always'], |
603 }, | 789 }, |
604 { | 790 { |
605 'test': 'browser_tests', | 791 'test': 'browser_tests', |
606 'exclude_builders': ['tryserver.chromium:win_chromium_x64_rel'], | 792 'exclude_builders': ['tryserver.chromium:win_chromium_x64_rel'], |
607 }, | 793 }, |
608 ]), | 794 ]), |
609 followup_fn=test_spec_followup_fn, | 795 followup_fn=test_spec_followup_fn, |
610 ) | 796 ) |
611 | 797 |
| 798 def should_use_test(test): |
| 799 """Given a test dict from test spec returns True or False.""" |
| 800 if 'platforms' in test: |
| 801 if api.platform.name not in test['platforms']: |
| 802 return False |
| 803 if 'chromium_configs' in test: |
| 804 if bot_config['chromium_config'] not in test['chromium_configs']: |
| 805 return False |
| 806 if 'exclude_builders' in test: |
| 807 if '%s:%s' % (mastername, buildername) in test['exclude_builders']: |
| 808 return False |
| 809 return True |
| 810 |
| 811 # Parse test spec file into list of Test instances. |
| 812 compile_targets, gtest_tests, swarming_tests = parse_test_spec( |
| 813 api.step_history['read test spec'].json.output, |
| 814 bot_config.get('enable_swarming'), |
| 815 should_use_test) |
| 816 |
| 817 # Swarming uses Isolate to transfer files to swarming bots. |
| 818 # set_isolate_environment modifies GYP_DEFINES to enable test isolation. |
| 819 use_isolate = swarming_tests or bot_config.get('use_isolate') |
| 820 if use_isolate: |
| 821 api.isolate.set_isolate_environment(api.chromium.c) |
| 822 |
612 runhooks_env = bot_config.get('runhooks_env', {}) | 823 runhooks_env = bot_config.get('runhooks_env', {}) |
613 | 824 |
614 yield api.chromium.runhooks(env=runhooks_env, abort_on_failure=False, | 825 yield api.chromium.runhooks(env=runhooks_env, abort_on_failure=False, |
615 can_fail_build=False) | 826 can_fail_build=False) |
616 if api.step_history.last_step().retcode != 0: | 827 if api.step_history.last_step().retcode != 0: |
617 # Before removing the checkout directory try just using LKCR. | 828 # Before removing the checkout directory try just using LKCR. |
618 api.gclient.set_config('chromium_lkcr') | 829 api.gclient.set_config('chromium_lkcr') |
619 | 830 |
620 # Since we're likely to switch to an earlier revision, revert the patch, | 831 # Since we're likely to switch to an earlier revision, revert the patch, |
621 # sync with the new config, and apply issue again. | 832 # sync with the new config, and apply issue again. |
(...skipping 10 matching lines...) Expand all Loading... |
632 if api.step_history.last_step().retcode != 0: | 843 if api.step_history.last_step().retcode != 0: |
633 if api.platform.is_win: | 844 if api.platform.is_win: |
634 yield api.chromium.taskkill() | 845 yield api.chromium.taskkill() |
635 yield ( | 846 yield ( |
636 api.path.rmcontents('slave build directory', api.path['slave_build']), | 847 api.path.rmcontents('slave build directory', api.path['slave_build']), |
637 api.gclient.checkout(revert=False), | 848 api.gclient.checkout(revert=False), |
638 api.tryserver.maybe_apply_issue(), | 849 api.tryserver.maybe_apply_issue(), |
639 api.chromium.runhooks(env=runhooks_env) | 850 api.chromium.runhooks(env=runhooks_env) |
640 ) | 851 ) |
641 | 852 |
642 gtest_tests = [] | 853 # If going to use swarming_client (pinned in src/DEPS), ensure it is |
643 compile_targets = [] | 854 # compatible with what recipes expect. |
644 test_spec = api.step_history['read test spec'].json.output | 855 if swarming_tests: |
645 | 856 yield api.swarming.check_client_version() |
646 if isinstance(test_spec, dict): | |
647 compile_targets = test_spec.get('compile_targets', []) | |
648 gtest_tests_spec = test_spec.get('gtest_tests', []) | |
649 else: | |
650 # TODO (nodir): Remove this after | |
651 # https://codereview.chromium.org/297303012/#ps50001 | |
652 # lands. | |
653 gtest_tests_spec = test_spec | |
654 | |
655 for test in gtest_tests_spec: | |
656 test_name = None | |
657 test_args = None | |
658 | |
659 if isinstance(test, unicode): | |
660 test_name = test.encode('utf-8') | |
661 elif isinstance(test, dict): | |
662 if 'platforms' in test: | |
663 if api.platform.name not in test['platforms']: | |
664 continue | |
665 | |
666 if 'chromium_configs' in test: | |
667 if bot_config['chromium_config'] not in test['chromium_configs']: | |
668 continue | |
669 | |
670 if 'exclude_builders' in test: | |
671 if '%s:%s' % (mastername, buildername) in test['exclude_builders']: | |
672 continue | |
673 | |
674 test_args = test.get('args') | |
675 if isinstance(test_args, basestring): | |
676 test_args = [test_args] | |
677 | |
678 if 'test' not in test: # pragma: no cover | |
679 raise ValueError('Invalid entry in test spec: %r' % test) | |
680 | |
681 test_name = test['test'].encode('utf-8') | |
682 else: # pragma: no cover | |
683 raise ValueError('Unrecognized entry in test spec: %r' % test) | |
684 | |
685 if test_name: | |
686 gtest_tests.append(GTestTest(test_name, test_args)) | |
687 | 857 |
688 tests = [] | 858 tests = [] |
689 tests.append(CheckdepsTest()) | 859 tests.append(CheckdepsTest()) |
690 if api.platform.is_linux: | 860 if api.platform.is_linux: |
691 tests.extend([ | 861 tests.extend([ |
692 CheckpermsTest(), | 862 CheckpermsTest(), |
693 ChecklicensesTest(), | 863 ChecklicensesTest(), |
694 ]) | 864 ]) |
695 tests.append(Deps2GitTest()) | 865 tests.append(Deps2GitTest()) |
696 for test in gtest_tests: | 866 tests.extend(gtest_tests) |
697 tests.append(test) | 867 tests.extend(swarming_tests) |
698 tests.append(NaclIntegrationTest()) | 868 tests.append(NaclIntegrationTest()) |
699 | 869 |
700 compile_targets.extend(bot_config.get('compile_targets', [])) | 870 compile_targets.extend(bot_config.get('compile_targets', [])) |
701 compile_targets.extend(api.itertools.chain( | 871 compile_targets.extend(api.itertools.chain( |
702 *[t.compile_targets() for t in tests])) | 872 *[t.compile_targets() for t in tests])) |
703 # TODO(phajdan.jr): Also compile 'all' on win, http://crbug.com/368831 . | 873 # TODO(phajdan.jr): Also compile 'all' on win, http://crbug.com/368831 . |
704 # Disabled for now because it takes too long and/or fails on Windows. | 874 # Disabled for now because it takes too long and/or fails on Windows. |
705 if not api.platform.is_win and not bot_config.get('exclude_compile_all'): | 875 if not api.platform.is_win and not bot_config.get('exclude_compile_all'): |
706 compile_targets = ['all'] + compile_targets | 876 compile_targets = ['all'] + compile_targets |
707 yield api.chromium.compile(compile_targets, | 877 yield api.chromium.compile(compile_targets, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 yield api.chromium.runhooks() | 911 yield api.chromium.runhooks() |
742 yield api.chromium.compile(compile_targets, | 912 yield api.chromium.compile(compile_targets, |
743 name='compile ' | 913 name='compile ' |
744 '(with patch, lkcr, clobber, nuke)', | 914 '(with patch, lkcr, clobber, nuke)', |
745 force_clobber=True) | 915 force_clobber=True) |
746 | 916 |
747 # Do not run tests if the build is already in a failed state. | 917 # Do not run tests if the build is already in a failed state. |
748 if api.step_history.failed: | 918 if api.step_history.failed: |
749 return | 919 return |
750 | 920 |
751 if bot_config.get('use_isolate'): | 921 # Collect *.isolated hashes for all isolated targets, used when triggering |
| 922 # tests on swarming. |
| 923 if use_isolate: |
752 yield api.isolate.find_isolated_tests(api.chromium.output_dir) | 924 yield api.isolate.find_isolated_tests(api.chromium.output_dir) |
753 | 925 |
754 if bot_config['compile_only']: | 926 if bot_config['compile_only']: |
755 return | 927 return |
756 | 928 |
757 if bot_config['chromium_config'] not in ['chromium_chromeos', | 929 if bot_config['chromium_config'] not in ['chromium_chromeos', |
758 'chromium_chromeos_clang']: | 930 'chromium_chromeos_clang']: |
759 # TODO(phajdan.jr): Make it possible to retry telemetry tests (add JSON). | 931 # TODO(phajdan.jr): Make it possible to retry telemetry tests (add JSON). |
| 932 # TODO(vadimsh): Trigger swarming tests before telemetry tests. |
760 yield ( | 933 yield ( |
761 api.chromium.run_telemetry_unittests(), | 934 api.chromium.run_telemetry_unittests(), |
762 api.chromium.run_telemetry_perf_unittests(), | 935 api.chromium.run_telemetry_perf_unittests(), |
763 ) | 936 ) |
764 | 937 |
765 def deapply_patch_fn(failing_tests): | 938 def deapply_patch_fn(failing_tests): |
766 if api.platform.is_win: | 939 if api.platform.is_win: |
767 yield api.chromium.taskkill() | 940 yield api.chromium.taskkill() |
768 if bot_update_mode: | 941 if bot_update_mode: |
769 bot_update_json = api.step_history['bot_update'].json.output | 942 bot_update_json = api.step_history['bot_update'].json.output |
(...skipping 14 matching lines...) Expand all Loading... |
784 yield api.chromium.compile(compile_targets, | 957 yield api.chromium.compile(compile_targets, |
785 name='compile (without patch)', | 958 name='compile (without patch)', |
786 abort_on_failure=False, | 959 abort_on_failure=False, |
787 can_fail_build=False, | 960 can_fail_build=False, |
788 always_run=True) | 961 always_run=True) |
789 if api.step_history['compile (without patch)'].retcode != 0: | 962 if api.step_history['compile (without patch)'].retcode != 0: |
790 yield api.chromium.compile(compile_targets, | 963 yield api.chromium.compile(compile_targets, |
791 name='compile (without patch, clobber)', | 964 name='compile (without patch, clobber)', |
792 force_clobber=True, | 965 force_clobber=True, |
793 always_run=True) | 966 always_run=True) |
| 967 if use_isolate: |
| 968 yield api.isolate.find_isolated_tests(api.chromium.output_dir, |
| 969 always_run=True) |
794 | 970 |
795 yield api.test_utils.determine_new_failures(tests, deapply_patch_fn) | 971 yield api.test_utils.determine_new_failures(tests, deapply_patch_fn) |
796 | 972 |
797 | 973 |
798 def _sanitize_nonalpha(text): | 974 def _sanitize_nonalpha(text): |
799 return ''.join(c if c.isalnum() else '_' for c in text) | 975 return ''.join(c if c.isalnum() else '_' for c in text) |
800 | 976 |
801 | 977 |
802 def GenTests(api): | 978 def GenTests(api): |
803 canned_checkdeps = { | 979 canned_checkdeps = { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 api.platform.name('linux') + | 1192 api.platform.name('linux') + |
1017 api.override_step_data( | 1193 api.override_step_data( |
1018 'checklicenses (with patch)', | 1194 'checklicenses (with patch)', |
1019 api.json.output([ | 1195 api.json.output([ |
1020 { | 1196 { |
1021 'filename': 'base/basictypes.h', | 1197 'filename': 'base/basictypes.h', |
1022 'license': 'UNKNOWN', | 1198 'license': 'UNKNOWN', |
1023 }, | 1199 }, |
1024 ])) | 1200 ])) |
1025 ) | 1201 ) |
| 1202 |
| 1203 # Successfully compiling, isolating and running two targets on swarming. |
| 1204 yield ( |
| 1205 api.test('swarming_basic') + |
| 1206 props(buildername='linux_chromium_rel_swarming') + |
| 1207 api.platform.name('linux') + |
| 1208 api.override_step_data('read test spec', api.json.output({ |
| 1209 'gtest_tests': [ |
| 1210 { |
| 1211 'test': 'base_unittests', |
| 1212 'swarming': {'can_use_on_swarming_builders': True}, |
| 1213 }, |
| 1214 { |
| 1215 'test': 'browser_tests', |
| 1216 'swarming': { |
| 1217 'can_use_on_swarming_builders': True, |
| 1218 'platforms': ['linux'], |
| 1219 }, |
| 1220 }, |
| 1221 ], |
| 1222 }) |
| 1223 ) + |
| 1224 api.override_step_data( |
| 1225 'find isolated tests', |
| 1226 api.isolate.output_json(['base_unittests', 'browser_tests'])) |
| 1227 ) |
| 1228 |
| 1229 # One target (browser_tests) failed to produce *.isolated file. |
| 1230 yield ( |
| 1231 api.test('swarming_missing_isolated') + |
| 1232 props(buildername='linux_chromium_rel_swarming') + |
| 1233 api.platform.name('linux') + |
| 1234 api.override_step_data('read test spec', api.json.output({ |
| 1235 'gtest_tests': [ |
| 1236 { |
| 1237 'test': 'base_unittests', |
| 1238 'swarming': {'can_use_on_swarming_builders': True}, |
| 1239 }, |
| 1240 { |
| 1241 'test': 'browser_tests', |
| 1242 'swarming': {'can_use_on_swarming_builders': True}, |
| 1243 }, |
| 1244 ], |
| 1245 }) |
| 1246 ) + |
| 1247 api.override_step_data( |
| 1248 'find isolated tests', |
| 1249 api.isolate.output_json(['base_unittests'])) |
| 1250 ) |
| 1251 |
| 1252 # One test (base_unittest) failed on swarming. It is retried with |
| 1253 # deapplied patch. |
| 1254 yield ( |
| 1255 api.test('swarming_deapply_patch') + |
| 1256 props(buildername='linux_chromium_rel_swarming') + |
| 1257 api.platform.name('linux') + |
| 1258 api.override_step_data('read test spec', api.json.output({ |
| 1259 'gtest_tests': [ |
| 1260 { |
| 1261 'test': 'base_unittests', |
| 1262 'swarming': {'can_use_on_swarming_builders': True}, |
| 1263 }, |
| 1264 { |
| 1265 'test': 'browser_tests', |
| 1266 'swarming': {'can_use_on_swarming_builders': True}, |
| 1267 }, |
| 1268 ], |
| 1269 }) |
| 1270 ) + |
| 1271 api.override_step_data( |
| 1272 'find isolated tests', |
| 1273 api.isolate.output_json(['base_unittests', 'browser_tests'])) + |
| 1274 api.override_step_data('[swarming] base_unittests (with patch)', |
| 1275 canned_test(passing=False)) + |
| 1276 api.override_step_data( |
| 1277 'find isolated tests (2)', |
| 1278 api.isolate.output_json(['base_unittests'])) |
| 1279 ) |
OLD | NEW |