Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317

This commit is contained in:
Josh Matthews 2018-01-04 13:44:24 -05:00
parent aa199307c8
commit 2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions

View file

@ -56,7 +56,7 @@ For example, to make the lint tool ignore all '%s'
errors in the %s file,
you could add the following line to the lint.whitelist file.
%s:%s"""
%s: %s"""
def all_filesystem_paths(repo_root):
path_filter = PathFilter(repo_root, extras=[".git/*"])
@ -108,13 +108,13 @@ def _all_files_equal(paths):
return True
def check_path_length(repo_root, path, css_mode):
def check_path_length(repo_root, path):
if len(path) + 1 > 150:
return [("PATH LENGTH", "/%s longer than maximum path length (%d > 150)" % (path, len(path) + 1), path, None)]
return []
def check_worker_collision(repo_root, path, css_mode):
def check_worker_collision(repo_root, path):
endings = [(".any.html", ".any.js"),
(".any.worker.html", ".any.js"),
(".worker.html", ".worker.js")]
@ -127,7 +127,7 @@ def check_worker_collision(repo_root, path, css_mode):
return []
def check_ahem_copy(repo_root, path, css_mode):
def check_ahem_copy(repo_root, path):
lpath = path.lower()
if "ahem" in lpath and lpath.endswith(".ttf"):
return [("AHEM COPY", "Don't add extra copies of Ahem, use /fonts/Ahem.ttf", path, None)]
@ -139,7 +139,7 @@ w3c_tr_re = re.compile(r"https?\:\/\/www\.w3c?\.org\/TR\/([^/?#]+)")
w3c_dev_re = re.compile(r"https?\:\/\/dev\.w3c?\.org\/[^/?#]+\/([^/?#]+)")
def check_css_globally_unique(repo_root, paths, css_mode):
def check_css_globally_unique(repo_root, paths):
"""
Checks that CSS filenames are sufficiently unique
@ -154,7 +154,6 @@ def check_css_globally_unique(repo_root, paths, css_mode):
:param repo_root: the repository root
:param paths: list of all paths
:param css_mode: whether we're in CSS testsuite mode
:returns: a list of errors found in ``paths``
"""
@ -166,11 +165,9 @@ def check_css_globally_unique(repo_root, paths, css_mode):
if os.name == "nt":
path = path.replace("\\", "/")
if not css_mode:
if not path.startswith("css/"):
continue
if not path.startswith("css/"):
continue
# we're within css or in css_mode after all that
source_file = SourceFile(repo_root, path, "/")
if source_file.name_is_non_test:
# If we're name_is_non_test for a reason apart from support, ignore it.
@ -332,6 +329,11 @@ class W3CTestOrgRegexp(Regexp):
error = "W3C-TEST.ORG"
description = "External w3c-test.org domain used"
class WebPlatformTestRegexp(Regexp):
pattern = b"web\-platform\.test"
error = "WEB-PLATFORM.TEST"
description = "Internal web-platform.test domain used"
class Webidl2Regexp(Regexp):
pattern = b"webidl2\.js"
error = "WEBIDL2.JS"
@ -374,6 +376,7 @@ regexps = [item() for item in
CRRegexp,
SetTimeoutRegexp,
W3CTestOrgRegexp,
WebPlatformTestRegexp,
Webidl2Regexp,
ConsoleRegexp,
GenerateTestsRegexp,
@ -381,7 +384,7 @@ regexps = [item() for item in
LayoutTestsRegexp,
SpecialPowersRegexp]]
def check_regexp_line(repo_root, path, f, css_mode):
def check_regexp_line(repo_root, path, f):
errors = []
applicable_regexps = [regexp for regexp in regexps if regexp.applies(path)]
@ -393,12 +396,12 @@ def check_regexp_line(repo_root, path, f, css_mode):
return errors
def check_parsed(repo_root, path, f, css_mode):
def check_parsed(repo_root, path, f):
source_file = SourceFile(repo_root, path, "/", contents=f.read())
errors = []
if css_mode or path.startswith("css/"):
if path.startswith("css/"):
if (source_file.type == "support" and
not source_file.name_is_non_test and
not source_file.name_is_reference):
@ -562,7 +565,7 @@ class OpenModeCheck(ASTCheck):
ast_checkers = [item() for item in [OpenModeCheck]]
def check_python_ast(repo_root, path, f, css_mode):
def check_python_ast(repo_root, path, f):
if not path.endswith(".py"):
return []
@ -582,7 +585,7 @@ broken_js_metadata = re.compile(b"//\s*META:")
broken_python_metadata = re.compile(b"#\s*META:")
def check_script_metadata(repo_root, path, f, css_mode):
def check_script_metadata(repo_root, path, f):
if path.endswith((".worker.js", ".any.js")):
meta_re = js_meta_re
broken_metadata = broken_js_metadata
@ -621,52 +624,49 @@ def check_script_metadata(repo_root, path, f, css_mode):
return errors
def check_path(repo_root, path, css_mode):
def check_path(repo_root, path):
"""
Runs lints that check the file path.
:param repo_root: the repository root
:param path: the path of the file within the repository
:param css_mode: whether we're in CSS testsuite mode
:returns: a list of errors found in ``path``
"""
errors = []
for path_fn in path_lints:
errors.extend(path_fn(repo_root, path, css_mode))
errors.extend(path_fn(repo_root, path))
return errors
def check_all_paths(repo_root, paths, css_mode):
def check_all_paths(repo_root, paths):
"""
Runs lints that check all paths globally.
:param repo_root: the repository root
:param paths: a list of all the paths within the repository
:param css_mode: whether we're in CSS testsuite mode
:returns: a list of errors found in ``f``
"""
errors = []
for paths_fn in all_paths_lints:
errors.extend(paths_fn(repo_root, paths, css_mode))
errors.extend(paths_fn(repo_root, paths))
return errors
def check_file_contents(repo_root, path, f, css_mode):
def check_file_contents(repo_root, path, f):
"""
Runs lints that check the file contents.
:param repo_root: the repository root
:param path: the path of the file within the repository
:param f: a file-like object with the file contents
:param css_mode: whether we're in CSS testsuite mode
:returns: a list of errors found in ``f``
"""
errors = []
for file_fn in file_lints:
errors.extend(file_fn(repo_root, path, f, css_mode))
errors.extend(file_fn(repo_root, path, f))
f.seek(0)
return errors
@ -773,10 +773,10 @@ def main(**kwargs):
paths = lint_paths(kwargs, repo_root)
return lint(repo_root, paths, output_format, kwargs.get("css_mode", False))
return lint(repo_root, paths, output_format)
def lint(repo_root, paths, output_format, css_mode):
def lint(repo_root, paths, output_format):
error_count = defaultdict(int)
last = None
@ -817,15 +817,15 @@ def lint(repo_root, paths, output_format, css_mode):
paths.remove(path)
continue
errors = check_path(repo_root, path, css_mode)
errors = check_path(repo_root, path)
last = process_errors(errors) or last
if not os.path.isdir(abs_path):
with open(abs_path, 'rb') as f:
errors = check_file_contents(repo_root, path, f, css_mode)
errors = check_file_contents(repo_root, path, f)
last = process_errors(errors) or last
errors = check_all_paths(repo_root, paths, css_mode)
errors = check_all_paths(repo_root, paths)
last = process_errors(errors) or last
if output_format in ("normal", "markdown"):

View file

@ -26,7 +26,7 @@ INTERESTING_FILE_NAMES = {
def check_with_files(input_bytes):
return {
filename: (check_file_contents("", filename, six.BytesIO(input_bytes), False), kind)
filename: (check_file_contents("", filename, six.BytesIO(input_bytes)), kind)
for (filename, kind) in
(
(os.path.join("html", filename), kind)
@ -100,6 +100,19 @@ def test_w3c_test_org():
expected.append(("PARSE-FAILED", "Unable to parse file", filename, None))
assert errors == expected
def test_web_platform_test():
error_map = check_with_files(b"import('http://web-platform.test/')")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [("WEB-PLATFORM.TEST", "Internal web-platform.test domain used", filename, 1)]
if kind == "python":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, 1))
elif kind == "web-strict":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, None))
assert errors == expected
def test_webidl2_js():
error_map = check_with_files(b"<script src=/resources/webidl2.js>")
@ -440,7 +453,7 @@ def fifth():
def test_open_mode():
for method in ["open", "file"]:
code = open_mode_code.format(method).encode("utf-8")
errors = check_file_contents("", "test.py", six.BytesIO(code), False)
errors = check_file_contents("", "test.py", six.BytesIO(code))
check_errors(errors)
message = ("File opened without providing an explicit mode (note: " +
@ -453,15 +466,13 @@ def test_open_mode():
@pytest.mark.parametrize(
"filename,css_mode,expect_error",
"filename,expect_error",
[
("foo/bar.html", False, False),
("foo/bar.html", True, True),
("css/bar.html", False, True),
("css/bar.html", True, True),
("foo/bar.html", False),
("css/bar.html", True),
])
def test_css_support_file(filename, css_mode, expect_error):
errors = check_file_contents("", filename, six.BytesIO(b""), css_mode)
def test_css_support_file(filename, expect_error):
errors = check_file_contents("", filename, six.BytesIO(b""))
check_errors(errors)
if expect_error:
@ -475,24 +486,6 @@ def test_css_support_file(filename, css_mode, expect_error):
assert errors == []
def test_css_missing_file_css_mode():
code = b"""\
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</html>
"""
errors = check_file_contents("", "foo/bar.html", six.BytesIO(code), True)
check_errors(errors)
assert errors == [
('MISSING-LINK',
'Testcase file must have a link to a spec',
"foo/bar.html",
None),
]
def test_css_missing_file_in_css():
code = b"""\
<html xmlns="http://www.w3.org/1999/xhtml">
@ -500,7 +493,7 @@ def test_css_missing_file_in_css():
<script src="/resources/testharnessreport.js"></script>
</html>
"""
errors = check_file_contents("", "css/foo/bar.html", six.BytesIO(code), False)
errors = check_file_contents("", "css/foo/bar.html", six.BytesIO(code))
check_errors(errors)
assert errors == [
@ -512,7 +505,7 @@ def test_css_missing_file_in_css():
def test_css_missing_file_manual():
errors = check_file_contents("", "css/foo/bar-manual.html", six.BytesIO(b""), False)
errors = check_file_contents("", "css/foo/bar-manual.html", six.BytesIO(b""))
check_errors(errors)
assert errors == [
@ -544,7 +537,7 @@ def test_css_missing_file_manual():
(b"""// META: timeout=bar\n""", (1, "UNKNOWN-TIMEOUT-METADATA")),
])
def test_script_metadata(filename, input, error):
errors = check_file_contents("", filename, six.BytesIO(input), False)
errors = check_file_contents("", filename, six.BytesIO(input))
check_errors(errors)
if error is not None:
@ -583,7 +576,7 @@ def test_script_metadata(filename, input, error):
])
def test_python_metadata(input, error):
filename = "test.py"
errors = check_file_contents("", filename, six.BytesIO(input), False)
errors = check_file_contents("", filename, six.BytesIO(input))
check_errors(errors)
if error is not None:

View file

@ -108,7 +108,7 @@ CR AT EOL, INDENT TABS: html/test2.js: 42
def test_lint_no_files(caplog):
rv = lint(_dummy_repo, [], "normal", False)
rv = lint(_dummy_repo, [], "normal")
assert rv == 0
assert caplog.text == ""
@ -116,7 +116,7 @@ def test_lint_no_files(caplog):
def test_lint_ignored_file(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["broken_ignored.html"], "normal", False)
rv = lint(_dummy_repo, ["broken_ignored.html"], "normal")
assert rv == 0
assert not mocked_check_path.called
assert not mocked_check_file_contents.called
@ -128,7 +128,7 @@ def test_lint_not_existing_file(caplog):
with _mock_lint("check_file_contents") as mocked_check_file_contents:
# really long path-linted filename
name = "a" * 256 + ".html"
rv = lint(_dummy_repo, [name], "normal", False)
rv = lint(_dummy_repo, [name], "normal")
assert rv == 0
assert not mocked_check_path.called
assert not mocked_check_file_contents.called
@ -138,7 +138,7 @@ def test_lint_not_existing_file(caplog):
def test_lint_passing(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["okay.html"], "normal", False)
rv = lint(_dummy_repo, ["okay.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -148,7 +148,7 @@ def test_lint_passing(caplog):
def test_lint_failing(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["broken.html"], "normal", False)
rv = lint(_dummy_repo, ["broken.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -159,7 +159,7 @@ def test_lint_failing(caplog):
def test_ref_existent_relative(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["ref/existent_relative.html"], "normal", False)
rv = lint(_dummy_repo, ["ref/existent_relative.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -169,7 +169,7 @@ def test_ref_existent_relative(caplog):
def test_ref_existent_root_relative(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["ref/existent_root_relative.html"], "normal", False)
rv = lint(_dummy_repo, ["ref/existent_root_relative.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -179,7 +179,7 @@ def test_ref_existent_root_relative(caplog):
def test_ref_non_existent_relative(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["ref/non_existent_relative.html"], "normal", False)
rv = lint(_dummy_repo, ["ref/non_existent_relative.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -191,7 +191,7 @@ def test_ref_non_existent_relative(caplog):
def test_ref_non_existent_root_relative(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["ref/non_existent_root_relative.html"], "normal", False)
rv = lint(_dummy_repo, ["ref/non_existent_root_relative.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -204,7 +204,7 @@ def test_ref_non_existent_root_relative(caplog):
def test_ref_absolute_url(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["ref/absolute.html"], "normal", False)
rv = lint(_dummy_repo, ["ref/absolute.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -216,7 +216,7 @@ def test_ref_absolute_url(caplog):
def test_ref_same_file_empty(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["ref/same_file_empty.html"], "normal", False)
rv = lint(_dummy_repo, ["ref/same_file_empty.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -227,7 +227,7 @@ def test_ref_same_file_empty(caplog):
def test_ref_same_file_path(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["ref/same_file_path.html"], "normal", False)
rv = lint(_dummy_repo, ["ref/same_file_path.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
@ -238,7 +238,7 @@ def test_ref_same_file_path(caplog):
def test_lint_passing_and_failing(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["broken.html", "okay.html"], "normal", False)
rv = lint(_dummy_repo, ["broken.html", "okay.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -250,7 +250,7 @@ def test_lint_passing_and_failing(caplog):
def test_check_css_globally_unique_identical_test(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/match/a.html", "css-unique/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/match/a.html", "css/css-unique/a.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -260,7 +260,7 @@ def test_check_css_globally_unique_identical_test(caplog):
def test_check_css_globally_unique_different_test(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/not-match/a.html", "css-unique/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/not-match/a.html", "css/css-unique/a.html"], "normal")
assert rv == 2
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -270,7 +270,7 @@ def test_check_css_globally_unique_different_test(caplog):
def test_check_css_globally_unique_different_spec_test(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/selectors/a.html", "css-unique/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/selectors/a.html", "css/css-unique/a.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -280,7 +280,7 @@ def test_check_css_globally_unique_different_spec_test(caplog):
def test_check_css_globally_unique_support_ignored(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/support/a.html", "css-unique/support/tools/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/support/a.html", "css/css-unique/support/tools/a.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -290,7 +290,7 @@ def test_check_css_globally_unique_support_ignored(caplog):
def test_check_css_globally_unique_support_identical(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/support/a.html", "css-unique/match/support/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/support/a.html", "css/css-unique/match/support/a.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -300,7 +300,7 @@ def test_check_css_globally_unique_support_identical(caplog):
def test_check_css_globally_unique_support_different(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/not-match/support/a.html", "css-unique/support/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/not-match/support/a.html", "css/css-unique/support/a.html"], "normal")
assert rv == 2
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -310,7 +310,7 @@ def test_check_css_globally_unique_support_different(caplog):
def test_check_css_globally_unique_test_support(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/support/a.html", "css-unique/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/support/a.html", "css/css-unique/a.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -320,7 +320,7 @@ def test_check_css_globally_unique_test_support(caplog):
def test_check_css_globally_unique_ref_identical(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/a-ref.html", "css-unique/match/a-ref.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/a-ref.html", "css/css-unique/match/a-ref.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -330,7 +330,7 @@ def test_check_css_globally_unique_ref_identical(caplog):
def test_check_css_globally_unique_ref_different(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/not-match/a-ref.html", "css-unique/a-ref.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/not-match/a-ref.html", "css/css-unique/a-ref.html"], "normal")
assert rv == 2
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -340,7 +340,7 @@ def test_check_css_globally_unique_ref_different(caplog):
def test_check_css_globally_unique_test_ref(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/a-ref.html", "css-unique/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/a-ref.html", "css/css-unique/a.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -350,7 +350,7 @@ def test_check_css_globally_unique_test_ref(caplog):
def test_check_css_globally_unique_ignored(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/tools/a.html", "css-unique/not-match/tools/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/tools/a.html", "css/css-unique/not-match/tools/a.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
@ -360,10 +360,10 @@ def test_check_css_globally_unique_ignored(caplog):
def test_check_css_globally_unique_ignored_dir(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
rv = lint(_dummy_repo, ["css-unique/support/a.html", "css/work-in-progress/foo/support/a.html"], "normal", True)
rv = lint(_dummy_repo, ["css/css-unique/support/a.html"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert caplog.text == ""
@ -390,7 +390,7 @@ def test_main_with_args():
sys.argv = ['./lint', 'a', 'b', 'c']
with _mock_lint('lint', return_value=True) as m:
lint_mod.main(**vars(create_parser().parse_args()))
m.assert_called_once_with(repo_root, ['a', 'b', 'c'], "normal", False)
m.assert_called_once_with(repo_root, ['a', 'b', 'c'], "normal")
finally:
sys.argv = orig_argv
@ -402,7 +402,7 @@ def test_main_no_args():
with _mock_lint('lint', return_value=True) as m:
with _mock_lint('changed_files', return_value=['foo', 'bar']) as m2:
lint_mod.main(**vars(create_parser().parse_args()))
m.assert_called_once_with(repo_root, ['foo', 'bar'], "normal", False)
m.assert_called_once_with(repo_root, ['foo', 'bar'], "normal")
finally:
sys.argv = orig_argv
@ -414,6 +414,6 @@ def test_main_all():
with _mock_lint('lint', return_value=True) as m:
with _mock_lint('all_filesystem_paths', return_value=['foo', 'bar']) as m2:
lint_mod.main(**vars(create_parser().parse_args()))
m.assert_called_once_with(repo_root, ['foo', 'bar'], "normal", False)
m.assert_called_once_with(repo_root, ['foo', 'bar'], "normal")
finally:
sys.argv = orig_argv

View file

@ -11,7 +11,7 @@ def test_allowed_path_length():
for idx in range(5):
filename = basename + idx * "a"
errors = check_path("/foo/", filename, False)
errors = check_path("/foo/", filename)
check_errors(errors)
assert errors == []
@ -23,7 +23,7 @@ def test_forbidden_path_length():
filename = basename + idx * "a"
message = "/%s longer than maximum path length (%s > 150)" % (filename, 146 + idx)
errors = check_path("/foo/", filename, False)
errors = check_path("/foo/", filename)
check_errors(errors)
assert errors == [("PATH LENGTH", message, filename, None)]
@ -36,6 +36,6 @@ def test_forbidden_path_endings(path_ending, generated):
message = ("path ends with %s which collides with generated tests from %s files" %
(path_ending, generated))
errors = check_path("/foo/", path, False)
errors = check_path("/foo/", path)
check_errors(errors)
assert errors == [("WORKER COLLISION", message, path, None)]