Chromium Code Reviews| Index: build/android/pylib/instrumentation/instrumentation_test_instance.py |
| diff --git a/build/android/pylib/instrumentation/instrumentation_test_instance.py b/build/android/pylib/instrumentation/instrumentation_test_instance.py |
| index f0b7cab24868cce3943d33e82e639bdad6e46438..140b1f5261cc038b0cf7e2acb8b97eaee6dd86fe 100644 |
| --- a/build/android/pylib/instrumentation/instrumentation_test_instance.py |
| +++ b/build/android/pylib/instrumentation/instrumentation_test_instance.py |
| @@ -33,6 +33,8 @@ _DEFAULT_ANNOTATIONS = [ |
| 'EnormousTest', 'IntegrationTest'] |
| _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS = [ |
| 'DisabledTest', 'FlakyTest'] |
| +_VALID_ANNOTATIONS = set(['Manual'] + _DEFAULT_ANNOTATIONS + |
| + _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS) |
| _EXTRA_DRIVER_TEST_LIST = ( |
| 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestList') |
| _EXTRA_DRIVER_TEST_LIST_FILE = ( |
| @@ -50,6 +52,13 @@ _NATIVE_CRASH_RE = re.compile('native crash', re.IGNORECASE) |
| _PICKLE_FORMAT_VERSION = 10 |
| +class MissingSizeAnnotationError(Exception): |
| + def __init__(self, class_name): |
| + super(MissingSizeAnnotationError, self).__init__(class_name + |
| + ': Test method is missing required size annotation. Add one of: ' + |
| + ', '.join('@' + a for a in _VALID_ANNOTATIONS)) |
| + |
| + |
| # TODO(jbudorick): Make these private class methods of |
| # InstrumentationTestInstance once the instrumentation test_runner is |
| # deprecated. |
| @@ -554,7 +563,7 @@ class InstrumentationTestInstance(test_instance.TestInstance): |
| return unittest_util.FilterTestNames(names, self._test_filter) |
| def annotation_filter(all_annotations): |
| - if not self._annotations: |
| + if not self._annotations or not all_annotations: |
|
jbudorick
2016/04/29 00:38:34
Can `not all_annotations` ever be true here?
agrieve
2016/04/29 19:26:02
Whoops, meant to revert that part! Done.
|
| return True |
| return any_annotation_matches(self._annotations, all_annotations) |
| @@ -579,6 +588,11 @@ class InstrumentationTestInstance(test_instance.TestInstance): |
| all_annotations = dict(c['annotations']) |
| all_annotations.update(m['annotations']) |
| + |
| + # Enforce that all tests declare their size. |
| + if not any(a in _VALID_ANNOTATIONS for a in all_annotations): |
| + raise MissingSizeAnnotationError('%s.%s' % (c['class'], m['method'])) |
| + |
| if (not annotation_filter(all_annotations) |
| or not excluded_annotation_filter(all_annotations)): |
| continue |