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/run_instrumentation_tests.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/run_instrumentation_tests.py')
-rwxr-xr-x | build/android/run_instrumentation_tests.py | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/build/android/run_instrumentation_tests.py b/build/android/run_instrumentation_tests.py new file mode 100755 index 0000000..1a6e099 --- /dev/null +++ b/build/android/run_instrumentation_tests.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# 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. + +"""Runs both the Python and Java tests.""" + +import sys +import time + +from pylib import apk_info +from pylib import test_options_parser +from pylib import run_java_tests +from pylib import run_python_tests +from pylib import run_tests_helper +from pylib.test_result import TestResults + + +def SummarizeResults(java_results, python_results, annotation): + """Summarize the results from the various test types. + + Args: + java_results: a TestResults object with java test case results. + python_results: a TestResults object with python test case results. + annotation: the annotation used for these results. + + Returns: + A tuple (all_results, summary_string, num_failing) + """ + all_results = TestResults.FromTestResults([java_results, python_results]) + summary_string = all_results.LogFull('Instrumentation', annotation) + num_failing = (len(all_results.failed) + len(all_results.crashed) + + len(all_results.unknown)) + return all_results, summary_string, num_failing + + +def DispatchInstrumentationTests(options): + """Dispatches the Java and Python instrumentation tests, sharding if possible. + + Uses the logging module to print the combined final results and + summary of the Java and Python tests. If the java_only option is set, only + the Java tests run. If the python_only option is set, only the python tests + run. If neither are set, run both Java and Python tests. + + Args: + options: command-line options for running the Java and Python tests. + + Returns: + An integer representing the number of failing tests. + """ + start_date = int(time.time() * 1000) + java_results = TestResults() + python_results = TestResults() + + if options.run_java_tests: + java_results = run_java_tests.DispatchJavaTests( + options, + [apk_info.ApkInfo(options.test_apk_path, options.test_apk_jar_path)]) + if options.run_python_tests: + python_results = run_python_tests.DispatchPythonTests(options) + + all_results, summary_string, num_failing = SummarizeResults( + java_results, python_results, options.annotation) + return num_failing + + +def main(argv): + options = test_options_parser.ParseInstrumentationArgs(argv) + run_tests_helper.SetLogLevel(options.verbose_count) + return DispatchInstrumentationTests(options) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) |