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

Side by Side Diff: build/android/pylib/run_java_tests.py

Issue 11437018: Change test running logic to run tests without any size annotation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply feedback Created 8 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" 5 """Runs the Java tests. See more information on run_instrumentation_tests.py."""
6 6
7 import fnmatch 7 import fnmatch
8 import logging 8 import logging
9 import os 9 import os
10 import re 10 import re
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 options: Command line options. 522 options: Command line options.
523 apks: list of APKs to use. 523 apks: list of APKs to use.
524 524
525 Returns: 525 Returns:
526 A TestResults object holding the results of the Java tests. 526 A TestResults object holding the results of the Java tests.
527 527
528 Raises: 528 Raises:
529 FatalTestException: when there's no attached the devices. 529 FatalTestException: when there's no attached the devices.
530 """ 530 """
531 test_apk = apks[0] 531 test_apk = apks[0]
532 # The default annotation for tests which do not have any sizes annotation.
533 default_size_annotation = 'SmallTest'
534
535 def testsMissingAnnotation(test_apk):
frankf 2012/12/05 23:54:17 Unfortunately, we don't follow the google3 style g
shashi 2012/12/06 00:27:26 Done.
536 test_size_annotations = frozenset(['Smoke', 'SmallTest', 'MediumTest',
537 'LargeTest', 'EnormousTest', 'FlakyTest',
538 'DisabledTest', 'Manual', 'PerfTest'])
539 tests_missing_annotations = []
540 for test_method in test_apk.GetTestMethods():
541 annotations = frozenset(test_apk.GetTestAnnotations(test_method))
542 if (annotations.isdisjoint(test_size_annotations) and
543 not apk_info.ApkInfo.IsPythonDrivenTest(test_method)):
544 tests_missing_annotations.append(test_method)
545 return tests_missing_annotations
546
532 if options.annotation: 547 if options.annotation:
533 available_tests = test_apk.GetAnnotatedTests(options.annotation) 548 available_tests = test_apk.GetAnnotatedTests(options.annotation)
534 if len(options.annotation) == 1 and options.annotation[0] == 'SmallTest': 549 if (len(options.annotation) == 1 and
535 tests_without_annotation = [ 550 options.annotation[0] == default_size_annotation):
frankf 2012/12/05 23:54:17 Why do we include un-annotated tests in SmallTest
shashi 2012/12/06 00:27:26 Currently build bots always specify size when runn
frankf 2012/12/06 01:01:55 What I meant: 1. Unannotated tests are run: ./run
shashi 2012/12/06 01:18:40 Makes sense, we need not check if SmallTest is the
536 m for m in 551 tests_missing_annotations = testsMissingAnnotation(test_apk)
537 test_apk.GetTestMethods() 552 if tests_missing_annotations:
538 if not test_apk.GetTestAnnotations(m) and 553 tests_missing_annotations.sort()
frankf 2012/12/05 23:54:17 just have the method sort it for you.
shashi 2012/12/06 00:27:26 Done.
539 not apk_info.ApkInfo.IsPythonDrivenTest(m)]
540 if tests_without_annotation:
541 tests_without_annotation.sort()
542 logging.warning('The following tests do not contain any annotation. ' 554 logging.warning('The following tests do not contain any annotation. '
543 'Assuming "SmallTest":\n%s', 555 'Assuming "%s":\n%s',
544 '\n'.join(tests_without_annotation)) 556 default_size_annotation,
545 available_tests += tests_without_annotation 557 '\n'.join(tests_missing_annotations))
558 available_tests += tests_missing_annotations
546 else: 559 else:
547 available_tests = [m for m in test_apk.GetTestMethods() 560 available_tests = [m for m in test_apk.GetTestMethods()
548 if not apk_info.ApkInfo.IsPythonDrivenTest(m)] 561 if not apk_info.ApkInfo.IsPythonDrivenTest(m)]
549 coverage = os.environ.get('EMMA_INSTRUMENT') == 'true' 562 coverage = os.environ.get('EMMA_INSTRUMENT') == 'true'
550 563
551 tests = [] 564 tests = []
552 if options.test_filter: 565 if options.test_filter:
553 # |available_tests| are in adb instrument format: package.path.class#test. 566 # |available_tests| are in adb instrument format: package.path.class#test.
554 filter_without_hash = options.test_filter.replace('#', '.') 567 filter_without_hash = options.test_filter.replace('#', '.')
555 tests = [t for t in available_tests 568 tests = [t for t in available_tests
(...skipping 17 matching lines...) Expand all
573 586
574 logging.info('Will run: %s', str(tests)) 587 logging.info('Will run: %s', str(tests))
575 588
576 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): 589 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger):
577 logging.warning('Coverage / debugger can not be sharded, ' 590 logging.warning('Coverage / debugger can not be sharded, '
578 'using first available device') 591 'using first available device')
579 attached_devices = attached_devices[:1] 592 attached_devices = attached_devices[:1]
580 sharder = TestSharder(attached_devices, options, tests, apks) 593 sharder = TestSharder(attached_devices, options, tests, apks)
581 test_results = sharder.RunShardedTests() 594 test_results = sharder.RunShardedTests()
582 return test_results 595 return test_results
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698