| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import string | 6 import string |
| 7 | 7 |
| 8 | 8 |
| 9 class Test(object): | 9 class Test(object): |
| 10 """ | 10 """ |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 isolate_file_path = (api.path['checkout'].join(self._android_isolate_path) | 870 isolate_file_path = (api.path['checkout'].join(self._android_isolate_path) |
| 871 if self._android_isolate_path else None) | 871 if self._android_isolate_path else None) |
| 872 return AndroidInstrumentationTest( | 872 return AndroidInstrumentationTest( |
| 873 name=self.name, | 873 name=self.name, |
| 874 compile_target=self._compile_target, | 874 compile_target=self._compile_target, |
| 875 apk_under_test=self._apk_under_test, | 875 apk_under_test=self._apk_under_test, |
| 876 test_apk=self.name, | 876 test_apk=self.name, |
| 877 isolate_file_path=isolate_file_path).run(api, suffix) | 877 isolate_file_path=isolate_file_path).run(api, suffix) |
| 878 | 878 |
| 879 | 879 |
| 880 class IsolatedScriptTest(Test): | 880 class LocalIsolatedScriptTest(Test): |
| 881 def __init__(self, name, args=None, target_name=None, **runtest_kwargs): | 881 def __init__(self, name, args=None, target_name=None, **runtest_kwargs): |
| 882 """Constructs an instance of IsolatedScriptTest. | 882 """Constructs an instance of LocalIsolatedScriptTest. |
| 883 | 883 |
| 884 An IsolatedScriptTest knows how to invoke an isolate which obeys a certain | 884 An LocalIsolatedScriptTest knows how to invoke an isolate which obeys a cert
ain |
| 885 contract. The isolate's main target must be a wrapper script which must | 885 contract. The isolate's main target must be a wrapper script which must |
| 886 interpret certain command line arguments as follows: | 886 interpret certain command line arguments as follows: |
| 887 | 887 |
| 888 --isolated-script-test-output [FILENAME] | 888 --isolated-script-test-output [FILENAME] |
| 889 | 889 |
| 890 The wrapper script must write the simplified json output that the recipes | 890 The wrapper script must write the simplified json output that the recipes |
| 891 consume (similar to GTestTest and ScriptTest) into |FILENAME|. | 891 consume (similar to GTestTest and ScriptTest) into |FILENAME|. |
| 892 | 892 |
| 893 The contract may be expanded later to support functionality like sharding | 893 The contract may be expanded later to support functionality like sharding |
| 894 and retries of specific failed tests. Currently the examples of such wrapper | 894 and retries of specific failed tests. Currently the examples of such wrapper |
| 895 scripts live in src/testing/scripts/ in the Chromium workspace. | 895 scripts live in src/testing/scripts/ in the Chromium workspace. |
| 896 | 896 |
| 897 Args: | 897 Args: |
| 898 name: Displayed name of the test. May be modified by suffixes. | 898 name: Displayed name of the test. May be modified by suffixes. |
| 899 args: Arguments to be passed to the test. | 899 args: Arguments to be passed to the test. |
| 900 target_name: Actual name of the test. Defaults to name. | 900 target_name: Actual name of the test. Defaults to name. |
| 901 runtest_kwargs: Additional keyword args forwarded to the runtest. | 901 runtest_kwargs: Additional keyword args forwarded to the runtest. |
| 902 """ | 902 """ |
| 903 super(IsolatedScriptTest, self).__init__() | 903 super(LocalIsolatedScriptTest, self).__init__() |
| 904 self._name = name | 904 self._name = name |
| 905 self._args = args or [] | 905 self._args = args or [] |
| 906 self._target_name = target_name | 906 self._target_name = target_name |
| 907 self._runtest_kwargs = runtest_kwargs | 907 self._runtest_kwargs = runtest_kwargs |
| 908 | 908 |
| 909 @property | 909 @property |
| 910 def name(self): | 910 def name(self): |
| 911 return self._name | 911 return self._name |
| 912 | 912 |
| 913 @property | 913 @property |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 self.failures(api, suffix) | 964 self.failures(api, suffix) |
| 965 | 965 |
| 966 return self._test_runs[suffix].json.output['valid'] | 966 return self._test_runs[suffix].json.output['valid'] |
| 967 except Exception: # pragma: no cover | 967 except Exception: # pragma: no cover |
| 968 return False | 968 return False |
| 969 | 969 |
| 970 def failures(self, api, suffix): | 970 def failures(self, api, suffix): |
| 971 return self._test_runs[suffix].json.output['failures'] | 971 return self._test_runs[suffix].json.output['failures'] |
| 972 | 972 |
| 973 | 973 |
| 974 class SwarmingIsolatedScriptTest(SwarmingTest): |
| 975 def __init__(self, name, args=None, target_name=None, shards=1, |
| 976 dimensions=None, tags=None, extra_suffix=None, |
| 977 upload_test_results=True): |
| 978 super(SwarmingIsolatedScriptTest, self).__init__( |
| 979 name, dimensions, tags, target_name, extra_suffix) |
| 980 self._args = args or [] |
| 981 self._shards = shards |
| 982 self._upload_test_results = upload_test_results |
| 983 |
| 984 @property |
| 985 def target_name(self): |
| 986 return self._target_name or self._name |
| 987 |
| 988 def compile_targets(self, _): |
| 989 return [self.target_name] |
| 990 |
| 991 @property |
| 992 def uses_swarming(self): |
| 993 return True |
| 994 |
| 995 def create_task(self, api, suffix, isolated_hash): |
| 996 # For local tests args are added inside api.chromium.run_telemetry_test. |
| 997 browser_config = api.chromium.c.build_config_fs.lower() |
| 998 args = self._args[:] |
| 999 |
| 1000 # TODO(nednguyen): only rerun the tests that failed for the "without patch" |
| 1001 # suffix. |
| 1002 |
| 1003 # For the time being, we assume all isolated_script_test are not idempotent |
| 1004 # TODO(nednguyen): make this configurable in isolated_scripts's spec. |
| 1005 return api.swarming.isolated_script_task( |
| 1006 title=self._step_name(suffix), isolated_hash=isolated_hash, |
| 1007 idempotent=False, extra_args=args) |
| 1008 |
| 1009 def validate_task_results(self, api, step_result): |
| 1010 results = getattr(step_result, 'isolated_script_results', None) or {} |
| 1011 |
| 1012 try: |
| 1013 failures = results['failures'] |
| 1014 valid = results['valid'] |
| 1015 if not failures and step_result.retcode != 0: |
| 1016 failures = ['%s (entire test suite)' % self.name] |
| 1017 valid = False |
| 1018 except (ValueError, KeyError) as e: |
| 1019 step_result.presentation.logs['invalid_results_exc'] = [str(e)] |
| 1020 valid = False |
| 1021 failures = None |
| 1022 if valid: |
| 1023 step_result.presentation.step_text += api.test_utils.format_step_text([ |
| 1024 ['failures:', failures] |
| 1025 ]) |
| 1026 return valid, failures |
| 1027 |
| 974 def generate_isolated_script(api, mastername, buildername, test_spec, | 1028 def generate_isolated_script(api, mastername, buildername, test_spec, |
| 975 enable_swarming=False, | 1029 enable_swarming=False, |
| 976 scripts_compile_targets=None): | 1030 scripts_compile_targets=None): |
| 977 for spec in test_spec.get(buildername, {}).get( | 1031 for spec in test_spec.get(buildername, {}).get('isolated_scripts', []): |
| 978 'isolated_scripts', []): | 1032 use_swarming = False |
| 979 yield IsolatedScriptTest( | 1033 swarming_shards = 1 |
| 980 str(spec['name']), | 1034 if enable_swarming: |
| 981 args=spec.get('args', []), | 1035 swarming_spec = spec.get('swarming', {}) |
| 982 target_name=spec['isolate_name']) | 1036 if swarming_spec.get('can_use_on_swarming_builders', False): |
| 1037 use_swarming = True |
| 1038 swarming_shards = swarming_spec.get('shards', 1) |
| 1039 name = str(spec['name']) |
| 1040 args = args=spec.get('args', []) |
| 1041 target_name = spec['isolate_name'] |
| 1042 if use_swarming: |
| 1043 yield SwarmingIsolatedScriptTest( |
| 1044 name=name, args=args, target_name=target_name, shards=swarming_shards) |
| 1045 else: |
| 1046 yield LocalIsolatedScriptTest( |
| 1047 name=name, args=args, target_name=target_name) |
| 983 | 1048 |
| 984 | 1049 |
| 985 class GTestTest(Test): | 1050 class GTestTest(Test): |
| 986 def __init__(self, name, args=None, target_name=None, enable_swarming=False, | 1051 def __init__(self, name, args=None, target_name=None, enable_swarming=False, |
| 987 swarming_shards=1, swarming_dimensions=None, swarming_tags=None, | 1052 swarming_shards=1, swarming_dimensions=None, swarming_tags=None, |
| 988 swarming_extra_suffix=None, **runtest_kwargs): | 1053 swarming_extra_suffix=None, **runtest_kwargs): |
| 989 super(GTestTest, self).__init__() | 1054 super(GTestTest, self).__init__() |
| 990 if enable_swarming: | 1055 if enable_swarming: |
| 991 self._test = SwarmingGTestTest( | 1056 self._test = SwarmingGTestTest( |
| 992 name, args, target_name, swarming_shards, swarming_dimensions, | 1057 name, args, target_name, swarming_shards, swarming_dimensions, |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1700 def run(self, api, suffix): | 1765 def run(self, api, suffix): |
| 1701 api.chromium_android.coverage_report(upload=False) | 1766 api.chromium_android.coverage_report(upload=False) |
| 1702 api.chromium_android.get_changed_lines_for_revision() | 1767 api.chromium_android.get_changed_lines_for_revision() |
| 1703 api.chromium_android.incremental_coverage_report() | 1768 api.chromium_android.incremental_coverage_report() |
| 1704 | 1769 |
| 1705 | 1770 |
| 1706 GOMA_TESTS = [ | 1771 GOMA_TESTS = [ |
| 1707 GTestTest('base_unittests'), | 1772 GTestTest('base_unittests'), |
| 1708 GTestTest('content_unittests'), | 1773 GTestTest('content_unittests'), |
| 1709 ] | 1774 ] |
| OLD | NEW |