diff --git a/testing/web-platform/mach_commands.py b/testing/web-platform/mach_commands.py index 3190c5d28823..3889689d1bbc 100644 --- a/testing/web-platform/mach_commands.py +++ b/testing/web-platform/mach_commands.py @@ -129,7 +129,11 @@ class WebPlatformTestsRunnerSetup(MozbuildObject): class WebPlatformTestsUpdater(MozbuildObject): """Update web platform tests.""" - def run_update(self, **kwargs): + def setup_logging(self, **kwargs): + import update + return update.setup_logging(kwargs, {"mach": sys.stdout}) + + def run_update(self, logger, **kwargs): import update from update import updatecommandline @@ -141,7 +145,6 @@ class WebPlatformTestsUpdater(MozbuildObject): kwargs["store_state"] = False kwargs = updatecommandline.check_args(kwargs) - logger = update.setup_logging(kwargs, {"mach": sys.stdout}) try: update.run_update(logger, **kwargs) @@ -269,24 +272,26 @@ testing/web-platform/tests for tests that may be shared if proc: proc.wait() - context.commands.dispatch("wpt-manifest-update", context) - class WPTManifestUpdater(MozbuildObject): - def run_update(self, rebuild=False, **kwargs): - import manifestupdate + def setup_logging(self, **kwargs): from wptrunner import wptlogging logger = wptlogging.setup(kwargs, {"mach": sys.stdout}) + + def run_update(self, logger, rebuild=False, **kwargs): + import manifestupdate wpt_dir = os.path.abspath(os.path.join(self.topsrcdir, 'testing', 'web-platform')) config_dir = os.path.abspath(os.path.join(self.topobjdir, '_tests', 'web-platform')) manifestupdate.update(logger, wpt_dir, rebuild, config_dir) class WPTManifestDownloader(MozbuildObject): - def run_download(self, manifest_update=True, force=False, **kwargs): - import manifestdownload + def setup_logging(self, **kwargs): from wptrunner import wptlogging logger = wptlogging.setup(kwargs, {"mach": sys.stdout}) + + def run_download(self, logger, manifest_update=True, force=False, **kwargs): + import manifestdownload wpt_dir = os.path.abspath(os.path.join(self.topobjdir, '_tests', 'web-platform')) manifestdownload.run(wpt_dir, self.topsrcdir, logger, force, manifest_update) @@ -347,11 +352,14 @@ class MachCommands(MachCommandBase): params["include"].append(item["name"]) del params["test_objects"] - self.wpt_manifest_download(**params) - params["manifest_update"] = False wpt_setup = self._spawn(WebPlatformTestsRunnerSetup) wpt_runner = WebPlatformTestsRunner(wpt_setup) - return wpt_runner.run(**params) + + logger = wpt_runner.setup_logging(**params) + + self.wpt_manifest_download(logger, **params) + params["manifest_update"] = False + return wpt_runner.run(logger, **params) @Command("wpt", category="testing", @@ -368,8 +376,10 @@ class MachCommands(MachCommandBase): self.virtualenv_manager.install_pip_package('html5lib==1.0.1') self.virtualenv_manager.install_pip_package('ujson') self.virtualenv_manager.install_pip_package('requests') + wpt_updater = self._spawn(WebPlatformTestsUpdater) - return wpt_updater.run_update(**params) + logger = wpt_updater.setup_logging(**params) + return wpt_updater.run_update(logger, **params) @Command("wpt-update", category="testing", @@ -398,12 +408,17 @@ class MachCommands(MachCommandBase): self.setup() self.wpt_manifest_download(**params) wpt_manifest_updater = self._spawn(WPTManifestUpdater) - return wpt_manifest_updater.run_update(**params) + logger = wpt_manifest_updater.setup_logging(**params) + self.wpt_manifest_download(logger, **params) + return wpt_manifest_updater.run_update(logger, **params) @Command("wpt-manifest-download", category="testing", parser=create_parser_manifest_download) - def wpt_manifest_download(self, **params): + def wpt_manifest_download(self, logger=None, **params): self.setup() + if logger is None: + from wptrunner import wptlogging + logger = wptlogging.setup(params, {"mach": sys.stdout}) wpt_manifest_downloader = self._spawn(WPTManifestDownloader) - return wpt_manifest_downloader.run_download(**params) + return wpt_manifest_downloader.run_download(logger, **params) diff --git a/testing/web-platform/mach_commands_base.py b/testing/web-platform/mach_commands_base.py index ee339d480d01..34644b09bf6c 100644 --- a/testing/web-platform/mach_commands_base.py +++ b/testing/web-platform/mach_commands_base.py @@ -16,7 +16,11 @@ class WebPlatformTestsRunner(object): def __init__(self, setup): self.setup = setup - def run(self, **kwargs): + def setup_logging(self, **kwargs): + from wptrunner import wptrunner + return wptrunner.setup_logging(kwargs, {self.setup.default_log_type: sys.stdout}) + + def run(self, logger, **kwargs): from wptrunner import wptrunner if kwargs["product"] in ["firefox", None]: kwargs = self.setup.kwargs_firefox(kwargs) @@ -27,6 +31,5 @@ class WebPlatformTestsRunner(object): kwargs = self.setup.kwargs_wptrun(kwargs) else: raise ValueError("Unknown product %s" % kwargs["product"]) - logger = wptrunner.setup_logging(kwargs, {self.setup.default_log_type: sys.stdout}) result = wptrunner.start(**kwargs) return int(not result)