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

Side by Side Diff: scripts/slave/recipe_modules/chromium_tests/steps.py

Issue 2142923002: Remove amp recipe module and related code (unused) (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 5 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 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 @property 276 @property
277 def uses_local_devices(self): 277 def uses_local_devices(self):
278 return True # pragma: no cover 278 return True # pragma: no cover
279 279
280 def isolate_target(self, _api): # pragma: no cover 280 def isolate_target(self, _api): # pragma: no cover
281 if self._override_isolate_target: 281 if self._override_isolate_target:
282 return self._override_isolate_target 282 return self._override_isolate_target
283 return self.target_name 283 return self.target_name
284 284
285 def compile_targets(self, api): 285 def compile_targets(self, api):
286 if self._override_compile_targets: 286 # TODO(phajdan.jr): clean up override_compile_targets (remove or cover).
287 if self._override_compile_targets: # pragma: no cover
287 return self._override_compile_targets 288 return self._override_compile_targets
288 289
289 if api.chromium.c.TARGET_PLATFORM == 'android': 290 if api.chromium.c.TARGET_PLATFORM == 'android':
290 # TODO(agrieve): Remove _apk suffix in favour of bin/run_${target} once 291 # TODO(agrieve): Remove _apk suffix in favour of bin/run_${target} once
291 # GYP is gone. http://crbug.com/599919 292 # GYP is gone. http://crbug.com/599919
292 return [self.target_name + '_apk'] 293 return [self.target_name + '_apk']
293 294
294 return [self.target_name] 295 return [self.target_name]
295 296
296 def run(self, api, suffix, test_filter=None): 297 def run(self, api, suffix, test_filter=None):
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 'got_revision_cp', 'x@{#0}') 911 'got_revision_cp', 'x@{#0}')
911 chrome_revision = str(api.commit_position.parse_revision( 912 chrome_revision = str(api.commit_position.parse_revision(
912 chrome_revision_cp)) 913 chrome_revision_cp))
913 api.test_results.upload( 914 api.test_results.upload(
914 api.json.input(parsed_gtest_data), 915 api.json.input(parsed_gtest_data),
915 chrome_revision=chrome_revision, 916 chrome_revision=chrome_revision,
916 test_type=step_result.step['name'], 917 test_type=step_result.step['name'],
917 test_results_server='test-results.appspot.com') 918 test_results_server='test-results.appspot.com')
918 919
919 920
920 # TODO(bpastene) Remove all AMP recipe code once all use of it has been
921 # discontinued. crbug.com/603943
922 class AMPTest(Test):
923 AMP_INSTANCE_ADDRESS = '172.22.21.180'
924 AMP_INSTANCE_PORT = '80'
925 AMP_INSTANCE_PROTOCOL = 'http'
926 AMP_RESULTS_BUCKET = 'chrome-amp-results'
927 def __init__(self, name, device_name=None, device_os=None, device_oem=None,
928 test_run_timeout=None):
929 self._name = name
930 self._device_name = device_name
931 self._device_os = device_os
932 self._device_oem = device_oem
933 self._test_run_id = None
934 self._test_run_timeout = test_run_timeout
935 self._trigger_successful = None
936 self._step_results = {}
937
938 @property
939 def name(self):
940 return self._name
941
942 def amp_arguments(self, api):
943 return api.amp.amp_arguments(
944 api_address=AMPTest.AMP_INSTANCE_ADDRESS,
945 api_port=AMPTest.AMP_INSTANCE_PORT,
946 api_protocol=AMPTest.AMP_INSTANCE_PROTOCOL,
947 device_name=self._device_name,
948 device_oem=self._device_oem,
949 device_os=self._device_os,
950 test_run_timeout=self._test_run_timeout)
951
952 def pre_run(self, api, suffix, test_filter=None):
953 """Triggers an AMP test."""
954 isolate_file_path = (api.path['checkout'].join(self._android_isolate_path)
955 if self._android_isolate_path else None)
956 try:
957 self.trigger_test(api, suffix)
958 self._trigger_successful = True
959 except api.step.StepFailure:
960 self._trigger_successful = False
961
962 def trigger_test(self, api, suffix):
963 self.test_run_id = api.amp.trigger_test_suite(
964 step_name=self._step_name(suffix),
965 suite=self.name,
966 test_type=self.test_type(),
967 test_type_args=self.test_type_args(api),
968 amp_args=self.amp_arguments(api))
969
970 def test_type(self):
971 raise NotImplementedError() # pragma: no cover
972
973 def test_type_args(self, api):
974 raise NotImplementedError() # pragma: no cover
975
976 def run(self, api, suffix, test_filter=None):
977 self._step_results[suffix] = {'valid': False, 'failures': []}
978
979 def post_run(self, api, suffix, test_filter=None):
980 if self._trigger_successful:
981 self.collect_test(api, suffix)
982
983 def collect_test(self, api, suffix):
984 gtest_results_file = api.test_utils.gtest_results(add_json_log=False)
985 step_test_data = lambda: api.test_utils.test_api.canned_gtest_output(True)
986
987 try:
988 api.amp.collect_test_suite(
989 step_name=self._step_name(suffix),
990 test_run_id=self.test_run_id,
991 suite=self.name, test_type=self.test_type(),
992 test_type_args=self.test_type_args(api),
993 amp_args=self.amp_arguments(api),
994 json_results_file=gtest_results_file,
995 step_test_data=step_test_data)
996 finally:
997 step_result = api.step.active_result
998 valid, failures = self.validate_task_results(api, step_result)
999 self._step_results[suffix] = {'valid': valid, 'failures': failures}
1000
1001 def validate_task_results(self, api, step_result):
1002 try:
1003 gtest_results = step_result.test_utils.gtest_results
1004 valid = gtest_results.valid
1005 failures = gtest_results.failures
1006 except (AttributeError, KeyError, ValueError): # pragma: no cover
1007 valid = False
1008 failures = None
1009
1010 if valid:
1011 step_result.presentation.step_text += api.test_utils.format_step_text([
1012 ['failures:', failures]
1013 ])
1014
1015 return valid, failures
1016
1017 def has_valid_results(self, api, suffix): # pragma: no cover
1018 return suffix in self._step_results and self._step_results[suffix]['valid']
1019
1020 def failures(self, api, suffix): # pragma: no cover
1021 assert self.has_valid_results(api, suffix)
1022 return self._step_results[suffix]['failures']
1023
1024
1025 class AMPGTestTest(AMPTest):
1026 def __init__(self, name, args=None, target_name=None, device_name=None,
1027 device_os=None, device_oem=None, android_isolate_path=None,
1028 test_run_timeout=None, **runtest_kwargs):
1029 super(AMPGTestTest, self).__init__(
1030 name=name, device_name=device_name, device_os=device_os,
1031 device_oem=device_oem, test_run_timeout=test_run_timeout)
1032 self._args = args
1033 self._target_name = target_name
1034 self._android_isolate_path = android_isolate_path
1035 # LocalGTestTest is used when AMP tests are not triggered successfully.
1036 self._local_test = LocalGTestTest(name, args, target_name, **runtest_kwargs)
1037
1038 def compile_targets(self, api):
1039 return self._local_test.compile_targets(api)
1040
1041 #override
1042 def test_type(self):
1043 return 'gtest'
1044
1045 #override
1046 def test_type_args(self, api):
1047 isolate_file_path = (api.path['checkout'].join(self._android_isolate_path)
1048 if self._android_isolate_path else None)
1049 return api.amp.gtest_arguments(
1050 self.name, isolate_file_path=isolate_file_path)
1051
1052
1053 class AMPInstrumentationTest(AMPTest):
1054 def __init__(self, test_apk, apk_under_test, compile_target=None,
1055 device_name=None, device_os=None, device_oem=None,
1056 android_isolate_path=None, test_run_timeout=None,
1057 test_timeout_scale=None):
1058 super(AMPInstrumentationTest, self).__init__(
1059 test_apk, device_name=device_name, device_os=device_os,
1060 device_oem=device_oem, test_run_timeout=test_run_timeout)
1061 self._apk_under_test = apk_under_test
1062 self._compile_target = compile_target
1063 self._android_isolate_path = android_isolate_path
1064 self._test_timeout_scale = test_timeout_scale
1065
1066 def compile_targets(self, api):
1067 return [self._compile_target]
1068
1069 #override
1070 def test_type(self):
1071 return 'instrumentation'
1072
1073 #override
1074 def test_type_args(self, api):
1075 isolate_file_path = (api.path['checkout'].join(self._android_isolate_path)
1076 if self._android_isolate_path else None)
1077 return api.amp.instrumentation_test_arguments(
1078 apk_under_test=self._apk_under_test,
1079 test_apk=self.name,
1080 isolate_file_path=isolate_file_path,
1081 timeout_scale=self._test_timeout_scale)
1082
1083
1084 class LocalIsolatedScriptTest(Test): 921 class LocalIsolatedScriptTest(Test):
1085 def __init__(self, name, args=None, target_name=None, 922 def __init__(self, name, args=None, target_name=None,
1086 override_compile_targets=None, **runtest_kwargs): 923 override_compile_targets=None, **runtest_kwargs):
1087 """Constructs an instance of LocalIsolatedScriptTest. 924 """Constructs an instance of LocalIsolatedScriptTest.
1088 925
1089 An LocalIsolatedScriptTest knows how to invoke an isolate which obeys a 926 An LocalIsolatedScriptTest knows how to invoke an isolate which obeys a
1090 certain contract. The isolate's main target must be a wrapper script which 927 certain contract. The isolate's main target must be a wrapper script which
1091 must interpret certain command line arguments as follows: 928 must interpret certain command line arguments as follows:
1092 929
1093 --isolated-script-test-output [FILENAME] 930 --isolated-script-test-output [FILENAME]
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 def run(self, api, suffix, test_filter=None): 1694 def run(self, api, suffix, test_filter=None):
1858 api.chromium_android.coverage_report(upload=False) 1695 api.chromium_android.coverage_report(upload=False)
1859 api.chromium_android.get_changed_lines_for_revision() 1696 api.chromium_android.get_changed_lines_for_revision()
1860 api.chromium_android.incremental_coverage_report() 1697 api.chromium_android.incremental_coverage_report()
1861 1698
1862 1699
1863 GOMA_TESTS = [ 1700 GOMA_TESTS = [
1864 GTestTest('base_unittests'), 1701 GTestTest('base_unittests'),
1865 GTestTest('content_unittests'), 1702 GTestTest('content_unittests'),
1866 ] 1703 ]
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/chromium_tests/chromium_fyi.py ('k') | scripts/slave/recipes/chromium.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698