| 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 collections | 5 import collections |
| 6 import copy | 6 import copy |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import pickle | 9 import pickle |
| 10 import re | 10 import re |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 # Ref: http://developer.android.com/reference/android/app/Activity.html | 26 # Ref: http://developer.android.com/reference/android/app/Activity.html |
| 27 _ACTIVITY_RESULT_CANCELED = 0 | 27 _ACTIVITY_RESULT_CANCELED = 0 |
| 28 _ACTIVITY_RESULT_OK = -1 | 28 _ACTIVITY_RESULT_OK = -1 |
| 29 | 29 |
| 30 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter' | 30 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter' |
| 31 _DEFAULT_ANNOTATIONS = [ | 31 _DEFAULT_ANNOTATIONS = [ |
| 32 'Smoke', 'SmallTest', 'MediumTest', 'LargeTest', | 32 'Smoke', 'SmallTest', 'MediumTest', 'LargeTest', |
| 33 'EnormousTest', 'IntegrationTest'] | 33 'EnormousTest', 'IntegrationTest'] |
| 34 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS = [ | 34 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS = [ |
| 35 'DisabledTest', 'FlakyTest'] | 35 'DisabledTest', 'FlakyTest'] |
| 36 _VALID_ANNOTATIONS = set(['Manual', 'PerfTest'] + _DEFAULT_ANNOTATIONS + | |
| 37 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS) | |
| 38 _EXTRA_DRIVER_TEST_LIST = ( | 36 _EXTRA_DRIVER_TEST_LIST = ( |
| 39 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestList') | 37 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestList') |
| 40 _EXTRA_DRIVER_TEST_LIST_FILE = ( | 38 _EXTRA_DRIVER_TEST_LIST_FILE = ( |
| 41 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestListFile') | 39 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestListFile') |
| 42 _EXTRA_DRIVER_TARGET_PACKAGE = ( | 40 _EXTRA_DRIVER_TARGET_PACKAGE = ( |
| 43 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetPackage') | 41 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetPackage') |
| 44 _EXTRA_DRIVER_TARGET_CLASS = ( | 42 _EXTRA_DRIVER_TARGET_CLASS = ( |
| 45 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetClass') | 43 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetClass') |
| 46 _EXTRA_TIMEOUT_SCALE = ( | 44 _EXTRA_TIMEOUT_SCALE = ( |
| 47 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TimeoutScale') | 45 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TimeoutScale') |
| 48 | 46 |
| 49 _PARAMETERIZED_TEST_ANNOTATION = 'ParameterizedTest' | 47 _PARAMETERIZED_TEST_ANNOTATION = 'ParameterizedTest' |
| 50 _PARAMETERIZED_TEST_SET_ANNOTATION = 'ParameterizedTest$Set' | 48 _PARAMETERIZED_TEST_SET_ANNOTATION = 'ParameterizedTest$Set' |
| 51 _NATIVE_CRASH_RE = re.compile('native crash', re.IGNORECASE) | 49 _NATIVE_CRASH_RE = re.compile('native crash', re.IGNORECASE) |
| 52 _PICKLE_FORMAT_VERSION = 10 | 50 _PICKLE_FORMAT_VERSION = 10 |
| 53 | 51 |
| 54 | 52 |
| 55 class MissingSizeAnnotationError(Exception): | |
| 56 def __init__(self, class_name): | |
| 57 super(MissingSizeAnnotationError, self).__init__(class_name + | |
| 58 ': Test method is missing required size annotation. Add one of: ' + | |
| 59 ', '.join('@' + a for a in _VALID_ANNOTATIONS)) | |
| 60 | |
| 61 | |
| 62 # TODO(jbudorick): Make these private class methods of | 53 # TODO(jbudorick): Make these private class methods of |
| 63 # InstrumentationTestInstance once the instrumentation test_runner is | 54 # InstrumentationTestInstance once the instrumentation test_runner is |
| 64 # deprecated. | 55 # deprecated. |
| 65 def ParseAmInstrumentRawOutput(raw_output): | 56 def ParseAmInstrumentRawOutput(raw_output): |
| 66 """Parses the output of an |am instrument -r| call. | 57 """Parses the output of an |am instrument -r| call. |
| 67 | 58 |
| 68 Args: | 59 Args: |
| 69 raw_output: the output of an |am instrument -r| call as a list of lines | 60 raw_output: the output of an |am instrument -r| call as a list of lines |
| 70 Returns: | 61 Returns: |
| 71 A 3-tuple containing: | 62 A 3-tuple containing: |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 filtered_classes = [] | 572 filtered_classes = [] |
| 582 for c in tests: | 573 for c in tests: |
| 583 filtered_methods = [] | 574 filtered_methods = [] |
| 584 for m in c['methods']: | 575 for m in c['methods']: |
| 585 # Gtest filtering | 576 # Gtest filtering |
| 586 if not gtest_filter(c, m): | 577 if not gtest_filter(c, m): |
| 587 continue | 578 continue |
| 588 | 579 |
| 589 all_annotations = dict(c['annotations']) | 580 all_annotations = dict(c['annotations']) |
| 590 all_annotations.update(m['annotations']) | 581 all_annotations.update(m['annotations']) |
| 591 | |
| 592 # Enforce that all tests declare their size. | |
| 593 if not any(a in _VALID_ANNOTATIONS for a in all_annotations): | |
| 594 raise MissingSizeAnnotationError('%s.%s' % (c['class'], m['method'])) | |
| 595 | |
| 596 if (not annotation_filter(all_annotations) | 582 if (not annotation_filter(all_annotations) |
| 597 or not excluded_annotation_filter(all_annotations)): | 583 or not excluded_annotation_filter(all_annotations)): |
| 598 continue | 584 continue |
| 599 | 585 |
| 600 filtered_methods.append(m) | 586 filtered_methods.append(m) |
| 601 | 587 |
| 602 if filtered_methods: | 588 if filtered_methods: |
| 603 filtered_class = dict(c) | 589 filtered_class = dict(c) |
| 604 filtered_class['methods'] = filtered_methods | 590 filtered_class['methods'] = filtered_methods |
| 605 filtered_classes.append(filtered_class) | 591 filtered_classes.append(filtered_class) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 def GenerateTestResults( | 642 def GenerateTestResults( |
| 657 result_code, result_bundle, statuses, start_ms, duration_ms): | 643 result_code, result_bundle, statuses, start_ms, duration_ms): |
| 658 return GenerateTestResults(result_code, result_bundle, statuses, | 644 return GenerateTestResults(result_code, result_bundle, statuses, |
| 659 start_ms, duration_ms) | 645 start_ms, duration_ms) |
| 660 | 646 |
| 661 #override | 647 #override |
| 662 def TearDown(self): | 648 def TearDown(self): |
| 663 if self._isolate_delegate: | 649 if self._isolate_delegate: |
| 664 self._isolate_delegate.Clear() | 650 self._isolate_delegate.Clear() |
| 665 | 651 |
| OLD | NEW |