Commit 455d9a08 authored by Alex Lopez's avatar Alex Lopez
Browse files

Bug 1696251 - Pass MachCommandBase object as first argument for Mach Commands....

Bug 1696251 - Pass MachCommandBase object as first argument for Mach Commands. r=mhentges,remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers

As an intermediate step to allow mach commands as standalone functions, the MachCommandBase
subclass instance that currently corresponds to self has to be made available as a separate
argument (named command_context).

Differential Revision: https://phabricator.services.mozilla.com/D109650
parent 5992e823
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ class MachCommands(MachCommandBase):
        "--suppression multiple times to specify multiple suppression "
        "files.",
    )
    def valgrind_test(self, suppressions):
    def valgrind_test(self, command_context, suppressions):

        from mozfile import TemporaryDirectory
        from mozhttpd import MozHttpd
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class MachCommands(MachCommandBase):
        category="post-build",
        description="Rebuild the devtool's static css properties database.",
    )
    def generate_css_db(self):
    def generate_css_db(self, command_context):
        """Generate the static css properties database for devtools and write it to file."""

        print("Re-generating the css properties database...")
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class WebIDLProvider(MachCommandBase):
    @CommandArgument(
        "interface", nargs="+", help="Interface(s) whose examples to generate."
    )
    def webidl_example(self, interface):
    def webidl_example(self, command_context, interface):
        from mozwebidlcodegen import BuildSystemWebIDL

        manager = self._spawn(BuildSystemWebIDL).manager
@@ -46,7 +46,7 @@ class WebIDLProvider(MachCommandBase):
        parser=get_test_parser,
        description="Run WebIDL tests (Interface Browser parser).",
    )
    def webidl_test(self, **kwargs):
    def webidl_test(self, command_context, **kwargs):
        sys.path.insert(0, os.path.join(self.topsrcdir, "other-licenses", "ply"))

        # Ensure the topobjdir exists. On a Taskcluster test run there won't be
+7 −7
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ class MachCommands(MachCommandBase):
        order="declaration",
        description="Commands for running the static analysis for GC rooting hazards",
    )
    def hazards(self):
    def hazards(self, command_context):
        """Commands related to performing the GC rooting hazard analysis"""
        print("See `mach hazards --help` for a list of subcommands")

@@ -121,7 +121,7 @@ class MachCommands(MachCommandBase):
        "bootstrap",
        description="Install prerequisites for the hazard analysis",
    )
    def bootstrap(self, **kwargs):
    def bootstrap(self, command_context, **kwargs):
        orig_dir = os.getcwd()
        os.chdir(self.ensure_dir_exists(self.tools_dir))
        try:
@@ -142,7 +142,7 @@ class MachCommands(MachCommandBase):
        metavar="FILENAME",
        help="Build with the given mozconfig.",
    )
    def build_shell(self, **kwargs):
    def build_shell(self, command_context, **kwargs):
        """Build a JS shell to use to run the rooting hazard analysis."""
        # The JS shell requires some specific configuration settings to execute
        # the hazard analysis code, and configuration is done via mozconfig.
@@ -215,7 +215,7 @@ no shell found in %s -- must build the JS shell with `mach hazards build-shell`
    @CommandArgument(
        "--work-dir", default=None, help="Directory for output and working files."
    )
    def gather_hazard_data(self, **kwargs):
    def gather_hazard_data(self, command_context, **kwargs):
        """Gather analysis information by compiling the tree"""
        application = kwargs["application"]
        objdir = kwargs["haz_objdir"]
@@ -279,7 +279,7 @@ no shell found in %s -- must build the JS shell with `mach hazards build-shell`
        default=os.environ.get("HAZ_OBJDIR"),
        help="Write object files to this directory.",
    )
    def inner_compile(self, **kwargs):
    def inner_compile(self, command_context, **kwargs):
        """Build a source tree and gather analysis information while running
        under the influence of the analysis collection server."""

@@ -346,7 +346,7 @@ no shell found in %s -- must build the JS shell with `mach hazards build-shell`
    @CommandArgument(
        "--work-dir", default=None, help="Directory for output and working files."
    )
    def analyze(self, application, shell_objdir, work_dir):
    def analyze(self, command_context, application, shell_objdir, work_dir):
        """Analyzed gathered data for rooting hazards"""

        shell = self.ensure_shell(shell_objdir)
@@ -374,7 +374,7 @@ no shell found in %s -- must build the JS shell with `mach hazards build-shell`
        default=None,
        help="objdir containing the optimized JS shell for running the analysis.",
    )
    def self_test(self, shell_objdir):
    def self_test(self, command_context, shell_objdir):
        """Analyzed gathered data for rooting hazards"""
        shell = self.ensure_shell(shell_objdir)
        args = [
+3 −3
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ class MachCommands(MachCommandBase):
        description="Run reftests (layout and graphics correctness).",
        parser=get_parser,
    )
    def run_reftest(self, **kwargs):
    def run_reftest(self, command_context, **kwargs):
        kwargs["suite"] = "reftest"
        return self._run_reftest(**kwargs)

@@ -246,7 +246,7 @@ class MachCommands(MachCommandBase):
        description="Run js/src/tests in the browser.",
        parser=get_parser,
    )
    def run_jstestbrowser(self, **kwargs):
    def run_jstestbrowser(self, command_context, **kwargs):
        if "--enable-js-shell" not in self.mozconfig["configure_args"]:
            raise Exception(
                "jstestbrowser requires --enable-js-shell be specified in mozconfig."
@@ -263,7 +263,7 @@ class MachCommands(MachCommandBase):
        description="Run crashtests (Check if crashes on a page).",
        parser=get_parser,
    )
    def run_crashtest(self, **kwargs):
    def run_crashtest(self, command_context, **kwargs):
        kwargs["suite"] = "crashtest"
        return self._run_reftest(**kwargs)

Loading