3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 """Runs both the Python and Java tests."""
12 from pylib
import apk_info
13 from pylib
import test_options_parser
14 from pylib
import run_java_tests
15 from pylib
import run_python_tests
16 from pylib
import run_tests_helper
17 from pylib
.test_result
import TestResults
20 def SummarizeResults(java_results
, python_results
, annotation
, build_type
):
21 """Summarize the results from the various test types.
24 java_results: a TestResults object with java test case results.
25 python_results: a TestResults object with python test case results.
26 annotation: the annotation used for these results.
27 build_type: 'Release' or 'Debug'.
30 A tuple (all_results, summary_string, num_failing)
32 all_results
= TestResults
.FromTestResults([java_results
, python_results
])
33 summary_string
= all_results
.LogFull('Instrumentation', annotation
,
35 num_failing
= (len(all_results
.failed
) + len(all_results
.crashed
) +
36 len(all_results
.unknown
))
37 return all_results
, summary_string
, num_failing
40 def DispatchInstrumentationTests(options
):
41 """Dispatches the Java and Python instrumentation tests, sharding if possible.
43 Uses the logging module to print the combined final results and
44 summary of the Java and Python tests. If the java_only option is set, only
45 the Java tests run. If the python_only option is set, only the python tests
46 run. If neither are set, run both Java and Python tests.
49 options: command-line options for running the Java and Python tests.
52 An integer representing the number of failing tests.
54 start_date
= int(time
.time() * 1000)
55 java_results
= TestResults()
56 python_results
= TestResults()
58 if options
.run_java_tests
:
59 java_results
= run_java_tests
.DispatchJavaTests(
61 [apk_info
.ApkInfo(options
.test_apk_path
, options
.test_apk_jar_path
)])
62 if options
.run_python_tests
:
63 python_results
= run_python_tests
.DispatchPythonTests(options
)
65 all_results
, summary_string
, num_failing
= SummarizeResults(
66 java_results
, python_results
, options
.annotation
, options
.build_type
)
71 options
= test_options_parser
.ParseInstrumentationArgs(argv
)
72 run_tests_helper
.SetLogLevel(options
.verbose_count
)
73 return DispatchInstrumentationTests(options
)
76 if __name__
== '__main__':
77 sys
.exit(main(sys
.argv
))