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 logging | 5 import logging |
6 import os | 6 import os |
7 import pickle | 7 import pickle |
8 import sys | 8 import sys |
9 | 9 |
10 from pylib import cmd_helper | 10 from pylib import cmd_helper |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 logging.error('Unrecognized status code %d. Handling as an error.', | 133 logging.error('Unrecognized status code %d. Handling as an error.', |
134 status_code) | 134 status_code) |
135 result_type = base_test_result.ResultType.FAIL | 135 result_type = base_test_result.ResultType.FAIL |
136 if 'stack' in bundle: | 136 if 'stack' in bundle: |
137 log = '\n'.join(bundle['stack']) | 137 log = '\n'.join(bundle['stack']) |
138 | 138 |
139 return test_result.InstrumentationTestResult( | 139 return test_result.InstrumentationTestResult( |
140 test_name, result_type, start_ms, duration_ms, log=log) | 140 test_name, result_type, start_ms, duration_ms, log=log) |
141 | 141 |
142 | 142 |
143 def GenerateMultiTestResult(errors, statuses): | |
jbudorick
2015/01/16 22:24:48
This implementation can just be in the test instan
rnephew (Wrong account)
2015/01/16 22:36:38
Done.
| |
144 INSTR_STATUS_CODE_START = 1 | |
145 results = [] | |
146 skip_counter = 1 | |
147 for status_code, bundle in statuses: | |
148 if status_code != INSTR_STATUS_CODE_START: | |
149 # TODO(rnephew): Make skipped tests still output test name. This is only | |
jbudorick
2015/01/16 22:24:48
What's preventing you from doing this now?
Also,
rnephew (Wrong account)
2015/01/16 22:36:38
I was planning on doing that in its own CL, as to
jbudorick
2015/01/16 22:39:06
Fair enough.
| |
150 # there to give skipped tests a unique name so they are counted | |
151 if 'test_skipped' in bundle: | |
152 test_name = "%s" % skip_counter | |
jbudorick
2015/01/16 22:24:48
should just be
test_name = str(skip_counter)
rnephew (Wrong account)
2015/01/16 22:36:38
Done.
| |
153 skip_counter += 1 | |
154 else: | |
155 test_name = '%s#%s' % ( | |
156 ''.join(bundle.get('class', [''])), | |
157 ''.join(bundle.get('test', ['']))) | |
158 | |
159 results.append( | |
160 GenerateTestResult(test_name, [(status_code, bundle)], 0, 0)) | |
161 | |
162 if len(errors) and errors.pop(0) == 'shortMsg=Native crash': | |
jbudorick
2015/01/16 22:24:48
I'm not crazy about attempting to match an exact s
rnephew (Wrong account)
2015/01/16 22:36:38
Either am I. But this and longMsg='long version of
jbudorick
2015/01/16 22:39:06
What if we just look for "Native crash" (maybe w/
rnephew (Wrong account)
2015/01/16 22:51:02
Done.
| |
163 results.append( | |
164 base_test_result.BaseTestResult( | |
165 'Crash detected', base_test_result.ResultType.CRASH)) | |
166 | |
167 return results | |
168 | |
169 | |
143 class InstrumentationTestInstance(test_instance.TestInstance): | 170 class InstrumentationTestInstance(test_instance.TestInstance): |
144 | 171 |
145 def __init__(self, args, isolate_delegate, error_func): | 172 def __init__(self, args, isolate_delegate, error_func): |
146 super(InstrumentationTestInstance, self).__init__() | 173 super(InstrumentationTestInstance, self).__init__() |
147 | 174 |
148 self._apk_under_test = None | 175 self._apk_under_test = None |
149 self._package_info = None | 176 self._package_info = None |
150 self._test_apk = None | 177 self._test_apk = None |
151 self._test_jar = None | 178 self._test_jar = None |
152 self._test_package = None | 179 self._test_package = None |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 if hasattr(args, 'device_flags') and args.device_flags: | 290 if hasattr(args, 'device_flags') and args.device_flags: |
264 with open(args.device_flags) as device_flags_file: | 291 with open(args.device_flags) as device_flags_file: |
265 stripped_lines = (l.strip() for l in device_flags_file) | 292 stripped_lines = (l.strip() for l in device_flags_file) |
266 self._flags.extend([flag for flag in stripped_lines if flag]) | 293 self._flags.extend([flag for flag in stripped_lines if flag]) |
267 if hasattr(args, 'device_flags_file') and args.device_flags_file: | 294 if hasattr(args, 'device_flags_file') and args.device_flags_file: |
268 with open(args.device_flags_file) as device_flags_file: | 295 with open(args.device_flags_file) as device_flags_file: |
269 stripped_lines = (l.strip() for l in device_flags_file) | 296 stripped_lines = (l.strip() for l in device_flags_file) |
270 self._flags.extend([flag for flag in stripped_lines if flag]) | 297 self._flags.extend([flag for flag in stripped_lines if flag]) |
271 | 298 |
272 @property | 299 @property |
300 def suite(self): | |
301 return 'instrumentation' | |
302 | |
303 @property | |
273 def apk_under_test(self): | 304 def apk_under_test(self): |
274 return self._apk_under_test | 305 return self._apk_under_test |
275 | 306 |
276 @property | 307 @property |
277 def flags(self): | 308 def flags(self): |
278 return self._flags | 309 return self._flags |
279 | 310 |
280 @property | 311 @property |
281 def package_info(self): | 312 def package_info(self): |
282 return self._package_info | 313 return self._package_info |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 'method': m['method'], | 487 'method': m['method'], |
457 'annotations': a, | 488 'annotations': a, |
458 }) | 489 }) |
459 return inflated_tests | 490 return inflated_tests |
460 | 491 |
461 @staticmethod | 492 @staticmethod |
462 def ParseAmInstrumentRawOutput(raw_output): | 493 def ParseAmInstrumentRawOutput(raw_output): |
463 return ParseAmInstrumentRawOutput(raw_output) | 494 return ParseAmInstrumentRawOutput(raw_output) |
464 | 495 |
465 @staticmethod | 496 @staticmethod |
497 def GenerateMultiTestResult(errors, statuses): | |
498 return GenerateMultiTestResult(errors, statuses) | |
499 | |
500 @staticmethod | |
466 def GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms): | 501 def GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms): |
467 return GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms) | 502 return GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms) |
468 | 503 |
469 #override | 504 #override |
470 def TearDown(self): | 505 def TearDown(self): |
471 if self._isolate_delegate: | 506 if self._isolate_delegate: |
472 self._isolate_delegate.Clear() | 507 self._isolate_delegate.Clear() |
473 | 508 |
OLD | NEW |