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

Side by Side Diff: build/android/pylib/instrumentation/instrumentation_test_instance.py

Issue 2991833003: Revert of List Java Instru Test Information From JUnit Runner (Closed)
Patch Set: Created 3 years, 4 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 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 copy 5 import copy
6 import logging 6 import logging
7 import os 7 import os
8 import pickle 8 import pickle
9 import re 9 import re
10 10
(...skipping 18 matching lines...) Expand all
29 _ACTIVITY_RESULT_CANCELED = 0 29 _ACTIVITY_RESULT_CANCELED = 0
30 _ACTIVITY_RESULT_OK = -1 30 _ACTIVITY_RESULT_OK = -1
31 31
32 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter' 32 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter'
33 _DEFAULT_ANNOTATIONS = [ 33 _DEFAULT_ANNOTATIONS = [
34 'SmallTest', 'MediumTest', 'LargeTest', 'EnormousTest', 'IntegrationTest'] 34 'SmallTest', 'MediumTest', 'LargeTest', 'EnormousTest', 'IntegrationTest']
35 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS = [ 35 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS = [
36 'DisabledTest', 'FlakyTest'] 36 'DisabledTest', 'FlakyTest']
37 _VALID_ANNOTATIONS = set(['Manual'] + _DEFAULT_ANNOTATIONS + 37 _VALID_ANNOTATIONS = set(['Manual'] + _DEFAULT_ANNOTATIONS +
38 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS) 38 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS)
39
40 # These test methods are inherited from android.test base test class and
41 # should be permitted for not having size annotation. For more, please check
42 # https://developer.android.com/reference/android/test/AndroidTestCase.html
43 # https://developer.android.com/reference/android/test/ServiceTestCase.html
44 _TEST_WITHOUT_SIZE_ANNOTATIONS = [
45 'testAndroidTestCaseSetupProperly', 'testServiceTestCaseSetUpProperly']
46
47 _EXTRA_DRIVER_TEST_LIST = ( 39 _EXTRA_DRIVER_TEST_LIST = (
48 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestList') 40 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestList')
49 _EXTRA_DRIVER_TEST_LIST_FILE = ( 41 _EXTRA_DRIVER_TEST_LIST_FILE = (
50 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestListFile') 42 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestListFile')
51 _EXTRA_DRIVER_TARGET_PACKAGE = ( 43 _EXTRA_DRIVER_TARGET_PACKAGE = (
52 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetPackage') 44 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetPackage')
53 _EXTRA_DRIVER_TARGET_CLASS = ( 45 _EXTRA_DRIVER_TARGET_CLASS = (
54 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetClass') 46 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetClass')
55 _EXTRA_TIMEOUT_SCALE = ( 47 _EXTRA_TIMEOUT_SCALE = (
56 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TimeoutScale') 48 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TimeoutScale')
(...skipping 11 matching lines...) Expand all
68 super(MissingSizeAnnotationError, self).__init__(class_name + 60 super(MissingSizeAnnotationError, self).__init__(class_name +
69 ': Test method is missing required size annotation. Add one of: ' + 61 ': Test method is missing required size annotation. Add one of: ' +
70 ', '.join('@' + a for a in _VALID_ANNOTATIONS)) 62 ', '.join('@' + a for a in _VALID_ANNOTATIONS))
71 63
72 64
73 class TestListPickleException(test_exception.TestException): 65 class TestListPickleException(test_exception.TestException):
74 pass 66 pass
75 67
76 68
77 # TODO(jbudorick): Make these private class methods of 69 # TODO(jbudorick): Make these private class methods of
78 # InstrumentationTestInstance once the instrumentation junit3_runner_class is 70 # InstrumentationTestInstance once the instrumentation test_runner is
79 # deprecated. 71 # deprecated.
80 def ParseAmInstrumentRawOutput(raw_output): 72 def ParseAmInstrumentRawOutput(raw_output):
81 """Parses the output of an |am instrument -r| call. 73 """Parses the output of an |am instrument -r| call.
82 74
83 Args: 75 Args:
84 raw_output: the output of an |am instrument -r| call as a list of lines 76 raw_output: the output of an |am instrument -r| call as a list of lines
85 Returns: 77 Returns:
86 A 3-tuple containing: 78 A 3-tuple containing:
87 - the instrumentation code as an integer 79 - the instrumentation code as an integer
88 - the instrumentation result as a list of lines 80 - the instrumentation result as a list of lines
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 156
165 return results 157 return results
166 158
167 159
168 def FilterTests(tests, test_filter=None, annotations=None, 160 def FilterTests(tests, test_filter=None, annotations=None,
169 excluded_annotations=None): 161 excluded_annotations=None):
170 """Filter a list of tests 162 """Filter a list of tests
171 163
172 Args: 164 Args:
173 tests: a list of tests. e.g. [ 165 tests: a list of tests. e.g. [
174 {'annotations": {}, 'class': 'com.example.TestA', 'method':'test1'}, 166 {'annotations": {}, 'class': 'com.example.TestA', 'methods':[]},
175 {'annotations": {}, 'class': 'com.example.TestB', 'method':'test2'}] 167 {'annotations": {}, 'class': 'com.example.TestB', 'methods':[]}]
176 test_filter: googletest-style filter string. 168 test_filter: googletest-style filter string.
177 annotations: a dict of wanted annotations for test methods. 169 annotations: a dict of wanted annotations for test methods.
178 exclude_annotations: a dict of annotations to exclude. 170 exclude_annotations: a dict of annotations to exclude.
179 171
180 Return: 172 Return:
181 A list of filtered tests 173 A list of filtered tests
182 """ 174 """
183 def gtest_filter(t): 175 def gtest_filter(t):
184 if not test_filter: 176 if not test_filter:
185 return True 177 return True
186 # Allow fully-qualified name as well as an omitted package. 178 # Allow fully-qualified name as well as an omitted package.
187 unqualified_class_test = { 179 unqualified_class_test = {
188 'class': t['class'].split('.')[-1], 180 'class': t['class'].split('.')[-1],
189 'method': t['method'] 181 'method': t['method']
190 } 182 }
191 names = [ 183 names = [
192 GetTestName(t, sep='.'), 184 GetTestName(t, sep='.'),
193 GetTestName(unqualified_class_test, sep='.'), 185 GetTestName(unqualified_class_test, sep='.'),
194 GetUniqueTestName(t, sep='.') 186 GetUniqueTestName(t, sep='.')
195 ] 187 ]
196 188
197 if t['is_junit4']:
198 names += [
199 GetTestNameWithoutParameterPostfix(t, sep='.'),
200 GetTestNameWithoutParameterPostfix(unqualified_class_test, sep='.')
201 ]
202
203 pattern_groups = test_filter.split('-') 189 pattern_groups = test_filter.split('-')
204 if len(pattern_groups) > 1: 190 if len(pattern_groups) > 1:
205 negative_filter = pattern_groups[1] 191 negative_filter = pattern_groups[1]
206 if unittest_util.FilterTestNames(names, negative_filter): 192 if unittest_util.FilterTestNames(names, negative_filter):
207 return [] 193 return []
208 194
209 positive_filter = pattern_groups[0] 195 positive_filter = pattern_groups[0]
210 return unittest_util.FilterTestNames(names, positive_filter) 196 return unittest_util.FilterTestNames(names, positive_filter)
211 197
212 def annotation_filter(all_annotations): 198 def annotation_filter(all_annotations):
(...skipping 22 matching lines...) Expand all
235 return filter_av in av 221 return filter_av in av
236 return filter_av == av 222 return filter_av == av
237 223
238 filtered_tests = [] 224 filtered_tests = []
239 for t in tests: 225 for t in tests:
240 # Gtest filtering 226 # Gtest filtering
241 if not gtest_filter(t): 227 if not gtest_filter(t):
242 continue 228 continue
243 229
244 # Enforce that all tests declare their size. 230 # Enforce that all tests declare their size.
245 if (not any(a in _VALID_ANNOTATIONS for a in t['annotations']) 231 if not any(a in _VALID_ANNOTATIONS for a in t['annotations']):
246 and t['method'] not in _TEST_WITHOUT_SIZE_ANNOTATIONS):
247 raise MissingSizeAnnotationError(GetTestName(t)) 232 raise MissingSizeAnnotationError(GetTestName(t))
248 233
249 if (not annotation_filter(t['annotations']) 234 if (not annotation_filter(t['annotations'])
250 or not excluded_annotation_filter(t['annotations'])): 235 or not excluded_annotation_filter(t['annotations'])):
251 continue 236 continue
252 237
253 filtered_tests.append(t) 238 filtered_tests.append(t)
254 239
255 return filtered_tests 240 return filtered_tests
256 241
257 242
258 # TODO(yolandyan): remove this once the tests are converted to junit4
259 def GetAllTestsFromJar(test_jar): 243 def GetAllTestsFromJar(test_jar):
260 pickle_path = '%s-proguard.pickle' % test_jar 244 pickle_path = '%s-proguard.pickle' % test_jar
261 try: 245 try:
262 tests = GetTestsFromPickle(pickle_path, test_jar) 246 tests = _GetTestsFromPickle(pickle_path, test_jar)
263 except TestListPickleException as e: 247 except TestListPickleException as e:
264 logging.info('Could not get tests from pickle: %s', e) 248 logging.info('Could not get tests from pickle: %s', e)
265 logging.info('Getting tests from JAR via proguard.') 249 logging.info('Getting tests from JAR via proguard.')
266 tests = _GetTestsFromProguard(test_jar) 250 tests = _GetTestsFromProguard(test_jar)
267 SaveTestsToPickle(pickle_path, test_jar, tests) 251 _SaveTestsToPickle(pickle_path, test_jar, tests)
268 return tests 252 return tests
269 253
270 254
271 def GetAllTestsFromApk(test_apk): 255 def GetAllTestsFromApk(test_apk):
272 pickle_path = '%s-dexdump.pickle' % test_apk 256 pickle_path = '%s-dexdump.pickle' % test_apk
273 try: 257 try:
274 tests = GetTestsFromPickle(pickle_path, test_apk) 258 tests = _GetTestsFromPickle(pickle_path, test_apk)
275 except TestListPickleException as e: 259 except TestListPickleException as e:
276 logging.info('Could not get tests from pickle: %s', e) 260 logging.info('Could not get tests from pickle: %s', e)
277 logging.info('Getting tests from dex via dexdump.') 261 logging.info('Getting tests from dex via dexdump.')
278 tests = _GetTestsFromDexdump(test_apk) 262 tests = _GetTestsFromDexdump(test_apk)
279 SaveTestsToPickle(pickle_path, test_apk, tests) 263 _SaveTestsToPickle(pickle_path, test_apk, tests)
280 return tests 264 return tests
281 265
282 def GetTestsFromPickle(pickle_path, jar_path): 266 def _GetTestsFromPickle(pickle_path, jar_path):
283 if not os.path.exists(pickle_path): 267 if not os.path.exists(pickle_path):
284 raise TestListPickleException('%s does not exist.' % pickle_path) 268 raise TestListPickleException('%s does not exist.' % pickle_path)
285 if os.path.getmtime(pickle_path) <= os.path.getmtime(jar_path): 269 if os.path.getmtime(pickle_path) <= os.path.getmtime(jar_path):
286 raise TestListPickleException( 270 raise TestListPickleException(
287 '%s newer than %s.' % (jar_path, pickle_path)) 271 '%s newer than %s.' % (jar_path, pickle_path))
288 272
289 with open(pickle_path, 'r') as f: 273 with open(pickle_path, 'r') as f:
290 pickle_data = pickle.load(f) 274 pickle_data = pickle.load(f)
291 jar_md5 = md5sum.CalculateHostMd5Sums(jar_path)[jar_path] 275 jar_md5 = md5sum.CalculateHostMd5Sums(jar_path)[jar_path]
292 276
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 for class_name, class_info in package_info['classes'].iteritems(): 331 for class_name, class_info in package_info['classes'].iteritems():
348 if class_name.endswith('Test'): 332 if class_name.endswith('Test'):
349 tests.append({ 333 tests.append({
350 'class': '%s.%s' % (package_name, class_name), 334 'class': '%s.%s' % (package_name, class_name),
351 'annotations': {}, 335 'annotations': {},
352 'methods': get_test_methods(class_info['methods']), 336 'methods': get_test_methods(class_info['methods']),
353 'superclass': class_info['superclass'], 337 'superclass': class_info['superclass'],
354 }) 338 })
355 return tests 339 return tests
356 340
357 def SaveTestsToPickle(pickle_path, jar_path, tests): 341
342 def _SaveTestsToPickle(pickle_path, jar_path, tests):
358 jar_md5 = md5sum.CalculateHostMd5Sums(jar_path)[jar_path] 343 jar_md5 = md5sum.CalculateHostMd5Sums(jar_path)[jar_path]
359 pickle_data = { 344 pickle_data = {
360 'VERSION': _PICKLE_FORMAT_VERSION, 345 'VERSION': _PICKLE_FORMAT_VERSION,
361 'JAR_MD5SUM': jar_md5, 346 'JAR_MD5SUM': jar_md5,
362 'TEST_METHODS': tests, 347 'TEST_METHODS': tests,
363 } 348 }
364 with open(pickle_path, 'w') as pickle_file: 349 with open(pickle_path, 'w') as pickle_file:
365 pickle.dump(pickle_data, pickle_file) 350 pickle.dump(pickle_data, pickle_file)
366 351
367 352
(...skipping 21 matching lines...) Expand all
389 374
390 Args: 375 Args:
391 test: the instrumentation test dict. 376 test: the instrumentation test dict.
392 sep: the character(s) that should join the class name and the method name. 377 sep: the character(s) that should join the class name and the method name.
393 Returns: 378 Returns:
394 The test name as a string. 379 The test name as a string.
395 """ 380 """
396 return '%s%s%s' % (test['class'], sep, test['method']) 381 return '%s%s%s' % (test['class'], sep, test['method'])
397 382
398 383
399 def GetTestNameWithoutParameterPostfix(
400 test, sep='#', parameterization_sep='__'):
401 """Gets the name of the given JUnit4 test without parameter postfix.
402
403 For most WebView JUnit4 javatests, each test is parameterizatized with
404 "__sandboxed_mode" to run in both non-sandboxed mode and sandboxed mode.
405
406 This function returns the name of the test without parameterization
407 so test filters can match both parameterized and non-parameterized tests.
408
409 Args:
410 test: the instrumentation test dict.
411 sep: the character(s) that should join the class name and the method name.
412 parameterization_sep: the character(s) that seperate method name and method
413 parameterization postfix.
414 Returns:
415 The test name without parameter postfix as a string.
416 """
417 name = GetTestName(test, sep=sep)
418 return name.split(parameterization_sep)[0]
419
420
421 def GetUniqueTestName(test, sep='#'): 384 def GetUniqueTestName(test, sep='#'):
422 """Gets the unique name of the given test. 385 """Gets the unique name of the given test.
423 386
424 This will include text to disambiguate between tests for which GetTestName 387 This will include text to disambiguate between tests for which GetTestName
425 would return the same name. 388 would return the same name.
426 389
427 Args: 390 Args:
428 test: the instrumentation test dict. 391 test: the instrumentation test dict.
429 sep: the character(s) that should join the class name and the method name. 392 sep: the character(s) that should join the class name and the method name.
430 Returns: 393 Returns:
(...skipping 12 matching lines...) Expand all
443 406
444 self._additional_apks = [] 407 self._additional_apks = []
445 self._apk_under_test = None 408 self._apk_under_test = None
446 self._apk_under_test_incremental_install_script = None 409 self._apk_under_test_incremental_install_script = None
447 self._package_info = None 410 self._package_info = None
448 self._suite = None 411 self._suite = None
449 self._test_apk = None 412 self._test_apk = None
450 self._test_apk_incremental_install_script = None 413 self._test_apk_incremental_install_script = None
451 self._test_jar = None 414 self._test_jar = None
452 self._test_package = None 415 self._test_package = None
453 self._junit3_runner_class = None 416 self._test_runner = None
454 self._junit4_runner_class = None 417 self._test_runner_junit4 = None
455 self._test_support_apk = None 418 self._test_support_apk = None
456 self._initializeApkAttributes(args, error_func) 419 self._initializeApkAttributes(args, error_func)
457 420
458 self._data_deps = None 421 self._data_deps = None
459 self._data_deps_delegate = None 422 self._data_deps_delegate = None
460 self._runtime_deps_path = None 423 self._runtime_deps_path = None
461 self._initializeDataDependencyAttributes(args, data_deps_delegate) 424 self._initializeDataDependencyAttributes(args, data_deps_delegate)
462 425
463 self._annotations = None 426 self._annotations = None
464 self._excluded_annotations = None 427 self._excluded_annotations = None
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 error_func('Unable to find test APK: %s' % self._test_apk.path) 514 error_func('Unable to find test APK: %s' % self._test_apk.path)
552 if not self._test_jar: 515 if not self._test_jar:
553 logging.warning('Test jar not specified. Test runner will not have ' 516 logging.warning('Test jar not specified. Test runner will not have '
554 'Java annotation info available. May not handle test ' 517 'Java annotation info available. May not handle test '
555 'timeouts correctly.') 518 'timeouts correctly.')
556 elif not os.path.exists(self._test_jar): 519 elif not os.path.exists(self._test_jar):
557 error_func('Unable to find test JAR: %s' % self._test_jar) 520 error_func('Unable to find test JAR: %s' % self._test_jar)
558 521
559 self._test_package = self._test_apk.GetPackageName() 522 self._test_package = self._test_apk.GetPackageName()
560 all_instrumentations = self._test_apk.GetAllInstrumentations() 523 all_instrumentations = self._test_apk.GetAllInstrumentations()
561 all_junit3_runner_classes = [ 524 test_runners = [
562 x for x in all_instrumentations if ('true' not in x.get( 525 x for x in all_instrumentations if ('true' not in x.get(
563 'chromium-junit4', ''))] 526 'chromium-junit4', ''))]
564 all_junit4_test_runner_classes = [ 527 test_runners_junit4 = [
565 x for x in all_instrumentations if ('true' in x.get( 528 x for x in all_instrumentations if ('true' in x.get(
566 'chromium-junit4', ''))] 529 'chromium-junit4', ''))]
567 530
568 if len(all_junit3_runner_classes) > 1: 531 if len(test_runners) > 1:
569 logging.warning('This test apk has more than one JUnit3 instrumentation') 532 logging.warning('This test apk has more than one JUnit3 instrumentation')
570 if len(all_junit4_test_runner_classes) > 1: 533 if len(test_runners_junit4) > 1:
571 logging.warning('This test apk has more than one JUnit4 instrumentation') 534 logging.warning('This test apk has more than one JUnit4 instrumentation')
572 535
573 self._junit3_runner_class = ( 536 self._test_runner = (
574 all_junit3_runner_classes[0]['android:name'] 537 test_runners[0]['android:name'] if test_runners else
575 if all_junit3_runner_classes else self.test_apk.GetInstrumentationName()) 538 self.test_apk.GetInstrumentationName())
576 539 self._test_runner_junit4 = (
577 self._junit4_runner_class = ( 540 test_runners_junit4[0]['android:name'] if test_runners_junit4 else None)
578 all_junit4_test_runner_classes[0]['android:name']
579 if all_junit4_test_runner_classes else None)
580 541
581 self._package_info = None 542 self._package_info = None
582 if self._apk_under_test: 543 if self._apk_under_test:
583 package_under_test = self._apk_under_test.GetPackageName() 544 package_under_test = self._apk_under_test.GetPackageName()
584 for package_info in constants.PACKAGE_INFO.itervalues(): 545 for package_info in constants.PACKAGE_INFO.itervalues():
585 if package_under_test == package_info.package: 546 if package_under_test == package_info.package:
586 self._package_info = package_info 547 self._package_info = package_info
587 break 548 break
588 if not self._package_info: 549 if not self._package_info:
589 logging.warning('Unable to find package info for %s', self._test_package) 550 logging.warning('Unable to find package info for %s', self._test_package)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 684
724 @property 685 @property
725 def flags(self): 686 def flags(self):
726 return self._flags 687 return self._flags
727 688
728 @property 689 @property
729 def gs_results_bucket(self): 690 def gs_results_bucket(self):
730 return self._gs_results_bucket 691 return self._gs_results_bucket
731 692
732 @property 693 @property
733 def junit3_runner_class(self):
734 return self._junit3_runner_class
735
736 @property
737 def junit4_runner_class(self):
738 return self._junit4_runner_class
739
740 @property
741 def should_save_logcat(self): 694 def should_save_logcat(self):
742 return self._should_save_logcat 695 return self._should_save_logcat
743 696
744 @property 697 @property
745 def package_info(self): 698 def package_info(self):
746 return self._package_info 699 return self._package_info
747 700
748 @property 701 @property
749 def render_results_dir(self): 702 def render_results_dir(self):
750 return self._render_results_dir 703 return self._render_results_dir
(...skipping 28 matching lines...) Expand all
779 732
780 @property 733 @property
781 def test_support_apk(self): 734 def test_support_apk(self):
782 return self._test_support_apk 735 return self._test_support_apk
783 736
784 @property 737 @property
785 def test_package(self): 738 def test_package(self):
786 return self._test_package 739 return self._test_package
787 740
788 @property 741 @property
742 def test_runner(self):
743 return self._test_runner
744
745 @property
746 def test_runner_junit4(self):
747 return self._test_runner_junit4
748
749 @property
789 def timeout_scale(self): 750 def timeout_scale(self):
790 return self._timeout_scale 751 return self._timeout_scale
791 752
792 @property 753 @property
793 def total_external_shards(self): 754 def total_external_shards(self):
794 return self._total_external_shards 755 return self._total_external_shards
795 756
796 @property 757 @property
797 def ui_screenshot_dir(self): 758 def ui_screenshot_dir(self):
798 return self._ui_screenshot_dir 759 return self._ui_screenshot_dir
799 760
800 #override 761 #override
801 def TestType(self): 762 def TestType(self):
802 return 'instrumentation' 763 return 'instrumentation'
803 764
804 #override 765 #override
805 def SetUp(self): 766 def SetUp(self):
806 self._data_deps.extend( 767 self._data_deps.extend(
807 self._data_deps_delegate(self._runtime_deps_path)) 768 self._data_deps_delegate(self._runtime_deps_path))
808 769
809 def GetDataDependencies(self): 770 def GetDataDependencies(self):
810 return self._data_deps 771 return self._data_deps
811 772
812 def GetTests(self): 773 def GetTests(self):
813 if self.test_jar: 774 if self.test_jar:
814 raw_tests = GetAllTestsFromJar(self.test_jar) 775 tests = GetAllTestsFromJar(self.test_jar)
815 else: 776 else:
816 raw_tests = GetAllTestsFromApk(self.test_apk.path) 777 tests = GetAllTestsFromApk(self.test_apk.path)
817 return self.ProcessRawTests(raw_tests) 778 inflated_tests = self._ParameterizeTestsWithFlags(self._InflateTests(tests))
818 779 if self._test_runner_junit4 is None and any(
819 def ProcessRawTests(self, raw_tests):
820 inflated_tests = self._ParameterizeTestsWithFlags(
821 self._InflateTests(raw_tests))
822 if self._junit4_runner_class is None and any(
823 t['is_junit4'] for t in inflated_tests): 780 t['is_junit4'] for t in inflated_tests):
824 raise MissingJUnit4RunnerException() 781 raise MissingJUnit4RunnerException()
825 filtered_tests = FilterTests( 782 filtered_tests = FilterTests(
826 inflated_tests, self._test_filter, self._annotations, 783 inflated_tests, self._test_filter, self._annotations,
827 self._excluded_annotations) 784 self._excluded_annotations)
828 if self._test_filter and not filtered_tests: 785 if self._test_filter and not filtered_tests:
829 for t in inflated_tests: 786 for t in inflated_tests:
830 logging.debug(' %s', GetUniqueTestName(t)) 787 logging.debug(' %s', GetUniqueTestName(t))
831 raise UnmatchedFilterException(self._test_filter) 788 raise UnmatchedFilterException(self._test_filter)
832 return filtered_tests 789 return filtered_tests
(...skipping 26 matching lines...) Expand all
859 for p in parameters[1:]: 816 for p in parameters[1:]:
860 parameterized_t = copy.copy(t) 817 parameterized_t = copy.copy(t)
861 parameterized_t['flags'] = ['--%s' % p] 818 parameterized_t['flags'] = ['--%s' % p]
862 new_tests.append(parameterized_t) 819 new_tests.append(parameterized_t)
863 return tests + new_tests 820 return tests + new_tests
864 821
865 def GetDriverEnvironmentVars( 822 def GetDriverEnvironmentVars(
866 self, test_list=None, test_list_file_path=None): 823 self, test_list=None, test_list_file_path=None):
867 env = { 824 env = {
868 _EXTRA_DRIVER_TARGET_PACKAGE: self.test_package, 825 _EXTRA_DRIVER_TARGET_PACKAGE: self.test_package,
869 _EXTRA_DRIVER_TARGET_CLASS: self.junit3_runner_class, 826 _EXTRA_DRIVER_TARGET_CLASS: self.test_runner,
870 _EXTRA_TIMEOUT_SCALE: self._timeout_scale, 827 _EXTRA_TIMEOUT_SCALE: self._timeout_scale,
871 } 828 }
872 829
873 if test_list: 830 if test_list:
874 env[_EXTRA_DRIVER_TEST_LIST] = ','.join(test_list) 831 env[_EXTRA_DRIVER_TEST_LIST] = ','.join(test_list)
875 832
876 if test_list_file_path: 833 if test_list_file_path:
877 env[_EXTRA_DRIVER_TEST_LIST_FILE] = ( 834 env[_EXTRA_DRIVER_TEST_LIST_FILE] = (
878 os.path.basename(test_list_file_path)) 835 os.path.basename(test_list_file_path))
879 836
880 return env 837 return env
881 838
882 @staticmethod 839 @staticmethod
883 def ParseAmInstrumentRawOutput(raw_output): 840 def ParseAmInstrumentRawOutput(raw_output):
884 return ParseAmInstrumentRawOutput(raw_output) 841 return ParseAmInstrumentRawOutput(raw_output)
885 842
886 @staticmethod 843 @staticmethod
887 def GenerateTestResults( 844 def GenerateTestResults(
888 result_code, result_bundle, statuses, start_ms, duration_ms): 845 result_code, result_bundle, statuses, start_ms, duration_ms):
889 return GenerateTestResults(result_code, result_bundle, statuses, 846 return GenerateTestResults(result_code, result_bundle, statuses,
890 start_ms, duration_ms) 847 start_ms, duration_ms)
891 848
892 #override 849 #override
893 def TearDown(self): 850 def TearDown(self):
894 pass 851 pass
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698