mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Update web-platform-tests to revision fd0429f0b45f975b25d85256dac33762134952c5
This commit is contained in:
parent
0ba7da4431
commit
c8202ddbe1
50 changed files with 1210 additions and 191 deletions
|
@ -15,7 +15,7 @@ try:
|
|||
except ImportError:
|
||||
zstandard = None
|
||||
|
||||
from .vcs import Git
|
||||
from .utils import git
|
||||
|
||||
from . import log
|
||||
|
||||
|
@ -40,9 +40,9 @@ def should_download(manifest_path, rebuild_time=timedelta(days=5)):
|
|||
|
||||
|
||||
def merge_pr_tags(repo_root, max_count=50):
|
||||
git = Git.get_func(repo_root)
|
||||
gitfunc = git(repo_root)
|
||||
tags = []
|
||||
for line in git("log", "--format=%D", "--max-count=%s" % max_count).split("\n"):
|
||||
for line in gitfunc("log", "--format=%D", "--max-count=%s" % max_count).split("\n"):
|
||||
for ref in line.split(", "):
|
||||
if ref.startswith("tag: merge_pr_"):
|
||||
tags.append(ref[5:])
|
||||
|
|
|
@ -470,7 +470,7 @@ def load_and_update(tests_root,
|
|||
rebuild=False,
|
||||
metadata_path=None,
|
||||
cache_root=None,
|
||||
working_copy=False,
|
||||
working_copy=True,
|
||||
types=None,
|
||||
meta_filters=None,
|
||||
write_manifest=True,
|
||||
|
|
|
@ -3,7 +3,7 @@ import subprocess
|
|||
|
||||
import mock
|
||||
|
||||
from .. import vcs
|
||||
from .. import utils
|
||||
|
||||
|
||||
def test_git_for_path_no_git():
|
||||
|
@ -11,4 +11,4 @@ def test_git_for_path_no_git():
|
|||
with mock.patch(
|
||||
"subprocess.check_output",
|
||||
side_effect=subprocess.CalledProcessError(1, "foo")):
|
||||
assert vcs.Git.for_path(this_dir, "/", this_dir) is None
|
||||
assert utils.git(this_dir) is None
|
|
@ -17,7 +17,7 @@ logger = get_logger()
|
|||
def update(tests_root,
|
||||
manifest,
|
||||
manifest_path=None,
|
||||
working_copy=False,
|
||||
working_copy=True,
|
||||
cache_root=None,
|
||||
rebuild=False):
|
||||
logger.warning("Deprecated; use manifest.load_and_update instead")
|
||||
|
@ -41,8 +41,7 @@ def update_from_cli(**kwargs):
|
|||
kwargs["url_base"],
|
||||
update=True,
|
||||
rebuild=kwargs["rebuild"],
|
||||
cache_root=kwargs["cache_root"],
|
||||
working_copy=kwargs["work"])
|
||||
cache_root=kwargs["cache_root"])
|
||||
|
||||
|
||||
def abs_path(path):
|
||||
|
@ -58,9 +57,6 @@ def create_parser():
|
|||
parser.add_argument(
|
||||
"-r", "--rebuild", action="store_true", default=False,
|
||||
help="Force a full rebuild of the manifest.")
|
||||
parser.add_argument(
|
||||
"--work", action="store_true", default=False,
|
||||
help="Build from the working tree rather than the latest commit")
|
||||
parser.add_argument(
|
||||
"--url-base", action="store", default="/",
|
||||
help="Base url to use as the mount point for tests in this manifest.")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import platform
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
from six import BytesIO
|
||||
|
||||
|
@ -32,6 +33,27 @@ def to_os_path(path):
|
|||
return path.replace("/", os.path.sep)
|
||||
|
||||
|
||||
def git(path):
|
||||
def gitfunc(cmd, *args):
|
||||
full_cmd = ["git", cmd] + list(args)
|
||||
try:
|
||||
return subprocess.check_output(full_cmd, cwd=path, stderr=subprocess.STDOUT)
|
||||
except Exception as e:
|
||||
if platform.uname()[0] == "Windows" and isinstance(e, WindowsError):
|
||||
full_cmd[0] = "git.bat"
|
||||
return subprocess.check_output(full_cmd, cwd=path, stderr=subprocess.STDOUT)
|
||||
else:
|
||||
raise
|
||||
|
||||
try:
|
||||
# this needs to be a command that fails if we aren't in a git repo
|
||||
gitfunc("rev-parse", "--show-toplevel")
|
||||
except (subprocess.CalledProcessError, OSError):
|
||||
return None
|
||||
else:
|
||||
return gitfunc
|
||||
|
||||
|
||||
class ContextManagerBytesIO(BytesIO):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
import json
|
||||
import os
|
||||
import platform
|
||||
import stat
|
||||
import subprocess
|
||||
from collections import deque
|
||||
|
||||
from six import iteritems
|
||||
|
||||
from .sourcefile import SourceFile
|
||||
from .utils import git
|
||||
|
||||
MYPY = False
|
||||
if MYPY:
|
||||
|
@ -16,7 +13,7 @@ if MYPY:
|
|||
|
||||
|
||||
def get_tree(tests_root, manifest, manifest_path, cache_root,
|
||||
working_copy=False, rebuild=False):
|
||||
working_copy=True, rebuild=False):
|
||||
tree = None
|
||||
if cache_root is None:
|
||||
cache_root = os.path.join(tests_root, ".wptcache")
|
||||
|
@ -27,11 +24,8 @@ def get_tree(tests_root, manifest, manifest_path, cache_root,
|
|||
cache_root = None
|
||||
|
||||
if not working_copy:
|
||||
tree = Git.for_path(tests_root,
|
||||
manifest.url_base,
|
||||
manifest_path=manifest_path,
|
||||
cache_path=cache_root,
|
||||
rebuild=rebuild)
|
||||
raise ValueError("working_copy=False unsupported")
|
||||
|
||||
if tree is None:
|
||||
tree = FileSystem(tests_root,
|
||||
manifest.url_base,
|
||||
|
@ -41,39 +35,9 @@ def get_tree(tests_root, manifest, manifest_path, cache_root,
|
|||
return tree
|
||||
|
||||
|
||||
class Git(object):
|
||||
def __init__(self, repo_root, url_base, cache_path, manifest_path=None,
|
||||
rebuild=False):
|
||||
self.root = repo_root
|
||||
self.git = Git.get_func(repo_root)
|
||||
self.url_base = url_base
|
||||
# rebuild is a noop for now since we don't cache anything
|
||||
|
||||
@staticmethod
|
||||
def get_func(repo_path):
|
||||
def git(cmd, *args):
|
||||
full_cmd = ["git", cmd] + list(args)
|
||||
try:
|
||||
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=subprocess.STDOUT)
|
||||
except Exception as e:
|
||||
if platform.uname()[0] == "Windows" and isinstance(e, WindowsError):
|
||||
full_cmd[0] = "git.bat"
|
||||
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=subprocess.STDOUT)
|
||||
else:
|
||||
raise
|
||||
return git
|
||||
|
||||
@classmethod
|
||||
def for_path(cls, path, url_base, cache_path, manifest_path=None, rebuild=False):
|
||||
git = Git.get_func(path)
|
||||
try:
|
||||
# this needs to be a command that fails if we aren't in a git repo
|
||||
git("rev-parse", "--show-toplevel")
|
||||
except (subprocess.CalledProcessError, OSError):
|
||||
return None
|
||||
else:
|
||||
return cls(path, url_base, cache_path,
|
||||
manifest_path=manifest_path, rebuild=rebuild)
|
||||
class GitHasher(object):
|
||||
def __init__(self, path):
|
||||
self.git = git(path)
|
||||
|
||||
def _local_changes(self):
|
||||
"""get a set of files which have changed between HEAD and working copy"""
|
||||
|
@ -95,10 +59,6 @@ class Git(object):
|
|||
|
||||
return changes
|
||||
|
||||
def _show_file(self, path):
|
||||
path = os.path.relpath(os.path.abspath(path), self.root)
|
||||
return self.git("show", "HEAD:%s" % path)
|
||||
|
||||
def hash_cache(self):
|
||||
# type: () -> Dict[str, Optional[str]]
|
||||
"""
|
||||
|
@ -114,20 +74,6 @@ class Git(object):
|
|||
|
||||
return hash_cache
|
||||
|
||||
def __iter__(self):
|
||||
for rel_path, hash in iteritems(self.hash_cache()):
|
||||
if hash is None:
|
||||
contents = self._show_file(rel_path)
|
||||
else:
|
||||
contents = None
|
||||
yield SourceFile(self.root,
|
||||
rel_path,
|
||||
self.url_base,
|
||||
hash,
|
||||
contents=contents), True
|
||||
|
||||
def dump_caches(self):
|
||||
pass
|
||||
|
||||
|
||||
class FileSystem(object):
|
||||
|
@ -145,7 +91,7 @@ class FileSystem(object):
|
|||
self.path_filter = gitignore.PathFilter(self.root,
|
||||
extras=[".git/"],
|
||||
cache=self.ignore_cache)
|
||||
git = Git.for_path(root, url_base, cache_path)
|
||||
git = GitHasher(root)
|
||||
if git is not None:
|
||||
self.hash_cache = git.hash_cache()
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue