Bug 1647439 - [remote] Preserve custom mocha recorder when vendoring Puppeteer r=remote-protocol-reviewers,jgraham

Differential Revision: https://phabricator.services.mozilla.com/D82066
This commit is contained in:
Maja Frydrychowicz 2020-07-02 18:46:42 +00:00
Родитель ea5b8a7d68
Коммит 2456548253
1 изменённых файлов: 14 добавлений и 10 удалений

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

@ -74,28 +74,32 @@ class RemoteCommands(MachCommandBase):
required=True, required=True,
help="The commit or tag object name to check out.") help="The commit or tag object name to check out.")
def vendor_puppeteer(self, repository, commitish): def vendor_puppeteer(self, repository, commitish):
puppeteerdir = os.path.join(self.remotedir, "test", "puppeteer") puppeteer_dir = os.path.join(self.remotedir, "test", "puppeteer")
shutil.rmtree(puppeteerdir, ignore_errors=True) # Preserve our custom mocha reporter
os.makedirs(puppeteerdir) shutil.move(os.path.join(puppeteer_dir, "json-mocha-reporter.js"), self.remotedir)
shutil.rmtree(puppeteer_dir, ignore_errors=True)
os.makedirs(puppeteer_dir)
with TemporaryDirectory() as tmpdir: with TemporaryDirectory() as tmpdir:
git("clone", "-q", repository, tmpdir) git("clone", "-q", repository, tmpdir)
git("checkout", commitish, worktree=tmpdir) git("checkout", commitish, worktree=tmpdir)
git("checkout-index", "-a", "-f", git("checkout-index", "-a", "-f",
"--prefix", "{}/".format(puppeteerdir), "--prefix", "{}/".format(puppeteer_dir),
worktree=tmpdir) worktree=tmpdir)
# remove files which may interfere with git checkout of central # remove files which may interfere with git checkout of central
try: try:
os.remove(os.path.join(puppeteerdir, ".gitattributes")) os.remove(os.path.join(puppeteer_dir, ".gitattributes"))
os.remove(os.path.join(puppeteerdir, ".gitignore")) os.remove(os.path.join(puppeteer_dir, ".gitignore"))
except OSError: except OSError:
pass pass
experimental_dir = os.path.join(puppeteerdir, "experimental") experimental_dir = os.path.join(puppeteer_dir, "experimental")
if os.path.isdir(experimental_dir): if os.path.isdir(experimental_dir):
shutil.rmtree(experimental_dir) shutil.rmtree(experimental_dir)
shutil.move(os.path.join(self.remotedir, "json-mocha-reporter.js"), puppeteer_dir)
import yaml import yaml
annotation = { annotation = {
"schema": 1, "schema": 1,
@ -111,7 +115,7 @@ class RemoteCommands(MachCommandBase):
"release": commitish, "release": commitish,
}, },
} }
with open(os.path.join(puppeteerdir, "moz.yaml"), "w") as fh: with open(os.path.join(puppeteer_dir, "moz.yaml"), "w") as fh:
yaml.safe_dump(annotation, fh, yaml.safe_dump(annotation, fh,
default_flow_style=False, default_flow_style=False,
encoding="utf-8", encoding="utf-8",
@ -321,7 +325,7 @@ class PuppeteerRunner(MozbuildObject):
super(PuppeteerRunner, self).__init__(*args, **kwargs) super(PuppeteerRunner, self).__init__(*args, **kwargs)
self.remotedir = os.path.join(self.topsrcdir, "remote") self.remotedir = os.path.join(self.topsrcdir, "remote")
self.puppeteerdir = os.path.join(self.remotedir, "test", "puppeteer") self.puppeteer_dir = os.path.join(self.remotedir, "test", "puppeteer")
def run_test(self, logger, *tests, **params): def run_test(self, logger, *tests, **params):
""" """
@ -398,7 +402,7 @@ class PuppeteerRunner(MozbuildObject):
expected_data = {} expected_data = {}
output_handler = MochaOutputHandler(logger, expected_data) output_handler = MochaOutputHandler(logger, expected_data)
proc = npm(*command, cwd=self.puppeteerdir, env=env, proc = npm(*command, cwd=self.puppeteer_dir, env=env,
processOutputLine=output_handler, wait=False) processOutputLine=output_handler, wait=False)
output_handler.proc = proc output_handler.proc = proc