Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: tools/telemetry/telemetry/results/results_options.py

Issue 430383003: Have all --output-format produces progress report (in gtest-style). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/telemetry/telemetry/results/progress_reporter.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import optparse 5 import optparse
6 import os 6 import os
7 import sys 7 import sys
8 8
9 from telemetry.core import util 9 from telemetry.core import util
10 from telemetry.page import page_measurement
11 from telemetry.results import buildbot_output_formatter 10 from telemetry.results import buildbot_output_formatter
12 from telemetry.results import csv_output_formatter 11 from telemetry.results import csv_output_formatter
13 from telemetry.results import gtest_test_results 12 from telemetry.results import gtest_progress_reporter
14 from telemetry.results import html_output_formatter 13 from telemetry.results import html_output_formatter
15 from telemetry.results import json_output_formatter 14 from telemetry.results import json_output_formatter
16 from telemetry.results import page_test_results 15 from telemetry.results import page_test_results
17 16
18 17
19 # Allowed output formats. The default is the first item in the list. 18 # Allowed output formats. The default is the first item in the list.
20 _OUTPUT_FORMAT_CHOICES = ('html', 'buildbot', 'block', 'csv', 'gtest', 19 _OUTPUT_FORMAT_CHOICES = ('html', 'buildbot', 'block', 'csv', 'gtest',
21 'json', 'none') 20 'json', 'none')
22 21
23 22
(...skipping 14 matching lines...) Expand all
38 help='Delete all stored results.') 37 help='Delete all stored results.')
39 group.add_option('--upload-results', action='store_true', 38 group.add_option('--upload-results', action='store_true',
40 help='Upload the results to cloud storage.') 39 help='Upload the results to cloud storage.')
41 group.add_option('--results-label', 40 group.add_option('--results-label',
42 default=None, 41 default=None,
43 help='Optional label to use for the results of a run .') 42 help='Optional label to use for the results of a run .')
44 parser.add_option_group(group) 43 parser.add_option_group(group)
45 44
46 45
47 def PrepareResults(test, options): 46 def PrepareResults(test, options):
48 if not isinstance(test, page_measurement.PageMeasurement):
49 # Sort of hacky. The default for non-Measurements should be "gtest."
50 if options.output_format != 'none':
51 options.output_format = 'gtest'
52
53 # TODO(chrishenry): This logic prevents us from having multiple 47 # TODO(chrishenry): This logic prevents us from having multiple
54 # OutputFormatters. We should have an output_file per OutputFormatter. 48 # OutputFormatters. We should have an output_file per OutputFormatter.
55 # Maybe we should have --output-dir instead of --output-file? 49 # Maybe we should have --output-dir instead of --output-file?
56 if options.output_format == 'html' and not options.output_file: 50 if options.output_format == 'html' and not options.output_file:
57 options.output_file = os.path.join(util.GetBaseDir(), 'results.html') 51 options.output_file = os.path.join(util.GetBaseDir(), 'results.html')
58 52
59 if hasattr(options, 'output_file') and options.output_file: 53 if hasattr(options, 'output_file') and options.output_file:
60 output_file = os.path.expanduser(options.output_file) 54 output_file = os.path.expanduser(options.output_file)
61 open(output_file, 'a').close() # Create file if it doesn't exist. 55 open(output_file, 'a').close() # Create file if it doesn't exist.
62 output_stream = open(output_file, 'r+') 56 output_stream = open(output_file, 'r+')
63 else: 57 else:
64 output_stream = sys.stdout 58 output_stream = sys.stdout
65 if not hasattr(options, 'output_format'): 59 if not hasattr(options, 'output_format'):
66 options.output_format = _OUTPUT_FORMAT_CHOICES[0] 60 options.output_format = _OUTPUT_FORMAT_CHOICES[0]
67 if not hasattr(options, 'output_trace_tag'): 61 if not hasattr(options, 'output_trace_tag'):
68 options.output_trace_tag = '' 62 options.output_trace_tag = ''
69 63
70 output_formatters = [] 64 output_formatters = []
65 output_skipped_tests_summary = True
71 if options.output_format == 'none': 66 if options.output_format == 'none':
72 pass 67 pass
73 elif options.output_format == 'csv': 68 elif options.output_format == 'csv':
74 output_formatters.append(csv_output_formatter.CsvOutputFormatter( 69 output_formatters.append(csv_output_formatter.CsvOutputFormatter(
75 output_stream)) 70 output_stream))
76 elif options.output_format == 'buildbot': 71 elif options.output_format == 'buildbot':
77 output_formatters.append(buildbot_output_formatter.BuildbotOutputFormatter( 72 output_formatters.append(buildbot_output_formatter.BuildbotOutputFormatter(
78 output_stream, trace_tag=options.output_trace_tag)) 73 output_stream, trace_tag=options.output_trace_tag))
79 elif options.output_format == 'gtest': 74 elif options.output_format == 'gtest':
80 return gtest_test_results.GTestTestResults(output_stream) 75 # TODO(chrishenry): This is here to not change the output of
76 # gtest. Let's try enabling skipped tests summary for gtest test
77 # results too (in a separate patch), and see if we break anything.
78 output_skipped_tests_summary = False
81 elif options.output_format == 'html': 79 elif options.output_format == 'html':
82 # TODO(chrishenry): We show buildbot output so that users can grep 80 # TODO(chrishenry): We show buildbot output so that users can grep
83 # through the results easily without needing to open the html 81 # through the results easily without needing to open the html
84 # file. Another option for this is to output the results directly 82 # file. Another option for this is to output the results directly
85 # in gtest-style results (via some sort of progress reporter), 83 # in gtest-style results (via some sort of progress reporter),
86 # as we plan to enable gtest-style output for all output formatters. 84 # as we plan to enable gtest-style output for all output formatters.
87 output_formatters.append(buildbot_output_formatter.BuildbotOutputFormatter( 85 output_formatters.append(buildbot_output_formatter.BuildbotOutputFormatter(
88 sys.stdout, trace_tag=options.output_trace_tag)) 86 sys.stdout, trace_tag=options.output_trace_tag))
89 output_formatters.append(html_output_formatter.HtmlOutputFormatter( 87 output_formatters.append(html_output_formatter.HtmlOutputFormatter(
90 output_stream, test.__class__.__name__, options.reset_results, 88 output_stream, test.__class__.__name__, options.reset_results,
91 options.upload_results, options.browser_type, 89 options.upload_results, options.browser_type,
92 options.results_label, trace_tag=options.output_trace_tag)) 90 options.results_label, trace_tag=options.output_trace_tag))
93 elif options.output_format == 'json': 91 elif options.output_format == 'json':
94 output_formatters.append(json_output_formatter.JsonOutputFormatter( 92 output_formatters.append(json_output_formatter.JsonOutputFormatter(
95 output_stream)) 93 output_stream))
96 else: 94 else:
97 # Should never be reached. The parser enforces the choices. 95 # Should never be reached. The parser enforces the choices.
98 raise Exception('Invalid --output-format "%s". Valid choices are: %s' 96 raise Exception('Invalid --output-format "%s". Valid choices are: %s'
99 % (options.output_format, 97 % (options.output_format,
100 ', '.join(_OUTPUT_FORMAT_CHOICES))) 98 ', '.join(_OUTPUT_FORMAT_CHOICES)))
101 99
102 return page_test_results.PageTestResults(output_formatters=output_formatters) 100 reporter = gtest_progress_reporter.GTestProgressReporter(
101 sys.stdout, output_skipped_tests_summary=output_skipped_tests_summary)
102 return page_test_results.PageTestResults(
103 output_formatters=output_formatters, progress_reporter=reporter)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/results/progress_reporter.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698