Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | # |
michael@0 | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
michael@0 | 4 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | # found in the LICENSE file. |
michael@0 | 6 | |
michael@0 | 7 | """Runs both the Python and Java tests.""" |
michael@0 | 8 | |
michael@0 | 9 | import optparse |
michael@0 | 10 | import sys |
michael@0 | 11 | import time |
michael@0 | 12 | |
michael@0 | 13 | from pylib import apk_info |
michael@0 | 14 | from pylib import buildbot_report |
michael@0 | 15 | from pylib import ports |
michael@0 | 16 | from pylib import run_java_tests |
michael@0 | 17 | from pylib import run_python_tests |
michael@0 | 18 | from pylib import run_tests_helper |
michael@0 | 19 | from pylib import test_options_parser |
michael@0 | 20 | from pylib.test_result import TestResults |
michael@0 | 21 | |
michael@0 | 22 | |
michael@0 | 23 | def SummarizeResults(java_results, python_results, annotation, build_type): |
michael@0 | 24 | """Summarize the results from the various test types. |
michael@0 | 25 | |
michael@0 | 26 | Args: |
michael@0 | 27 | java_results: a TestResults object with java test case results. |
michael@0 | 28 | python_results: a TestResults object with python test case results. |
michael@0 | 29 | annotation: the annotation used for these results. |
michael@0 | 30 | build_type: 'Release' or 'Debug'. |
michael@0 | 31 | |
michael@0 | 32 | Returns: |
michael@0 | 33 | A tuple (all_results, summary_string, num_failing) |
michael@0 | 34 | """ |
michael@0 | 35 | all_results = TestResults.FromTestResults([java_results, python_results]) |
michael@0 | 36 | summary_string = all_results.LogFull('Instrumentation', annotation, |
michael@0 | 37 | build_type) |
michael@0 | 38 | num_failing = (len(all_results.failed) + len(all_results.crashed) + |
michael@0 | 39 | len(all_results.unknown)) |
michael@0 | 40 | return all_results, summary_string, num_failing |
michael@0 | 41 | |
michael@0 | 42 | |
michael@0 | 43 | def DispatchInstrumentationTests(options): |
michael@0 | 44 | """Dispatches the Java and Python instrumentation tests, sharding if possible. |
michael@0 | 45 | |
michael@0 | 46 | Uses the logging module to print the combined final results and |
michael@0 | 47 | summary of the Java and Python tests. If the java_only option is set, only |
michael@0 | 48 | the Java tests run. If the python_only option is set, only the python tests |
michael@0 | 49 | run. If neither are set, run both Java and Python tests. |
michael@0 | 50 | |
michael@0 | 51 | Args: |
michael@0 | 52 | options: command-line options for running the Java and Python tests. |
michael@0 | 53 | |
michael@0 | 54 | Returns: |
michael@0 | 55 | An integer representing the number of failing tests. |
michael@0 | 56 | """ |
michael@0 | 57 | # Reset the test port allocation. It's important to do it before starting |
michael@0 | 58 | # to dispatch any tests. |
michael@0 | 59 | if not ports.ResetTestServerPortAllocation(): |
michael@0 | 60 | raise Exception('Failed to reset test server port.') |
michael@0 | 61 | start_date = int(time.time() * 1000) |
michael@0 | 62 | java_results = TestResults() |
michael@0 | 63 | python_results = TestResults() |
michael@0 | 64 | |
michael@0 | 65 | if options.run_java_tests: |
michael@0 | 66 | java_results = run_java_tests.DispatchJavaTests( |
michael@0 | 67 | options, |
michael@0 | 68 | [apk_info.ApkInfo(options.test_apk_path, options.test_apk_jar_path)]) |
michael@0 | 69 | if options.run_python_tests: |
michael@0 | 70 | python_results = run_python_tests.DispatchPythonTests(options) |
michael@0 | 71 | |
michael@0 | 72 | all_results, summary_string, num_failing = SummarizeResults( |
michael@0 | 73 | java_results, python_results, options.annotation, options.build_type) |
michael@0 | 74 | return num_failing |
michael@0 | 75 | |
michael@0 | 76 | |
michael@0 | 77 | def main(argv): |
michael@0 | 78 | option_parser = optparse.OptionParser() |
michael@0 | 79 | test_options_parser.AddInstrumentationOptions(option_parser) |
michael@0 | 80 | options, args = option_parser.parse_args(argv) |
michael@0 | 81 | test_options_parser.ValidateInstrumentationOptions(option_parser, options, |
michael@0 | 82 | args) |
michael@0 | 83 | |
michael@0 | 84 | run_tests_helper.SetLogLevel(options.verbose_count) |
michael@0 | 85 | buildbot_report.PrintNamedStep( |
michael@0 | 86 | 'Instrumentation tests: %s - %s' % (', '.join(options.annotation), |
michael@0 | 87 | options.test_apk)) |
michael@0 | 88 | return DispatchInstrumentationTests(options) |
michael@0 | 89 | |
michael@0 | 90 | |
michael@0 | 91 | if __name__ == '__main__': |
michael@0 | 92 | sys.exit(main(sys.argv)) |