Bug 1750976 - Add ability to provide custom browsertime arguments. r=perftest-reviewers,kshampur

This patch adds the ability to provide custom browsertime arguments through the command line option `--browsertime-arg`. It is used like so:

`
./mach raptor --browsertime -t browsertime --browsertime-arg test_script=/home/sparky/mozilla-source/mozilla-central/testing/raptor/browsertime/browsertime_pageload.js --browsertime-arg browsertime.url=https://www.sitespeed.io --browsertime-arg iterations=3
`

Differential Revision: https://phabricator.services.mozilla.com/D144166
This commit is contained in:
Gregory Mierzwinski 2022-04-21 18:05:52 +00:00
parent e2273932cb
commit 3b88452e0b
3 changed files with 31 additions and 0 deletions

View File

@ -156,6 +156,16 @@ class Raptor(
"help": argparse.SUPPRESS,
},
],
[
["--browsertime-arg"],
{
"action": "append",
"metavar": "PREF=VALUE",
"dest": "browsertime_user_args",
"default": [],
"help": argparse.SUPPRESS,
},
],
[
["--browsertime"],
{
@ -657,6 +667,7 @@ class Raptor(
self.firefox_android_browsers = ["fennec", "geckoview", "refbrow", "fenix"]
self.android_browsers = self.firefox_android_browsers + ["chrome-m"]
self.browsertime_visualmetrics = self.config.get("browsertime_visualmetrics")
self.browsertime_user_args = self.config.get("browsertime_user_args")
self.browsertime_video = False
self.enable_marionette_trace = self.config.get("enable_marionette_trace")
self.browser_cycles = self.config.get("browser_cycles")
@ -953,6 +964,9 @@ class Raptor(
if value and arg not in self.config.get("raptor_cmd_line_args", []):
if isinstance(value, string_types):
options.extend([arg, os.path.expandvars(value)])
elif isinstance(value, (tuple, list)):
for val in value:
options.extend([arg, val])
else:
options.extend([arg])

View File

@ -42,6 +42,7 @@ class Browsertime(Perftest):
def __init__(self, app, binary, process_handler=None, **kwargs):
self.browsertime = True
self.browsertime_failure = ""
self.browsertime_user_args = []
self.process_handler = process_handler or mozprocess.ProcessHandler
for key in list(kwargs):
@ -71,6 +72,7 @@ class Browsertime(Perftest):
"browsertime_ffmpeg",
"browsertime_geckodriver",
"browsertime_chromedriver",
"browsertime_user_args",
):
try:
if not self.browsertime_video and k == "browsertime_ffmpeg":
@ -389,6 +391,12 @@ class Browsertime(Perftest):
if value is not None:
priority1_options.extend([browser_time_option, str(value)])
# Add any user-specified flags here, let them override anything
# with no restrictions
for user_arg in self.browsertime_user_args:
arg, val = user_arg.split("=")
priority1_options.extend([f"--{arg}", val])
# In this code block we check if any priority 1 arguments are in conflict with a
# priority 2/3/4 argument
MULTI_OPTS = [

View File

@ -366,6 +366,15 @@ def create_parser(mach_interface=False):
action="store_true",
help="Whether to use browsertime to execute pageload tests",
)
add_arg(
"--browsertime-arg",
dest="browsertime_user_args",
action="append",
default=[],
metavar="OPTION=VALUE",
help="Add extra browsertime arguments to your test run using "
"this option e.g.: --browsertime-arg timeout.scripts=1000",
)
add_arg(
"--browsertime-node", dest="browsertime_node", help="path to Node.js executable"
)