Fail if an instrumentation test is missing size annotation

Right now we just silently never run such tests.

BUG=601464

Review-Url: https://codereview.chromium.org/1863353002
Cr-Original-Commit-Position: refs/heads/master@{#391288}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 70d776ed260e4c48a4f4a92903030f1e578ef291
This commit is contained in:
agrieve 2016-05-03 10:55:04 -07:00 коммит произвёл Commit bot
Родитель a454f1d368
Коммит e5b0ef5932
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -33,6 +33,8 @@ _DEFAULT_ANNOTATIONS = [
'EnormousTest', 'IntegrationTest']
_EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS = [
'DisabledTest', 'FlakyTest']
_VALID_ANNOTATIONS = set(['Manual', 'PerfTest'] + _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.
@ -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