Bug 1635930 - Activate a layer when its options are used. r=sparky,tarek

Differential Revision: https://phabricator.services.mozilla.com/D83551
This commit is contained in:
Yue Zhang 2020-07-31 17:23:51 +00:00
Родитель 9f220fdcc4
Коммит 210c0b2307
2 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -126,3 +126,19 @@ class PerftestArgumentParser(ArgumentParser):
self.add_argument(name, **options)
mozlog.commandline.add_logging_group(self)
def parse_helper(self, args):
for arg in args:
arg_part = arg.partition("--")[-1].partition("-")
layer_name = f"--{arg_part[0]}"
layer_exists = arg_part[1] and layer_name in Options.args
if layer_exists:
args.append(layer_name)
def parse_args(self, args=None, namespace=None):
self.parse_helper(args)
return super().parse_args(args, namespace)
def parse_known_args(self, args=None, namespace=None):
self.parse_helper(args)
return super().parse_known_args(args, namespace)

Просмотреть файл

@ -23,6 +23,16 @@ def test_options():
)
def test_layer_option():
parser = PerftestArgumentParser()
assert parser.parse_args(["--notebook-metrics"]) == parser.parse_args(
["--notebook-metrics", "--notebook"]
)
assert parser.parse_known_args(["--notebook-metrics"]) == parser.parse_known_args(
["--notebook-metrics", "--notebook"]
)
def test_bad_test_date():
parser = PerftestArgumentParser()
args = ["test_one.js", "--test-date", "bleh"]