| Index: build/android/pylib/results/presentation/test_results_presentation.py
|
| diff --git a/build/android/pylib/results/presentation/test_results_presentation.py b/build/android/pylib/results/presentation/test_results_presentation.py
|
| index cb51590e3cf7878eec9f2321351fb2a51a3dc938..218f2aee0893463a0b7a3f01de37cf3e3ea24e96 100755
|
| --- a/build/android/pylib/results/presentation/test_results_presentation.py
|
| +++ b/build/android/pylib/results/presentation/test_results_presentation.py
|
| @@ -275,11 +275,15 @@ def feedback_url(result_details_link):
|
|
|
|
|
| def results_to_html(results_dict, cs_base_url, bucket, test_name,
|
| - builder_name, build_number):
|
| - """Convert list of test results into html format."""
|
| + builder_name, build_number, local_output):
|
| + """Convert list of test results into html format.
|
|
|
| - test_rows_header, test_rows = create_test_table(results_dict, cs_base_url,
|
| - test_name)
|
| + Args:
|
| + local_output: Whether this results file is uploaded to Google Storage or
|
| + just a local file.
|
| + """
|
| + test_rows_header, test_rows = create_test_table(
|
| + results_dict, cs_base_url, test_name)
|
| suite_rows_header, suite_rows, suite_row_footer = create_suite_table(
|
| results_dict)
|
|
|
| @@ -298,21 +302,34 @@ def results_to_html(results_dict, cs_base_url, bucket, test_name,
|
|
|
| main_template = JINJA_ENVIRONMENT.get_template(
|
| os.path.join('template', 'main.html'))
|
| - dest = google_storage_helper.unique_name(
|
| - '%s_%s_%s' % (test_name, builder_name, build_number))
|
| -
|
| - result_details_link = google_storage_helper.get_url_link(
|
| - dest, '%s/html' % bucket)
|
| -
|
| - return (main_template.render( # pylint: disable=no-member
|
| - {'tb_values': [suite_table_values, test_table_values],
|
| - 'feedback_url': feedback_url(result_details_link)
|
| - }), dest, result_details_link)
|
|
|
| + if local_output:
|
| + html_render = main_template.render( # pylint: disable=no-member
|
| + {
|
| + 'tb_values': [suite_table_values, test_table_values]
|
| + })
|
| + return (html_render, None, None)
|
| + else:
|
| + dest = google_storage_helper.unique_name(
|
| + '%s_%s_%s' % (test_name, builder_name, build_number))
|
| + result_details_link = google_storage_helper.get_url_link(
|
| + dest, '%s/html' % bucket)
|
| + html_render = main_template.render( # pylint: disable=no-member
|
| + {
|
| + 'tb_values': [suite_table_values, test_table_values],
|
| + 'feedback_url': feedback_url(result_details_link),
|
| + })
|
| + return (html_render, dest, result_details_link)
|
| +
|
| +
|
| +def result_details(json_path, test_name, cs_base_url, bucket=None,
|
| + builder_name=None, build_number=None, local_output=False):
|
| + """Get result details from json path and then convert results to html.
|
|
|
| -def result_details(json_path, cs_base_url, bucket, test_name,
|
| - builder_name, build_number):
|
| - """Get result details from json path and then convert results to html."""
|
| + Args:
|
| + local_output: Whether this results file is uploaded to Google Storage or
|
| + just a local file.
|
| + """
|
|
|
| with open(json_path) as json_file:
|
| json_object = json.loads(json_file.read())
|
| @@ -324,8 +341,8 @@ def result_details(json_path, cs_base_url, bucket, test_name,
|
| for testsuite_run in json_object['per_iteration_data']:
|
| for test, test_runs in testsuite_run.iteritems():
|
| results_dict[test].extend(test_runs)
|
| - return results_to_html(results_dict, cs_base_url, bucket,
|
| - test_name, builder_name, build_number)
|
| + return results_to_html(results_dict, cs_base_url, bucket, test_name,
|
| + builder_name, build_number, local_output)
|
|
|
|
|
| def upload_to_google_bucket(html, bucket, dest):
|
| @@ -352,18 +369,18 @@ def main():
|
| required=True)
|
| parser.add_argument(
|
| '-o', '--output-json',
|
| - help='(Swarming Merge Script API)'
|
| - ' Output JSON file to create.')
|
| + help='(Swarming Merge Script API) '
|
| + 'Output JSON file to create.')
|
| parser.add_argument(
|
| '--build-properties',
|
| help='(Swarming Merge Script API) '
|
| 'Build property JSON file provided by recipes.')
|
| parser.add_argument(
|
| '--summary-json',
|
| - help='(Swarming Merge Script API)'
|
| - ' Summary of shard state running on swarming.'
|
| - ' (Output of the swarming.py collect'
|
| - ' --task-summary-json=XXX command.)')
|
| + help='(Swarming Merge Script API) '
|
| + 'Summary of shard state running on swarming. '
|
| + '(Output of the swarming.py collect '
|
| + '--task-summary-json=XXX command.)')
|
| parser.add_argument(
|
| 'positional', nargs='*',
|
| help='output.json from shards.')
|
| @@ -420,13 +437,12 @@ def main():
|
|
|
| # Link to result details presentation page is a part of the page.
|
| result_html_string, dest, result_details_link = result_details(
|
| - json_file, args.cs_base_url, args.bucket,
|
| - args.test_name, builder_name, build_number)
|
| + json_file, args.test_name, args.cs_base_url, args.bucket,
|
| + builder_name, build_number)
|
|
|
| result_details_link_2 = upload_to_google_bucket(
|
| result_html_string.encode('UTF-8'),
|
| args.bucket, dest)
|
| -
|
| assert result_details_link == result_details_link_2, (
|
| 'Result details link do not match. The link returned by get_url_link'
|
| ' should be the same as that returned by upload.')
|
|
|