| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from recipe_engine.types import freeze | 6 from recipe_engine.types import freeze |
| 7 | 7 |
| 8 | 8 |
| 9 class V8TestingVariants(object): | 9 class V8TestingVariants(object): |
| 10 """Immutable class to manage the testing variant passed to v8. | 10 """Immutable class to manage the testing variant passed to v8. |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 491 |
| 492 # Arguments for actual 'collect' command. | 492 # Arguments for actual 'collect' command. |
| 493 args.append('--') | 493 args.append('--') |
| 494 args.extend(self.api.swarming.get_collect_cmd_args(task)) | 494 args.extend(self.api.swarming.get_collect_cmd_args(task)) |
| 495 | 495 |
| 496 return self.api.python( | 496 return self.api.python( |
| 497 name=self.test['name'] + self.test_step_config.suffix, | 497 name=self.test['name'] + self.test_step_config.suffix, |
| 498 script=self.v8.resource('collect_v8_task.py'), | 498 script=self.v8.resource('collect_v8_task.py'), |
| 499 args=args, | 499 args=args, |
| 500 allow_subannotations=True, | 500 allow_subannotations=True, |
| 501 infra_step=True, |
| 501 step_test_data=kwargs.pop('step_test_data', None), | 502 step_test_data=kwargs.pop('step_test_data', None), |
| 502 **kwargs) | 503 **kwargs) |
| 503 | 504 |
| 504 def pre_run(self, test=None, coverage_context=NULL_COVERAGE, **kwargs): | 505 def pre_run(self, test=None, coverage_context=NULL_COVERAGE, **kwargs): |
| 505 # Set up arguments for test runner. | 506 # Set up arguments for test runner. |
| 506 self.test = test or TEST_CONFIGS[self.name] | 507 self.test = test or TEST_CONFIGS[self.name] |
| 507 extra_args, _ = self.v8._setup_test_runner( | 508 extra_args, _ = self.v8._setup_test_runner( |
| 508 self.test, self.applied_test_filter, self.test_step_config) | 509 self.test, self.applied_test_filter, self.test_step_config) |
| 509 | 510 |
| 510 # Let json results be stored in swarming's output folder. The collect | 511 # Let json results be stored in swarming's output folder. The collect |
| (...skipping 30 matching lines...) Expand all Loading... |
| 541 if 'os' not in self.task.dimensions: | 542 if 'os' not in self.task.dimensions: |
| 542 self.task.dimensions['os'] = self.api.swarming.prefered_os_dimension( | 543 self.task.dimensions['os'] = self.api.swarming.prefered_os_dimension( |
| 543 self.api.platform.name) | 544 self.api.platform.name) |
| 544 | 545 |
| 545 self.api.swarming.trigger_task(self.task) | 546 self.api.swarming.trigger_task(self.task) |
| 546 | 547 |
| 547 def run(self, coverage_context=NULL_COVERAGE, **kwargs): | 548 def run(self, coverage_context=NULL_COVERAGE, **kwargs): |
| 548 # TODO(machenbach): Soften this when softening 'assert isolated_hash' | 549 # TODO(machenbach): Soften this when softening 'assert isolated_hash' |
| 549 # above. | 550 # above. |
| 550 assert self.task | 551 assert self.task |
| 552 result = TestResults.empty() |
| 551 try: | 553 try: |
| 552 # Collect swarming results. Use the same test simulation data for the | 554 # Collect swarming results. Use the same test simulation data for the |
| 553 # swarming collect step like for local testing. | 555 # swarming collect step like for local testing. |
| 554 result = self.api.swarming.collect_task( | 556 self.api.swarming.collect_task( |
| 555 self.task, | 557 self.task, |
| 556 step_test_data=lambda: self.v8.test_api.output_json(), | 558 step_test_data=lambda: self.v8.test_api.output_json(), |
| 557 ) | 559 ) |
| 558 finally: | 560 except self.api.step.InfraFailure as e: |
| 559 # Note: Exceptions from post_run might hide a pending exception from the | 561 result += TestResults.infra_failure(e) |
| 560 # try block. | 562 |
| 561 return self.post_run(self.test, coverage_context) | 563 return result + self.post_run(self.test, coverage_context) |
| 562 | 564 |
| 563 def rerun(self, failure_dict, **kwargs): | 565 def rerun(self, failure_dict, **kwargs): |
| 564 self.pre_run(test=self._setup_rerun_config(failure_dict), **kwargs) | 566 self.pre_run(test=self._setup_rerun_config(failure_dict), **kwargs) |
| 565 return self.run(**kwargs) | 567 return self.run(**kwargs) |
| 566 | 568 |
| 567 | 569 |
| 568 class V8Presubmit(BaseTest): | 570 class V8Presubmit(BaseTest): |
| 569 def run(self, **kwargs): | 571 def run(self, **kwargs): |
| 570 self.api.python( | 572 self.api.python( |
| 571 'Presubmit', | 573 'Presubmit', |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 class TestResults(object): | 759 class TestResults(object): |
| 758 def __init__(self, failures, flakes, infra_failures): | 760 def __init__(self, failures, flakes, infra_failures): |
| 759 self.failures = failures | 761 self.failures = failures |
| 760 self.flakes = flakes | 762 self.flakes = flakes |
| 761 self.infra_failures = infra_failures | 763 self.infra_failures = infra_failures |
| 762 | 764 |
| 763 @staticmethod | 765 @staticmethod |
| 764 def empty(): | 766 def empty(): |
| 765 return TestResults([], [], []) | 767 return TestResults([], [], []) |
| 766 | 768 |
| 769 @staticmethod |
| 770 def infra_failure(exception): |
| 771 return TestResults([], [], [exception]) |
| 772 |
| 767 @property | 773 @property |
| 768 def is_negative(self): | 774 def is_negative(self): |
| 769 return bool(self.failures or self.flakes or self.infra_failures) | 775 return bool(self.failures or self.flakes or self.infra_failures) |
| 770 | 776 |
| 771 @property | 777 @property |
| 772 def has_failures(self): | 778 def has_failures(self): |
| 773 return bool(self.failures or self.infra_failures) | 779 return bool(self.failures or self.infra_failures) |
| 774 | 780 |
| 775 def __add__(self, other): | 781 def __add__(self, other): |
| 776 return TestResults( | 782 return TestResults( |
| 777 self.failures + other.failures, | 783 self.failures + other.failures, |
| 778 self.flakes + other.flakes, | 784 self.flakes + other.flakes, |
| 779 self.infra_failures + other.infra_failures, | 785 self.infra_failures + other.infra_failures, |
| 780 ) | 786 ) |
| 781 | 787 |
| 782 | 788 |
| 783 def create_test(test_step_config, api, v8_api): | 789 def create_test(test_step_config, api, v8_api): |
| 784 test_cls = V8_NON_STANDARD_TESTS.get(test_step_config.name) | 790 test_cls = V8_NON_STANDARD_TESTS.get(test_step_config.name) |
| 785 if not test_cls: | 791 if not test_cls: |
| 786 # TODO(machenbach): Implement swarming for non-standard tests. | 792 # TODO(machenbach): Implement swarming for non-standard tests. |
| 787 if v8_api.bot_config.get('enable_swarming') and test_step_config.swarming: | 793 if v8_api.bot_config.get('enable_swarming') and test_step_config.swarming: |
| 788 tools_mapping = TOOL_TO_TEST_SWARMING | 794 tools_mapping = TOOL_TO_TEST_SWARMING |
| 789 else: | 795 else: |
| 790 tools_mapping = TOOL_TO_TEST | 796 tools_mapping = TOOL_TO_TEST |
| 791 | 797 |
| 792 # The tool the test is going to use. Default: V8 test runner (run-tests). | 798 # The tool the test is going to use. Default: V8 test runner (run-tests). |
| 793 tool = TEST_CONFIGS[test_step_config.name].get('tool', 'run-tests') | 799 tool = TEST_CONFIGS[test_step_config.name].get('tool', 'run-tests') |
| 794 test_cls = tools_mapping[tool] | 800 test_cls = tools_mapping[tool] |
| 795 return test_cls(test_step_config, api, v8_api) | 801 return test_cls(test_step_config, api, v8_api) |
| OLD | NEW |