Add directory option for JUnit coverage files.
Added runtime option --coverage-dir to let the users decide where to store coverage.ec. BUG=608072 Review-Url: https://codereview.chromium.org/1965013008 Cr-Original-Commit-Position: refs/heads/master@{#394470} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: e16476a8c069b9646370f75d71cad6cdc9c491e8
This commit is contained in:
Родитель
3a019f01a4
Коммит
a4fab917cf
|
@ -25,6 +25,7 @@ script_template = """\
|
|||
#
|
||||
# This file was generated by build/android/gyp/create_java_binary_script.py
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -37,13 +38,29 @@ if os.getcwd() != self_dir:
|
|||
classpath = [os.path.join(offset, p) for p in classpath]
|
||||
bootclasspath = [os.path.join(offset, p) for p in bootclasspath]
|
||||
java_cmd = ["java"]
|
||||
# This is a simple argparser for jvm and jar arguments.
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--jar-args')
|
||||
parser.add_argument('--jvm-args')
|
||||
|
||||
known_args, unknown_args = parser.parse_known_args(sys.argv[1:])
|
||||
if known_args.jvm_args:
|
||||
jvm_arguments = known_args.jvm_args.strip('"').split()
|
||||
java_cmd.extend(jvm_arguments)
|
||||
if known_args.jar_args:
|
||||
jar_arguments = known_args.jar_args.strip('"').split()
|
||||
if unknown_args:
|
||||
raise Exception('There are unknown arguments')
|
||||
else:
|
||||
jar_arguments = unknown_args
|
||||
|
||||
{noverify_flag}
|
||||
if bootclasspath:
|
||||
java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath))
|
||||
java_cmd.extend(
|
||||
["-classpath", ":".join(classpath), "-enableassertions", \"{main_class}\"])
|
||||
java_cmd.extend(extra_program_args)
|
||||
java_cmd.extend(sys.argv[1:])
|
||||
java_cmd.extend(jar_arguments)
|
||||
os.execvp("java", java_cmd)
|
||||
"""
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ class JavaTestRunner(object):
|
|||
"""Runs java tests on the host."""
|
||||
|
||||
def __init__(self, args):
|
||||
self._coverage_dir = args.coverage_dir
|
||||
self._package_filter = args.package_filter
|
||||
self._runner_filter = args.runner_filter
|
||||
self._sdk_version = args.sdk_version
|
||||
|
@ -28,17 +29,28 @@ class JavaTestRunner(object):
|
|||
with tempfile.NamedTemporaryFile() as json_file:
|
||||
java_script = os.path.join(
|
||||
constants.GetOutDirectory(), 'bin', 'helper', self._test_suite)
|
||||
command = [java_script,
|
||||
'-test-jars', self._test_suite + '.jar',
|
||||
'-json-results-file', json_file.name]
|
||||
command = [java_script]
|
||||
|
||||
# Add Jar arguments.
|
||||
jar_args = ['-test-jars', self._test_suite + '.jar',
|
||||
'-json-results-file', json_file.name]
|
||||
if self._test_filter:
|
||||
command.extend(['-gtest-filter', self._test_filter])
|
||||
jar_args.extend(['-gtest-filter', self._test_filter])
|
||||
if self._package_filter:
|
||||
command.extend(['-package-filter', self._package_filter])
|
||||
jar_args.extend(['-package-filter', self._package_filter])
|
||||
if self._runner_filter:
|
||||
command.extend(['-runner-filter', self._runner_filter])
|
||||
jar_args.extend(['-runner-filter', self._runner_filter])
|
||||
if self._sdk_version:
|
||||
command.extend(['-sdk-version', self._sdk_version])
|
||||
jar_args.extend(['-sdk-version', self._sdk_version])
|
||||
command.extend(['--jar-args', '"%s"' % ' '.join(jar_args)])
|
||||
|
||||
# Add JVM arguments.
|
||||
jvm_args = []
|
||||
if self._coverage_dir:
|
||||
jvm_args.append('-Demma.coverage.out.file=%s' % self._coverage_dir)
|
||||
if jvm_args:
|
||||
command.extend(['--jvm-args', '"%s"' % ' '.join(jvm_args)])
|
||||
|
||||
return_code = cmd_helper.RunCmd(command)
|
||||
results_list = json_results.ParseResultsFromJson(
|
||||
json.loads(json_file.read()))
|
||||
|
|
|
@ -459,6 +459,9 @@ def AddJUnitTestOptions(parser):
|
|||
group.add_argument(
|
||||
'--sdk-version', dest='sdk_version', type=int,
|
||||
help='The Android SDK version.')
|
||||
group.add_argument(
|
||||
'--coverage-dir', dest='coverage_dir',
|
||||
help='Directory to store coverage info.')
|
||||
AddCommonOptions(parser)
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче