diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-12 13:59:53 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-12 13:59:53 +0000 |
commit | a0c1fa879609e996816d6844215ae007f42a300c (patch) | |
tree | decae525b8387a75014755cf8c533286379fc445 /build/android/pylib/tests_annotations.py | |
parent | 361b9e8cf474ddad4f0bf5716c0804801a0ad633 (diff) | |
download | chromium_src-a0c1fa879609e996816d6844215ae007f42a300c.zip chromium_src-a0c1fa879609e996816d6844215ae007f42a300c.tar.gz chromium_src-a0c1fa879609e996816d6844215ae007f42a300c.tar.bz2 |
Android: adds instrumentation test runners.
Part of upstreaming build/android, this adds the instrumentation
test runners to allow us to run java-based tests.
BUG=136688
TEST=
Review URL: https://chromiumcodereview.appspot.com/10703165
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/android/pylib/tests_annotations.py')
-rw-r--r-- | build/android/pylib/tests_annotations.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/build/android/pylib/tests_annotations.py b/build/android/pylib/tests_annotations.py new file mode 100644 index 0000000..f2a1834 --- /dev/null +++ b/build/android/pylib/tests_annotations.py @@ -0,0 +1,89 @@ +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Annotations for python-driven tests.""" + +import os + + +class AnnotatedFunctions(object): + """A container for annotated methods.""" + _ANNOTATED = {} + + @staticmethod + def _AddFunction(annotation, function): + """Adds an annotated to function to our container. + + Args: + annotation: the annotation string. + function: the function. + Returns: + The function passed in. + """ + module_name = os.path.splitext(os.path.basename( + function.__globals__['__file__']))[0] + qualified_function_name = '.'.join([module_name, function.func_name]) + function_list = AnnotatedFunctions._ANNOTATED.get(annotation, []) + function_list.append(qualified_function_name) + AnnotatedFunctions._ANNOTATED[annotation] = function_list + return function + + @staticmethod + def IsAnnotated(annotation, qualified_function_name): + """True if function name (module.function) contains the annotation. + + Args: + annotation: the annotation string. + qualified_function_name: the qualified function name. + Returns: + True if module.function contains the annotation. + """ + return qualified_function_name in AnnotatedFunctions._ANNOTATED.get( + annotation, []) + + @staticmethod + def GetTestAnnotations(qualified_function_name): + """Returns a list containing all annotations for the given function. + + Args: + qualified_function_name: the qualified function name. + Returns: + List of all annotations for this function. + """ + return [annotation + for annotation, tests in AnnotatedFunctions._ANNOTATED.iteritems() + if qualified_function_name in tests] + + +# The following functions are annotations used for the python driven tests. +def Smoke(function): + return AnnotatedFunctions._AddFunction('Smoke', function) + + +def SmallTest(function): + return AnnotatedFunctions._AddFunction('SmallTest', function) + + +def MediumTest(function): + return AnnotatedFunctions._AddFunction('MediumTest', function) + + +def LargeTest(function): + return AnnotatedFunctions._AddFunction('LargeTest', function) + + +def FlakyTest(function): + return AnnotatedFunctions._AddFunction('FlakyTest', function) + + +def DisabledTest(function): + return AnnotatedFunctions._AddFunction('DisabledTest', function) + + +def Feature(feature_list): + def _AddFeatures(function): + for feature in feature_list: + AnnotatedFunctions._AddFunction('Feature' + feature, function) + return AnnotatedFunctions._AddFunction('Feature', function) + return _AddFeatures |