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

Unified Diff: telemetry/telemetry/internal/results/chart_json_output_formatter.py

Issue 2342023005: Outputting chart json for disabled tests. (Closed)
Patch Set: Setting arg explicitly Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/internal/results/chart_json_output_formatter_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/internal/results/chart_json_output_formatter.py
diff --git a/telemetry/telemetry/internal/results/chart_json_output_formatter.py b/telemetry/telemetry/internal/results/chart_json_output_formatter.py
index 9d95415720f09c00b5cf8278aa65a449956f23f0..6a84be1c428d963fc22e8534b871133a184ed7aa 100644
--- a/telemetry/telemetry/internal/results/chart_json_output_formatter.py
+++ b/telemetry/telemetry/internal/results/chart_json_output_formatter.py
@@ -68,20 +68,47 @@ def ResultsAsChartDict(benchmark_metadata, page_specific_values,
'trace_rerun_options': benchmark_metadata.rerun_options,
'benchmark_metadata': benchmark_metadata.AsDict(),
'charts': charts,
+ # Need to add this in for compatibility with disabled chartjson results.
+ 'enabled': True
}
return result_dict
+
+def DisabledResultsDict(benchmark_name):
+ """Produces a dict for serialization to Chart JSON when a benchmark is
+ disabled.
+
+ Args:
+ benchmark_name: name of the disabled benchmark
+
+ Returns:
+ A Chart JSON dict corresponding to a disabled benchmark.
+ """
+ result_dict = {
+ 'benchmark_name': benchmark_name,
+ 'enabled': False
+ }
+
+ return result_dict
+
+
# TODO(eakuefner): Transition this to translate Telemetry JSON.
class ChartJsonOutputFormatter(output_formatter.OutputFormatter):
def __init__(self, output_stream, benchmark_metadata):
super(ChartJsonOutputFormatter, self).__init__(output_stream)
self._benchmark_metadata = benchmark_metadata
+ def FormatDisabled(self):
+ self._Dump(DisabledResultsDict(self._benchmark_metadata.name))
+
def Format(self, page_test_results):
- json.dump(ResultsAsChartDict(
- self._benchmark_metadata,
- page_test_results.all_page_specific_values,
- page_test_results.all_summary_values),
- self.output_stream, indent=2)
+ self._Dump(ResultsAsChartDict(
+ self._benchmark_metadata,
+ page_test_results.all_page_specific_values,
+ page_test_results.all_summary_values))
+
+ def _Dump(self, results):
+ json.dump(results, self.output_stream, indent=2,
+ separators=(',', ': '))
self.output_stream.write('\n')
« no previous file with comments | « no previous file | telemetry/telemetry/internal/results/chart_json_output_formatter_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698