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

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

Issue 411143003: Add an "in_unit_test_mode" attribute to the environment. Use this to default output format to 'gtes… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New approach (a wrapper script). 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 | « content/test/gpu/run_gpu_test ('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 block_page_measurement_results 10 from telemetry.results import block_page_measurement_results
12 from telemetry.results import buildbot_page_measurement_results 11 from telemetry.results import buildbot_page_measurement_results
13 from telemetry.results import csv_page_measurement_results 12 from telemetry.results import csv_page_measurement_results
14 from telemetry.results import gtest_test_results 13 from telemetry.results import gtest_test_results
15 from telemetry.results import html_page_measurement_results 14 from telemetry.results import html_page_measurement_results
16 from telemetry.results import page_measurement_results 15 from telemetry.results import page_measurement_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', 'none') 19 _OUTPUT_FORMAT_CHOICES = ('html', 'buildbot', 'block', 'csv', 'gtest', 'none')
(...skipping 16 matching lines...) Expand all
37 help='Delete all stored results.') 36 help='Delete all stored results.')
38 group.add_option('--upload-results', action='store_true', 37 group.add_option('--upload-results', action='store_true',
39 help='Upload the results to cloud storage.') 38 help='Upload the results to cloud storage.')
40 group.add_option('--results-label', 39 group.add_option('--results-label',
41 default=None, 40 default=None,
42 help='Optional label to use for the results of a run .') 41 help='Optional label to use for the results of a run .')
43 parser.add_option_group(group) 42 parser.add_option_group(group)
44 43
45 44
46 def PrepareResults(test, options): 45 def PrepareResults(test, options):
47 if not isinstance(test, page_measurement.PageMeasurement):
48 # Sort of hacky. The default for non-Measurements should be "gtest."
49 if options.output_format != 'none':
50 options.output_format = 'gtest'
51
52 if options.output_format == 'html' and not options.output_file: 46 if options.output_format == 'html' and not options.output_file:
53 options.output_file = os.path.join(util.GetBaseDir(), 'results.html') 47 options.output_file = os.path.join(util.GetBaseDir(), 'results.html')
54 48
55 if hasattr(options, 'output_file') and options.output_file: 49 if hasattr(options, 'output_file') and options.output_file:
56 output_file = os.path.expanduser(options.output_file) 50 output_file = os.path.expanduser(options.output_file)
57 open(output_file, 'a').close() # Create file if it doesn't exist. 51 open(output_file, 'a').close() # Create file if it doesn't exist.
58 output_stream = open(output_file, 'r+') 52 output_stream = open(output_file, 'r+')
59 else: 53 else:
60 output_stream = sys.stdout 54 output_stream = sys.stdout
61 if not hasattr(options, 'output_format'): 55 if not hasattr(options, 'output_format'):
(...skipping 18 matching lines...) Expand all
80 elif options.output_format == 'html': 74 elif options.output_format == 'html':
81 return html_page_measurement_results.HtmlPageMeasurementResults( 75 return html_page_measurement_results.HtmlPageMeasurementResults(
82 output_stream, test.__class__.__name__, options.reset_results, 76 output_stream, test.__class__.__name__, options.reset_results,
83 options.upload_results, options.browser_type, 77 options.upload_results, options.browser_type,
84 options.results_label, trace_tag=options.output_trace_tag) 78 options.results_label, trace_tag=options.output_trace_tag)
85 else: 79 else:
86 # Should never be reached. The parser enforces the choices. 80 # Should never be reached. The parser enforces the choices.
87 raise Exception('Invalid --output-format "%s". Valid choices are: %s' 81 raise Exception('Invalid --output-format "%s". Valid choices are: %s'
88 % (options.output_format, 82 % (options.output_format,
89 ', '.join(_OUTPUT_FORMAT_CHOICES))) 83 ', '.join(_OUTPUT_FORMAT_CHOICES)))
OLDNEW
« no previous file with comments | « content/test/gpu/run_gpu_test ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698