Skip to content

Commit

Permalink
Merge pull request #17 from w3c/jgraham/update-no-repo
Browse files Browse the repository at this point in the history
Allow metadata updates without sync repo.
  • Loading branch information
jgraham committed Sep 9, 2014
2 parents 12d1aa5 + 2a9d43b commit 6f3a8a1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 26 deletions.
3 changes: 1 addition & 2 deletions docs/expectation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ wptupdate takes several useful options:
mercurial tree).

``--patch``
Create a branch containing a git commit, or a mq patch with the
changes made by wptupdate.
Create a a git commit, or a mq patch, with the changes made by wptupdate.

``--ignore-existing``
Overwrite all the expectation data for any tests that have a result
Expand Down
9 changes: 5 additions & 4 deletions wptrunner/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ def update_manifest(git_root, metadata_root):


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

manifest = load_test_manifest(test_root, metadata_root)

if rev_old is not None:
rev_old = git("rev-parse", rev_old, repo=test_root).strip()
rev_new = git("rev-parse", rev_new, repo=test_root).strip()
if sync_root is not None:
if rev_old is not None:
rev_old = git("rev-parse", rev_old, repo=test_root).strip()
rev_new = git("rev-parse", rev_new, repo=test_root).strip()

if rev_old is not None:
change_data = load_change_data(rev_old, rev_new, repo=test_root)
Expand Down
60 changes: 41 additions & 19 deletions wptrunner/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,17 @@ def create_patch(self, patch_name, message):
try:
self.hg("qinit")
except subprocess.CalledProcessError:
# There is already a patch queue in this repo
# Should only happen during development
pass
self.hg("qnew", patch_name, "-X", self.root, "-m", message)

patch_names = [item.strip() for item in self.hg("qseries").split("\n") if item.strip()]

suffix = 0
test_name = patch_name
while test_name in patch_names:
suffix += 1
test_name = "%s-%i" % (patch_name, suffix)

self.hg("qnew", test_name, "-X", self.root, "-m", message)

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

def create_patch(self, patch_name, message):
# In git a patch is actually a branch
# In git a patch is actually a commit
self.message = message
self.git("checkout", "-b", patch_name)

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


def update_metadata(paths, local_tree, wpt, initial_rev, bug, log_files, ignore_existing):
def update_metadata(paths, local_tree, initial_rev, bug, log_files, ignore_existing,
wpt_repo=None):
try:
try:
local_tree.create_patch("web-platform-tests_update_%s_metadata" % wpt.rev,
"Update web-platform-tests expected data to revision %s" %
wpt.rev)
if wpt_repo is not None:
name = "web-platform-tests_update_%s_metadata" % wpt_repo.rev
message = "Update web-platform-tests expected data to revision %s" % wpt_repo.rev
else:
name = "web-platform-tests_update_metadata"
message = "Update web-platform-tests expected data"

local_tree.create_patch(name, message)
except subprocess.CalledProcessError:
# Patch with that name already exists, probably
pass
needs_human = metadata.update_expected(paths["sync"],
needs_human = metadata.update_expected(paths["test"],
paths["metadata"],
log_files,
rev_old=initial_rev,
ignore_existing=ignore_existing)
ignore_existing=ignore_existing,
sync_root=paths.get("sync", None))

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

paths = {"sync": kwargs["sync_path"],
"test": kwargs["tests_root"],
paths = {"test": kwargs["tests_root"],
"metadata": kwargs["metadata_root"]}

if kwargs["sync"]:
paths["sync"] = kwargs["sync_path"]

for path in paths.itervalues():
ensure_exists(path)

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

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

initial_rev = None
wpt_repo = None

if kwargs["sync"]:
initial_manifest, new_manifest = sync_tests(paths, local_tree, wpt, bug)
wpt_repo = WebPlatformTests(config["web-platform-tests"]["remote_url"],
paths["sync"],
rev=rev)
initial_manifest, new_manifest = sync_tests(paths, local_tree, wpt_repo, bug)
initial_rev = initial_manifest.rev

if kwargs["run_log"]:
update_metadata(paths, local_tree, wpt, initial_rev, bug,
kwargs["run_log"], kwargs["ignore_existing"])
update_metadata(paths,
local_tree,
initial_rev,
bug,
kwargs["run_log"],
kwargs["ignore_existing"],
wpt_repo=wpt_repo)


def main():
Expand Down
2 changes: 1 addition & 1 deletion wptrunner/wptcommandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def create_parser_update():
parser.add_argument("--no-check-clean", action="store_true", default=False,
help="Don't check the working directory is clean before updating")
parser.add_argument("--patch", action="store_true",
help="Create an mq patch or git branch+commit containing the changes.")
help="Create an mq patch or git commit containing the changes.")
parser.add_argument("--sync", dest="sync", action="store_true", default=False,
help="Sync the tests with the latest from upstream")
parser.add_argument("--ignore-existing", action="store_true", help="When updating test results only consider results from the logfiles provided, not existing expectations.")
Expand Down

0 comments on commit 6f3a8a1

Please sign in to comment.