Bug 1494308 - Use consistent logger in wpt commands r=ato

Before we were using a different logger for the manifest download and the actual test run.
This caused timestamps to get reset in a confusing way. Now create the logger early and
share it for all the subseteps.

Depends on D7171

Differential Revision: https://phabricator.services.mozilla.com/D7172

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Graham 2018-09-29 14:51:44 +00:00
Родитель a11c998bf1
Коммит 7b657769c4
2 изменённых файлов: 35 добавлений и 17 удалений

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

@ -129,7 +129,11 @@ class WebPlatformTestsRunnerSetup(MozbuildObject):
class WebPlatformTestsUpdater(MozbuildObject): class WebPlatformTestsUpdater(MozbuildObject):
"""Update web platform tests.""" """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 import update
from update import updatecommandline from update import updatecommandline
@ -141,7 +145,6 @@ class WebPlatformTestsUpdater(MozbuildObject):
kwargs["store_state"] = False kwargs["store_state"] = False
kwargs = updatecommandline.check_args(kwargs) kwargs = updatecommandline.check_args(kwargs)
logger = update.setup_logging(kwargs, {"mach": sys.stdout})
try: try:
update.run_update(logger, **kwargs) update.run_update(logger, **kwargs)
@ -269,24 +272,26 @@ testing/web-platform/tests for tests that may be shared
if proc: if proc:
proc.wait() proc.wait()
context.commands.dispatch("wpt-manifest-update", context)
class WPTManifestUpdater(MozbuildObject): class WPTManifestUpdater(MozbuildObject):
def run_update(self, rebuild=False, **kwargs): def setup_logging(self, **kwargs):
import manifestupdate
from wptrunner import wptlogging from wptrunner import wptlogging
logger = wptlogging.setup(kwargs, {"mach": sys.stdout}) 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')) 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')) config_dir = os.path.abspath(os.path.join(self.topobjdir, '_tests', 'web-platform'))
manifestupdate.update(logger, wpt_dir, rebuild, config_dir) manifestupdate.update(logger, wpt_dir, rebuild, config_dir)
class WPTManifestDownloader(MozbuildObject): class WPTManifestDownloader(MozbuildObject):
def run_download(self, manifest_update=True, force=False, **kwargs): def setup_logging(self, **kwargs):
import manifestdownload
from wptrunner import wptlogging from wptrunner import wptlogging
logger = wptlogging.setup(kwargs, {"mach": sys.stdout}) 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')) wpt_dir = os.path.abspath(os.path.join(self.topobjdir, '_tests', 'web-platform'))
manifestdownload.run(wpt_dir, self.topsrcdir, logger, force, manifest_update) manifestdownload.run(wpt_dir, self.topsrcdir, logger, force, manifest_update)
@ -347,11 +352,14 @@ class MachCommands(MachCommandBase):
params["include"].append(item["name"]) params["include"].append(item["name"])
del params["test_objects"] del params["test_objects"]
self.wpt_manifest_download(**params)
params["manifest_update"] = False
wpt_setup = self._spawn(WebPlatformTestsRunnerSetup) wpt_setup = self._spawn(WebPlatformTestsRunnerSetup)
wpt_runner = WebPlatformTestsRunner(wpt_setup) 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", @Command("wpt",
category="testing", 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('html5lib==1.0.1')
self.virtualenv_manager.install_pip_package('ujson') self.virtualenv_manager.install_pip_package('ujson')
self.virtualenv_manager.install_pip_package('requests') self.virtualenv_manager.install_pip_package('requests')
wpt_updater = self._spawn(WebPlatformTestsUpdater) 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", @Command("wpt-update",
category="testing", category="testing",
@ -398,12 +408,17 @@ class MachCommands(MachCommandBase):
self.setup() self.setup()
self.wpt_manifest_download(**params) self.wpt_manifest_download(**params)
wpt_manifest_updater = self._spawn(WPTManifestUpdater) 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", @Command("wpt-manifest-download",
category="testing", category="testing",
parser=create_parser_manifest_download) parser=create_parser_manifest_download)
def wpt_manifest_download(self, **params): def wpt_manifest_download(self, logger=None, **params):
self.setup() self.setup()
if logger is None:
from wptrunner import wptlogging
logger = wptlogging.setup(params, {"mach": sys.stdout})
wpt_manifest_downloader = self._spawn(WPTManifestDownloader) wpt_manifest_downloader = self._spawn(WPTManifestDownloader)
return wpt_manifest_downloader.run_download(**params) return wpt_manifest_downloader.run_download(logger, **params)

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

@ -16,7 +16,11 @@ class WebPlatformTestsRunner(object):
def __init__(self, setup): def __init__(self, setup):
self.setup = 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 from wptrunner import wptrunner
if kwargs["product"] in ["firefox", None]: if kwargs["product"] in ["firefox", None]:
kwargs = self.setup.kwargs_firefox(kwargs) kwargs = self.setup.kwargs_firefox(kwargs)
@ -27,6 +31,5 @@ class WebPlatformTestsRunner(object):
kwargs = self.setup.kwargs_wptrun(kwargs) kwargs = self.setup.kwargs_wptrun(kwargs)
else: else:
raise ValueError("Unknown product %s" % kwargs["product"]) raise ValueError("Unknown product %s" % kwargs["product"])
logger = wptrunner.setup_logging(kwargs, {self.setup.default_log_type: sys.stdout})
result = wptrunner.start(**kwargs) result = wptrunner.start(**kwargs)
return int(not result) return int(not result)