Commit 5315399b authored by Ben Joyce's avatar Ben Joyce Committed by Commit Bot

Create device and host reports for html.

CQ bots generate an html report using this script and we won't know if
the developer needs the host or device report, so generate both.

BUG: 1116208
Change-Id: Idd2a841c495b87d6f382acb1771b9f2842908508
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2355571Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarYuke Liao <liaoyuke@chromium.org>
Commit-Queue: benjamin joyce <bjoyce@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798193}
parent 7ebef132
...@@ -61,18 +61,19 @@ def _CreateClassfileArgs(class_files, exclude_suffix=None): ...@@ -61,18 +61,19 @@ def _CreateClassfileArgs(class_files, exclude_suffix=None):
return result_class_files return result_class_files
def _GenerateReportOutputArgs(args, class_files): def _GenerateReportOutputArgs(args, class_files, report_type):
class_jar_exclude = None class_jar_exclude = None
if args.device_or_host == 'device': if report_type == 'device':
class_jar_exclude = _DEVICE_CLASS_EXCLUDE_SUFFIX class_jar_exclude = _DEVICE_CLASS_EXCLUDE_SUFFIX
elif args.device_or_host == 'host': elif report_type == 'host':
class_jar_exclude = _HOST_CLASS_EXCLUDE_SUFFIX class_jar_exclude = _HOST_CLASS_EXCLUDE_SUFFIX
cmd = _CreateClassfileArgs(class_files, class_jar_exclude) cmd = _CreateClassfileArgs(class_files, class_jar_exclude)
if args.format == 'html': if args.format == 'html':
if not os.path.exists(args.output_dir): report_dir = os.path.join(args.output_dir, report_type)
os.makedirs(args.output_dir) if not os.path.exists(report_dir):
cmd += ['--html', args.output_dir] os.makedirs(report_dir)
cmd += ['--html', report_dir]
elif args.format == 'xml': elif args.format == 'xml':
cmd += ['--xml', args.output_file] cmd += ['--xml', args.output_file]
elif args.format == 'csv': elif args.format == 'csv':
...@@ -118,7 +119,8 @@ def _ParseArguments(parser): ...@@ -118,7 +119,8 @@ def _ParseArguments(parser):
choices=['device', 'host'], choices=['device', 'host'],
help='Selection on whether to use the device classpath files or the ' help='Selection on whether to use the device classpath files or the '
'host classpath files. Host would typically be used for junit tests ' 'host classpath files. Host would typically be used for junit tests '
' and device for tests that run on the device.') ' and device for tests that run on the device. Only used for xml and csv'
' reports.')
parser.add_argument('--output-dir', help='html report output directory.') parser.add_argument('--output-dir', help='html report output directory.')
parser.add_argument('--output-file', parser.add_argument('--output-file',
help='xml file to write device coverage results.') help='xml file to write device coverage results.')
...@@ -152,17 +154,16 @@ def _ParseArguments(parser): ...@@ -152,17 +154,16 @@ def _ParseArguments(parser):
'runtime.') 'runtime.')
args = parser.parse_args() args = parser.parse_args()
if args.format in ('csv', 'html'): if args.format == 'html' and not args.output_dir:
if not args.output_dir: parser.error('--output-dir needed for report.')
parser.error('--output-dir needed for report.') if args.format in ('csv', 'xml'):
if args.format == 'xml' and not args.output_file: if not args.output_file:
parser.error(('--output-junit-coverage-file/--output-device-coverage-file ' parser.error('--output-file needed for xml/csv reports.')
'needed for xml/csv reports.')) if not args.device_or_host and args.sources_json_dir:
parser.error('--device-or-host selection needed with --sources-json-dir')
if not (args.sources_json_dir or args.class_files): if not (args.sources_json_dir or args.class_files):
parser.error('At least either --sources-json-dir or --class-files needed.') parser.error('At least either --sources-json-dir or --class-files needed.')
if not args.device_or_host and args.sources_json_dir:
parser.error('--device-or-host selection needed with --sources-json-dir')
return args return args
...@@ -213,8 +214,18 @@ def main(): ...@@ -213,8 +214,18 @@ def main():
for source in fixed_source_dirs: for source in fixed_source_dirs:
cmd += ['--sourcefiles', source] cmd += ['--sourcefiles', source]
cmd = cmd + _GenerateReportOutputArgs(args, class_files) if args.format == 'html':
exit_code = cmd_helper.RunCmd(cmd) # Both reports are generated for html as the cq bot generates an html
# report and we wouldn't know which one a developer needed.
device_cmd = cmd + _GenerateReportOutputArgs(args, class_files, 'device')
host_cmd = cmd + _GenerateReportOutputArgs(args, class_files, 'host')
device_exit_code = cmd_helper.RunCmd(device_cmd)
host_exit_code = cmd_helper.RunCmd(host_cmd)
exit_code = device_exit_code or host_exit_code
else:
cmd = cmd + _GenerateReportOutputArgs(args, class_files,
args.device_or_host)
exit_code = cmd_helper.RunCmd(cmd)
if args.cleanup: if args.cleanup:
for f in coverage_files: for f in coverage_files:
......
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