Commit 071f7c48 authored by hzl's avatar hzl Committed by Commit bot

Enable emma code coverage for JUnit testcases.

After setting emma_coverage as true, and then run JUnit testcases, code
coverage information will be stored in coverage.ec. In order to read
coverage.ec file, you will need to find the corresponding <name>.em file
in out-gn/Debug and then merge the .em and .ec file into a txt or html.

BUG=604900

Review URL: https://codereview.chromium.org/1913593002

Cr-Commit-Position: refs/heads/master@{#389902}
parent fbc7e83c
...@@ -37,6 +37,7 @@ if os.getcwd() != self_dir: ...@@ -37,6 +37,7 @@ if os.getcwd() != self_dir:
classpath = [os.path.join(offset, p) for p in classpath] classpath = [os.path.join(offset, p) for p in classpath]
bootclasspath = [os.path.join(offset, p) for p in bootclasspath] bootclasspath = [os.path.join(offset, p) for p in bootclasspath]
java_cmd = ["java"] java_cmd = ["java"]
{noverify_flag}
if bootclasspath: if bootclasspath:
java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath)) java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath))
java_cmd.extend( java_cmd.extend(
...@@ -58,8 +59,16 @@ def main(argv): ...@@ -58,8 +59,16 @@ def main(argv):
help='Classpath for running the jar.') help='Classpath for running the jar.')
parser.add_option('--bootclasspath', action='append', default=[], parser.add_option('--bootclasspath', action='append', default=[],
help='zip/jar files to add to bootclasspath for java cmd.') help='zip/jar files to add to bootclasspath for java cmd.')
parser.add_option('--noverify', action='store_true',
help='JVM flag: noverify.')
options, extra_program_args = parser.parse_args(argv) options, extra_program_args = parser.parse_args(argv)
if (options.noverify):
noverify_flag = 'java_cmd.append("-noverify")'
else:
noverify_flag = ''
classpath = [options.jar_path] classpath = [options.jar_path]
for cp_arg in options.classpath: for cp_arg in options.classpath:
classpath += build_utils.ParseGypList(cp_arg) classpath += build_utils.ParseGypList(cp_arg)
...@@ -78,7 +87,8 @@ def main(argv): ...@@ -78,7 +87,8 @@ def main(argv):
bootclasspath=('"%s"' % '", "'.join(bootclasspath) bootclasspath=('"%s"' % '", "'.join(bootclasspath)
if bootclasspath else ''), if bootclasspath else ''),
main_class=options.main_class, main_class=options.main_class,
extra_program_args=repr(extra_program_args))) extra_program_args=repr(extra_program_args),
noverify_flag=noverify_flag))
os.chmod(options.output, 0750) os.chmod(options.output, 0750)
......
...@@ -240,6 +240,15 @@ template("java_binary_script") { ...@@ -240,6 +240,15 @@ template("java_binary_script") {
"--main-class", "--main-class",
_main_class, _main_class,
] ]
if (emma_coverage) {
args += [
"--classpath",
rebase_path(
"//third_party/android_tools_internal/sdk/tools/lib/emma.jar",
root_build_dir),
]
args += [ "--noverify" ]
}
if (defined(invoker.wrapper_script_args)) { if (defined(invoker.wrapper_script_args)) {
args += [ "--" ] + invoker.wrapper_script_args args += [ "--" ] + invoker.wrapper_script_args
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment