# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import os import sys from functools import partial
from mach.decorators import Command, CommandArgument, SubCommand from mozbuild.base import MachCommandConditions as conditions
@Command( "perftest",
category="testing",
conditions=[partial(conditions.is_buildapp_in, apps=["firefox", "android"])],
description="Run any flavor of perftest",
parser=get_perftest_parser,
) def run_perftest(command_context, **kwargs): # original parser that brought us there
original_parser = get_parser()
from mozperftest.script import ParseError, ScriptInfo, ScriptType
# Refer people to the --help command if they are lost ifnot kwargs["tests"] or kwargs["tests"] == ["help"]:
print("No test selected!\n")
print("See `./mach perftest --help` for more info\n") return
if len(kwargs["tests"]) > 1:
print("\nSorry no support yet for multiple local perftest") return
# if the script is xpcshell, we can force the flavor here # XXX on multi-selection, what happens if we have several flavors? try:
script_info = ScriptInfo(kwargs["tests"][0]) except ParseError as e: if e.exception is IsADirectoryError:
script_info = None else: raise else: if script_info.script_type == ScriptType.xpcshell:
kwargs["flavor"] = script_info.script_type.name elif script_info.script_type == ScriptType.alert:
kwargs["flavor"] = script_info.script_type.name elif script_info.script_type == ScriptType.eval_mochitest:
kwargs["flavor"] = "eval-mochitest" elif"flavor"notin kwargs: # we set the value only if not provided (so "mobile-browser" # can be picked)
kwargs["flavor"] = "desktop-browser"
# running pytest with coverage # coverage is done in three steps: # 1/ coverage erase => erase any previous coverage data # 2/ coverage run pytest ... => run the tests and collect info # 3/ coverage report => generate the report
tests_dir = Path(HERE, "tests").resolve()
tests = kwargs.get("tests", []) if tests == []:
tests = str(tests_dir)
run_coverage_check = not skip_linters else:
run_coverage_check = False
def _get_test(test): if Path(test).exists(): return str(test) return str(tests_dir / test)
tests = " ".join([_get_test(test) for test in tests])
# on macOS + try we skip the coverage # because macOS workers prevent us from installing # packages from PyPI if sys.platform == "darwin"and ON_TRY:
run_coverage_check = False
options = "-xs" if kwargs.get("verbose"):
options += "v"
# If we run mozperftest with the --raptor argument, # then only run the raptor unit tests if kwargs.get("raptor"):
run_coverage_check = True
tests = str(Path(command_context.topsrcdir, "testing", "raptor", "test"))
if run_coverage_check: assert checkout_python_script(
venv, "coverage", ["erase"], label="remove old coverage data"
)
ifnot paths: try: from mozversioncontrol import get_repository_object
vcs = get_repository_object(str(topsrcdir))
changed = set(vcs.get_changed_files("AM", mode="all"))
changed.update(vcs.get_outgoing_files("AM")) # The "AM" filter is applied per commit, so a file modified in # one commit and deleted in a later one is still captured. Keep # only the paths that still exist, otherwise run_perfdocs errors # trying to lint a deleted file.
paths = [str(topsrcdir / p) for p in changed if (topsrcdir / p).exists()] except Exception as e:
logger.info(f"Failed to get modified files: {e}")
if output_file: with open(output_file, "w", encoding="utf-8") as fh:
json.dump(dict(logger.issues) or {}, fh)
if failed:
logger.critical("[TEST-UNEXPECTED-ERROR] Perfdocs need to be regenerated.") return1 return0
@Command( "perftest-tools",
category="testing",
description="Run perftest tools",
) def run_tools(command_context, **kwargs): """
Runs various perftest tools such as the side-by-side generator. """
print("Runs various perftest tools such as the side-by-side generator.")
@SubCommand( "perftest-tools", "side-by-side",
description="This tool can be used to generate a side-by-side visualization of two videos. " "When using this tool, make sure that the `--test-name` is an exact match, i.e. if you are " "comparing the task `test-linux64-shippable-qr/opt-browsertime-tp6-firefox-linkedin-e10s` " "between two revisions, then use `browsertime-tp6-firefox-linkedin-e10s` as the suite name " "and `test-linux64-shippable-qr/opt` as the platform.",
parser=get_perftest_tools_parser("side-by-side"),
) def run_side_by_side(command_context, **kwargs): from mozperftest.runner import run_tools
@SubCommand( "perftest-tools", "change-detector",
description="This tool can be used to determine if there are differences between two " "revisions. It can do either direct comparisons, or searching for regressions in between " "two revisions (with a maximum or autocomputed depth).",
parser=get_perftest_tools_parser("change-detector"),
) def run_change_detector(command_context, **kwargs): from mozperftest.runner import run_tools
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.