Skip to content

Commit 6f3a8a1

Browse files
committed
Merge pull request #17 from w3c/jgraham/update-no-repo
Allow metadata updates without sync repo.
2 parents 12d1aa5 + 2a9d43b commit 6f3a8a1

File tree

4 files changed

+48
-26
lines changed

4 files changed

+48
-26
lines changed

docs/expectation.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ wptupdate takes several useful options:
9292
mercurial tree).
9393

9494
``--patch``
95-
Create a branch containing a git commit, or a mq patch with the
96-
changes made by wptupdate.
95+
Create a a git commit, or a mq patch, with the changes made by wptupdate.
9796

9897
``--ignore-existing``
9998
Overwrite all the expectation data for any tests that have a result

wptrunner/metadata.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ def update_manifest(git_root, metadata_root):
4242

4343

4444
def update_expected(test_root, metadata_root, log_file_names, rev_old=None, rev_new="HEAD",
45-
ignore_existing=False):
45+
ignore_existing=False, sync_root=None):
4646
"""Update the metadata files for web-platform-tests based on
4747
the results obtained in a previous run"""
4848

4949
manifest = load_test_manifest(test_root, metadata_root)
5050

51-
if rev_old is not None:
52-
rev_old = git("rev-parse", rev_old, repo=test_root).strip()
53-
rev_new = git("rev-parse", rev_new, repo=test_root).strip()
51+
if sync_root is not None:
52+
if rev_old is not None:
53+
rev_old = git("rev-parse", rev_old, repo=test_root).strip()
54+
rev_new = git("rev-parse", rev_new, repo=test_root).strip()
5455

5556
if rev_old is not None:
5657
change_data = load_change_data(rev_old, rev_new, repo=test_root)

wptrunner/update.py

+41-19
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,17 @@ def create_patch(self, patch_name, message):
179179
try:
180180
self.hg("qinit")
181181
except subprocess.CalledProcessError:
182-
# There is already a patch queue in this repo
183-
# Should only happen during development
184182
pass
185-
self.hg("qnew", patch_name, "-X", self.root, "-m", message)
183+
184+
patch_names = [item.strip() for item in self.hg("qseries").split("\n") if item.strip()]
185+
186+
suffix = 0
187+
test_name = patch_name
188+
while test_name in patch_names:
189+
suffix += 1
190+
test_name = "%s-%i" % (patch_name, suffix)
191+
192+
self.hg("qnew", test_name, "-X", self.root, "-m", message)
186193

187194
def update_patch(self, include=None):
188195
if include is not None:
@@ -227,9 +234,8 @@ def add_new(self, prefix=None):
227234
self.git("add", *args)
228235

229236
def create_patch(self, patch_name, message):
230-
# In git a patch is actually a branch
237+
# In git a patch is actually a commit
231238
self.message = message
232-
self.git("checkout", "-b", patch_name)
233239

234240
def update_patch(self, include=None):
235241
assert self.message is not None
@@ -289,20 +295,27 @@ def sync_tests(paths, local_tree, wpt, bug):
289295
return initial_manifest, new_manifest
290296

291297

292-
def update_metadata(paths, local_tree, wpt, initial_rev, bug, log_files, ignore_existing):
298+
def update_metadata(paths, local_tree, initial_rev, bug, log_files, ignore_existing,
299+
wpt_repo=None):
293300
try:
294301
try:
295-
local_tree.create_patch("web-platform-tests_update_%s_metadata" % wpt.rev,
296-
"Update web-platform-tests expected data to revision %s" %
297-
wpt.rev)
302+
if wpt_repo is not None:
303+
name = "web-platform-tests_update_%s_metadata" % wpt_repo.rev
304+
message = "Update web-platform-tests expected data to revision %s" % wpt_repo.rev
305+
else:
306+
name = "web-platform-tests_update_metadata"
307+
message = "Update web-platform-tests expected data"
308+
309+
local_tree.create_patch(name, message)
298310
except subprocess.CalledProcessError:
299311
# Patch with that name already exists, probably
300312
pass
301-
needs_human = metadata.update_expected(paths["sync"],
313+
needs_human = metadata.update_expected(paths["test"],
302314
paths["metadata"],
303315
log_files,
304316
rev_old=initial_rev,
305-
ignore_existing=ignore_existing)
317+
ignore_existing=ignore_existing,
318+
sync_root=paths.get("sync", None))
306319

307320
if needs_human:
308321
#TODO: List all the files that should be checked carefully for changes.
@@ -321,10 +334,12 @@ def update_metadata(paths, local_tree, wpt, initial_rev, bug, log_files, ignore_
321334
def run_update(**kwargs):
322335
config = kwargs["config"]
323336

324-
paths = {"sync": kwargs["sync_path"],
325-
"test": kwargs["tests_root"],
337+
paths = {"test": kwargs["tests_root"],
326338
"metadata": kwargs["metadata_root"]}
327339

340+
if kwargs["sync"]:
341+
paths["sync"] = kwargs["sync_path"]
342+
328343
for path in paths.itervalues():
329344
ensure_exists(path)
330345

@@ -352,19 +367,26 @@ def run_update(**kwargs):
352367
if rev is None:
353368
rev = config["web-platform-tests"].get("branch", "master")
354369

355-
wpt = WebPlatformTests(config["web-platform-tests"]["remote_url"],
356-
paths["sync"],
357-
rev=rev)
358370
bug = None
359371

360372
initial_rev = None
373+
wpt_repo = None
374+
361375
if kwargs["sync"]:
362-
initial_manifest, new_manifest = sync_tests(paths, local_tree, wpt, bug)
376+
wpt_repo = WebPlatformTests(config["web-platform-tests"]["remote_url"],
377+
paths["sync"],
378+
rev=rev)
379+
initial_manifest, new_manifest = sync_tests(paths, local_tree, wpt_repo, bug)
363380
initial_rev = initial_manifest.rev
364381

365382
if kwargs["run_log"]:
366-
update_metadata(paths, local_tree, wpt, initial_rev, bug,
367-
kwargs["run_log"], kwargs["ignore_existing"])
383+
update_metadata(paths,
384+
local_tree,
385+
initial_rev,
386+
bug,
387+
kwargs["run_log"],
388+
kwargs["ignore_existing"],
389+
wpt_repo=wpt_repo)
368390

369391

370392
def main():

wptrunner/wptcommandline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def create_parser_update():
198198
parser.add_argument("--no-check-clean", action="store_true", default=False,
199199
help="Don't check the working directory is clean before updating")
200200
parser.add_argument("--patch", action="store_true",
201-
help="Create an mq patch or git branch+commit containing the changes.")
201+
help="Create an mq patch or git commit containing the changes.")
202202
parser.add_argument("--sync", dest="sync", action="store_true", default=False,
203203
help="Sync the tests with the latest from upstream")
204204
parser.add_argument("--ignore-existing", action="store_true", help="When updating test results only consider results from the logfiles provided, not existing expectations.")

0 commit comments

Comments
 (0)