| Index: third_party/WebKit/LayoutTests/external/wpt/check_stability.py
|
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/check_stability.py b/third_party/WebKit/LayoutTests/external/wpt/check_stability.py
|
| index 611be00028e46c45fcf1de202894bc355194eeb4..248c447f3736d5fa94201a1f2cac38704e13464d 100644
|
| --- a/third_party/WebKit/LayoutTests/external/wpt/check_stability.py
|
| +++ b/third_party/WebKit/LayoutTests/external/wpt/check_stability.py
|
| @@ -404,52 +404,62 @@ def get_files_changed():
|
| if not files:
|
| return []
|
| assert files[-1] == "\0"
|
| - return ["%s/%s" % (wpt_root, item)
|
| + return [os.path.join(wpt_root, item)
|
| for item in files[:-1].split("\0")]
|
|
|
|
|
| def get_affected_testfiles(files_changed):
|
| - affected_testfiles = []
|
| - all_tests = set()
|
| + affected_testfiles = set()
|
| nontests_changed = set(files_changed)
|
| manifest_file = os.path.join(wpt_root, "MANIFEST.json")
|
| - for _, test, _ in manifest.load(wpt_root, manifest_file):
|
| - test_full_path = os.path.join(wpt_root, test)
|
| - all_tests.add(test_full_path)
|
| - if test_full_path in nontests_changed:
|
| - # Reduce the set of changed files to only non-tests.
|
| - nontests_changed.remove(test_full_path)
|
| - for changedfile_pathname in nontests_changed:
|
| - changed_file_repo_path = os.path.join(os.path.sep, os.path.relpath(changedfile_pathname, wpt_root))
|
| - os.path.normpath(changed_file_repo_path)
|
| - path_components = changed_file_repo_path.split(os.sep)[1:]
|
| + skip_dirs = ["conformance-checkers", "docs", "tools"]
|
| + test_types = ["testharness", "reftest", "wdspec"]
|
| +
|
| + wpt_manifest = manifest.load(wpt_root, manifest_file)
|
| +
|
| + support_files = {os.path.join(wpt_root, path)
|
| + for _, path, _ in wpt_manifest.itertypes("support")}
|
| + test_files = {os.path.join(wpt_root, path)
|
| + for _, path, _ in wpt_manifest.itertypes(*test_types)}
|
| +
|
| + nontests_changed = nontests_changed.intersection(support_files)
|
| +
|
| + nontest_changed_paths = set()
|
| + for full_path in nontests_changed:
|
| + rel_path = os.path.relpath(full_path, wpt_root)
|
| + path_components = rel_path.split(os.sep)
|
| if len(path_components) < 2:
|
| # This changed file is in the repo root, so skip it
|
| # (because it's not part of any test).
|
| continue
|
| top_level_subdir = path_components[0]
|
| - if top_level_subdir in ["conformance-checkers", "docs"]:
|
| + if top_level_subdir in skip_dirs:
|
| continue
|
| - # OK, this changed file is the kind we care about: It's something
|
| - # other than a test (e.g., it's a .js or .json file), and it's
|
| - # somewhere down beneath one of the top-level "spec" directories.
|
| - # So now we try to find any tests that reference it.
|
| - for root, dirs, fnames in os.walk(os.path.join(wpt_root, top_level_subdir)):
|
| - # Walk top_level_subdir looking for test files containing either the
|
| - # relative filepath or absolute filepatch to the changed file.
|
| - for fname in fnames:
|
| - testfile_full_path = os.path.join(root, fname)
|
| - # Skip any test file that's already in files_changed.
|
| - if testfile_full_path in files_changed:
|
| - continue
|
| - # Skip any file that's not a test file.
|
| - if testfile_full_path not in all_tests:
|
| - continue
|
| - with open(testfile_full_path, "r") as fh:
|
| - file_contents = fh.read()
|
| - changed_file_relpath = os.path.relpath(changedfile_pathname, root).replace(os.path.sep, "/")
|
| - if changed_file_relpath in file_contents or changed_file_repo_path.replace(os.path.sep, "/") in file_contents:
|
| - affected_testfiles.append(testfile_full_path)
|
| + repo_path = "/" + os.path.relpath(full_path, wpt_root).replace(os.path.sep, "/")
|
| + nontest_changed_paths.add((full_path, repo_path))
|
| +
|
| + for root, dirs, fnames in os.walk(wpt_root):
|
| + # Walk top_level_subdir looking for test files containing either the
|
| + # relative filepath or absolute filepatch to the changed files.
|
| + if root == wpt_root:
|
| + for dir_name in skip_dirs:
|
| + dirs.remove(dir_name)
|
| + for fname in fnames:
|
| + test_full_path = os.path.join(root, fname)
|
| + # Skip any file that's not a test file.
|
| + if test_full_path not in test_files:
|
| + continue
|
| + with open(test_full_path, "rb") as fh:
|
| + file_contents = fh.read()
|
| + if file_contents.startswith("\xfe\xff"):
|
| + file_contents = file_contents.decode("utf-16be")
|
| + elif file_contents.startswith("\xff\xfe"):
|
| + file_contents = file_contents.decode("utf-16le")
|
| + for full_path, repo_path in nontest_changed_paths:
|
| + rel_path = os.path.relpath(full_path, root).replace(os.path.sep, "/")
|
| + if rel_path in file_contents or repo_path in file_contents:
|
| + affected_testfiles.add(test_full_path)
|
| + continue
|
| return affected_testfiles
|
|
|
|
|
|
|