Skip to content

Commit

Permalink
Bug 1733619 [wpt PR 31037] - Avoid assert not files_list[-1] errors…
Browse files Browse the repository at this point in the history
… on TC, a=testonly

Automatic update from web-platform-tests
Disable rename detection when looking for changed tests

At least at times, we could end up with the rename limit warning being
output (i.e., `inexact rename detection was skipped due to too many
files`). This then caused our assert to fail, as it relied on the
output following the -z argument and ending without any trailing out.

This warning is absolutely useless for us, as we're just looking to
find out what files have changed, so we don't care if the file is a
rename or not, so we can avoid it by just outright disabling rename
detection.

This was previously fixed in
web-platform-tests/wpt#18879 (30c42ecf9a) by
just outright ignoring stderr, but was regressed in
web-platform-tests/wpt#23733
(6539f1e343). Avoiding the warning being output in the first place
seems like a better solution than ignoring any errors git might
produce.

--
Deal with the different semantics of A..B in git-diff in repo_files_changed

At the moment on TaskCluster we pass something like

{PR base}..{PR head} which is sometimes a small range when parsed as a
range (see gitrevisions(7)), as it is everything reachable from PR
head but not from PR base. By comparison, for git-diff, A..B gives all
changes between the two trees A and B, which if the PR is filed with a
merge-base a long way behind master would be a much larger change.

As such, change repo_files_changed to use the merge-base of A..B, as
this gives us the diff of the commits that are new on the PR branch.

--

wpt-commits: 7cba72c881e666578f1f01c790d2298dd3ee756d, a7514a7da22289bccf9e0ce5e7bc28f75b9dc9bc
wpt-pr: 31037
  • Loading branch information
gsnedders authored and moz-wptsync-bot committed Oct 5, 2021
1 parent 5b13cc7 commit 8605d8d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions testing/web-platform/tests/tools/wpt/testfiles.py
Expand Up @@ -154,8 +154,17 @@ def repo_files_changed(revish, include_uncommitted=False, include_new=False):
if git is None:
raise Exception("git not found")

files_list = git("diff", "--name-only", "-z", revish).split(u"\0")
assert not files_list[-1]
if "..." in revish:
raise Exception(f"... not supported when finding files changed (revish: {revish!r}")

if ".." in revish:
# ".." isn't treated as a range for git-diff; what we want is
# everything reachable from B but not A, and git diff A...B
# gives us that (via the merge-base)
revish = revish.replace("..", "...")

files_list = git("diff", "--no-renames", "--name-only", "-z", revish).split(u"\0")
assert not files_list[-1], f"final item should be empty, got: {files_list[-1]!r}"
files = set(files_list[:-1])

if include_uncommitted:
Expand Down

0 comments on commit 8605d8d

Please sign in to comment.