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/test_options_parser.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/test_options_parser.py')
-rw-r--r-- | build/android/pylib/test_options_parser.py | 80 |
1 files changed, 77 insertions, 3 deletions
diff --git a/build/android/pylib/test_options_parser.py b/build/android/pylib/test_options_parser.py index 4b4deec..97e4580 100644 --- a/build/android/pylib/test_options_parser.py +++ b/build/android/pylib/test_options_parser.py @@ -4,8 +4,10 @@ """Parses options for the instrumentation tests.""" -import os +import constants import optparse +import os + def CreateTestRunnerOptionParser(usage=None, default_timeout=60): @@ -17,8 +19,7 @@ def CreateTestRunnerOptionParser(usage=None, default_timeout=60): default=default_timeout) option_parser.add_option('-c', dest='cleanup_test_files', help='Cleanup test files on the device after run', - action='store_true', - default=False) + action='store_true') option_parser.add_option('-v', '--verbose', dest='verbose_count', @@ -37,3 +38,76 @@ def CreateTestRunnerOptionParser(usage=None, default_timeout=60): help='Run the test under a tool ' '(use --tool help to list them)') return option_parser + + +def ParseInstrumentationArgs(args): + """Parse arguments and return options with defaults.""" + + option_parser = CreateTestRunnerOptionParser() + option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger', + action='store_true', help='Wait for debugger.') + option_parser.add_option('-I', dest='install_apk', help='Install APK.', + action='store_true') + option_parser.add_option('-f', '--test_filter', + help='Test filter (if not fully qualified, ' + 'will run all matches).') + option_parser.add_option('-A', '--annotation', dest='annotation_str', + help=('Run only tests with any of the given ' + 'annotations. ' + 'An annotation can be either a key or a ' + 'key-values pair. ' + 'A test that has no annotation is ' + 'considered "SmallTest".')) + option_parser.add_option('-j', '--java_only', action='store_true', + help='Run only the Java tests.') + option_parser.add_option('-p', '--python_only', action='store_true', + help='Run only the Python tests.') + option_parser.add_option('-n', '--run_count', type='int', + dest='number_of_runs', default=1, + help=('How many times to run each test, regardless ' + 'of the result. (Default is 1)')) + option_parser.add_option('--test-apk', dest='test_apk', + help=('The name of the apk containing the tests ' + '(without the .apk extension).')) + option_parser.add_option('--screenshot', dest='screenshot_failures', + action='store_true', + help='Capture screenshots of test failures') + option_parser.add_option('--save-perf-json', action='store_true', + help='Saves the JSON file for each UI Perf test.') + option_parser.add_option('--shard_retries', type=int, default=1, + help=('Number of times to retry each failure when ' + 'sharding.')) + option_parser.add_option('--official-build', help='Run official build tests.') + option_parser.add_option('--device', + help='Serial number of device we should use.') + option_parser.add_option('--python_test_root', + help='Root of the python-driven tests.') + + options, args = option_parser.parse_args(args) + if len(args) > 1: + option_parser.error('Unknown argument:', args[1:]) + if options.java_only and options.python_only: + option_parser.error('Options java_only (-j) and python_only (-p) ' + 'are mutually exclusive') + + options.run_java_tests = True + options.run_python_tests = True + if options.java_only: + options.run_python_tests = False + elif options.python_only: + options.run_java_tests = False + + options.test_apk_path = os.path.join(constants.CHROME_DIR, + 'out', 'Release', + '%s.apk' % options.test_apk) + options.test_apk_jar_path = os.path.join(constants.CHROME_DIR, + 'out', 'Release', + '%s.jar' % options.test_apk) + if options.annotation_str: + options.annotation = options.annotation_str.split() + elif options.test_filter: + options.annotation = [] + else: + options.annotation = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] + + return options |