Commit df6a24aa authored by Mikhail Khokhlov's avatar Mikhail Khokhlov Committed by Commit Bot

[tools/perf] Remove support for legacy formats

Results Processor now handles all output formats, so we can remove
the arguments that were used to pass some formats to Telemetry.

Bug: 981349
Change-Id: Ibf6d12a7a1814b31c11d566f607f063694ab3f38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901028
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Reviewed-by: default avatarJuan Antonio Navarro Pérez <perezju@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713413}
parent 923cfb10
......@@ -15,8 +15,7 @@ from telemetry import command_line
def main(config, args=None):
results_arg_parser = results_processor.ArgumentParser(
legacy_formats=command_line.LEGACY_OUTPUT_FORMATS)
results_arg_parser = results_processor.ArgumentParser()
options = command_line.ParseArgs(
environment=config, args=args, results_arg_parser=results_arg_parser)
results_processor.ProcessOptions(options)
......
......@@ -19,19 +19,15 @@ from py_utils import cloud_storage
from core.results_processor import formatters
# These formats are always handled natively, and never handed over to Telemetry.
HANDLED_NATIVELY = ['none', 'json-test-results', 'histograms', 'html', 'csv']
TELEMETRY_TEST_PATH_FORMAT = 'telemetry'
GTEST_TEST_PATH_FORMAT = 'gtest'
def ArgumentParser(standalone=False, legacy_formats=None):
def ArgumentParser(standalone=False):
"""Create an ArgumentParser defining options required by the processor."""
if standalone:
all_output_formats = formatters.FORMATTERS.keys()
else:
all_output_formats = sorted(
set(HANDLED_NATIVELY).union(legacy_formats or ()))
if not standalone:
all_output_formats.append('none')
parser, group = _CreateTopLevelParser(standalone)
parser.add_argument(
'-v', '--verbose', action='count', dest='verbosity',
......@@ -42,7 +38,7 @@ def ArgumentParser(standalone=False, legacy_formats=None):
help=Sentences(
'Output format to produce.',
'May be used multiple times to produce multiple outputs.',
'Avaliable formats: %s.' % ', '.join(all_output_formats),
'Avaliable formats: %(choices)s.',
'' if standalone else 'Defaults to: html.'))
group.add_argument(
'--intermediate-dir', metavar='DIR_PATH', required=standalone,
......@@ -89,7 +85,7 @@ def ArgumentParser(standalone=False, legacy_formats=None):
return parser
def ProcessOptions(options, standalone=False):
def ProcessOptions(options):
"""Adjust result processing options as needed before running benchmarks.
Note: The intended scope of this function is limited to only adjust options
......@@ -102,8 +98,6 @@ def ProcessOptions(options, standalone=False):
Args:
options: An options object with values parsed from the command line.
standalone: Whether this is a standalone Results Processor run (as
opposed to the run with Telemetry).
"""
if options.verbosity >= 2:
logging.getLogger().setLevel(logging.DEBUG)
......@@ -140,19 +134,10 @@ def ProcessOptions(options, standalone=False):
else:
options.upload_bucket = None
if options.output_formats:
chosen_formats = sorted(set(options.output_formats))
else:
chosen_formats = ['html']
options.output_formats = []
for output_format in chosen_formats:
if output_format == 'none':
continue
elif standalone or output_format in HANDLED_NATIVELY:
options.output_formats.append(output_format)
else:
options.legacy_output_formats.append(output_format)
if not options.output_formats:
options.output_formats = ['html']
elif 'none' in options.output_formats:
options.output_formats.remove('none')
def _CreateTopLevelParser(standalone):
......
......@@ -17,7 +17,6 @@ import unittest
import mock
from core.results_processor import command_line
from core.results_processor import formatters
# To easily mock module level symbols within the command_line module.
......@@ -27,7 +26,6 @@ def module(symbol):
class ProcessOptionsTestCase(unittest.TestCase):
def setUp(self):
self.legacy_formats = []
self.standalone = False
# Mock os module within results_processor so path manipulations do not
......@@ -53,8 +51,7 @@ class ProcessOptionsTestCase(unittest.TestCase):
mock.patch.stopall()
def ParseArgs(self, args):
parser = command_line.ArgumentParser(
standalone=self.standalone, legacy_formats=self.legacy_formats)
parser = command_line.ArgumentParser(standalone=self.standalone)
options = parser.parse_args(args)
command_line.ProcessOptions(options)
return options
......@@ -132,23 +129,6 @@ class TestProcessOptions(ProcessOptionsTestCase):
with self.assertRaises(SystemExit):
self.ParseArgs(['--output-format', 'unknown'])
@mock.patch(module('HANDLED_NATIVELY'), ['new-format'])
def testOutputFormatsSplit(self):
self.legacy_formats = ['old-format']
options = self.ParseArgs(
['--output-format', 'new-format', '--output-format', 'old-format'])
self.assertEqual(options.output_formats, ['new-format'])
self.assertEqual(options.legacy_output_formats, ['old-format'])
@mock.patch(module('HANDLED_NATIVELY'), ['new-format'])
def testNoDuplicateOutputFormats(self):
self.legacy_formats = ['old-format']
options = self.ParseArgs(
['--output-format', 'new-format', '--output-format', 'old-format',
'--output-format', 'new-format', '--output-format', 'old-format'])
self.assertEqual(options.output_formats, ['new-format'])
self.assertEqual(options.legacy_output_formats, ['old-format'])
class StandaloneTestProcessOptions(ProcessOptionsTestCase):
def setUp(self):
......@@ -170,11 +150,3 @@ class StandaloneTestProcessOptions(ProcessOptionsTestCase):
self.assertEqual(options.output_formats, ['json-test-results'])
self.assertEqual(options.intermediate_dir, '/path/to/curdir/some_dir')
self.assertEqual(options.output_dir, '/path/to/output_dir')
class TestNativelyHandledFormats(unittest.TestCase):
def testNativelyHandledFormatsHaveFormatters(self):
for output_format in command_line.HANDLED_NATIVELY:
if output_format == 'none':
continue
self.assertIn(output_format, formatters.FORMATTERS)
......@@ -323,5 +323,5 @@ def main(args=None):
"""Entry point for the standalone version of the results_processor script."""
parser = command_line.ArgumentParser(standalone=True)
options = parser.parse_args(args)
command_line.ProcessOptions(options, standalone=True)
command_line.ProcessOptions(options)
return ProcessResults(options)
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