Skip to content

Commit

Permalink
[wpt] Discard stderr when calling git
Browse files Browse the repository at this point in the history
git occasionally prints warning messages to stderr (e.g. when too many
files are modified and rename detection is disabled), which would mess
with the output parsing if they are redirected to stdout.

Fixes #18608.
  • Loading branch information
Hexcles committed Sep 5, 2019
1 parent ea47721 commit ac70bd3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/wpt/testfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@
def get_git_cmd(repo_path):
# type: (bytes) -> Callable[..., Text]
"""Create a function for invoking git commands as a subprocess."""
devnull = open(os.devnull, "w")
def git(cmd, *args):
# type: (Text, *Union[bytes, Text]) -> Text
full_cmd = [u"git", cmd] + list(item.decode("utf8") if isinstance(item, bytes) else item for item in args) # type: List[Text]
try:
logger.debug(" ".join(full_cmd))
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=subprocess.STDOUT).decode("utf8").strip()
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=devnull).decode("utf8").strip()
except subprocess.CalledProcessError as e:
logger.error("Git command exited with status %i" % e.returncode)
logger.error(e.output)
Expand Down

0 comments on commit ac70bd3

Please sign in to comment.