Bug 1463112 [wpt PR 11092] - Lint that META.yml files exist, a=testonly

Automatic update from web-platform-testsLint that META.yml files exist (#11092)

Fixes #10552.
--

wpt-commits: 93dceabca4f79ced2a35fa480f78d30d4123ffaa
wpt-pr: 11092


--HG--
rename : testing/web-platform/tests/tools/lint/tests/dummy/broken.html => testing/web-platform/tests/tools/lint/tests/dummy/tests/broken.html
rename : testing/web-platform/tests/tools/lint/tests/dummy/broken_ignored.html => testing/web-platform/tests/tools/lint/tests/dummy/tests/broken_ignored.html
rename : testing/web-platform/tests/tools/lint/tests/dummy/dependency.html => testing/web-platform/tests/tools/lint/tests/dummy/tests/dependency.html
rename : testing/web-platform/tests/tools/lint/tests/dummy/okay.html => testing/web-platform/tests/tools/lint/tests/dummy/tests/okay.html
This commit is contained in:
Simon Pieters 2018-07-06 23:30:48 +00:00 коммит произвёл James Graham
Родитель e44f5cd2a1
Коммит aca3032b18
16 изменённых файлов: 271 добавлений и 79 удалений

Просмотреть файл

@ -409626,7 +409626,7 @@
"support"
],
"./lint.whitelist": [
"1fd41d38b2af42fffea5bc09c0348feb0f078e85",
"365b43f66ce7b6d81314f8aecf8e245cf6ec53e5",
"support"
],
"./serve.py": [

Просмотреть файл

@ -772,6 +772,9 @@ MISSING-LINK: css/cssom-view/scrollTop-display-change.html
MISSING-LINK: css/geometry/*.worker.js
MISSING-LINK: css/filter-effects/*.any.js
# TODO https://github.com/web-platform-tests/wpt/pull/11710
MISSING-META-YML: css/css-box
# Tests that use WebKit/Blink testing APIs
LAYOUTTESTS APIS: css/css-regions/interactivity/*
LAYOUTTESTS APIS: resources/chromium/generic_sensor_mocks.js

Просмотреть файл

@ -263,6 +263,52 @@ def check_css_globally_unique(repo_root, paths):
return errors
def check_meta_yml(repo_root, paths):
"""
Checks that all top-level directories have META.yml files.
:param repo_root: the repository root
:param paths: list of all paths
:returns: a list of errors found in ``paths``
"""
# dirs represents whether there's a META.yml file, value is a boolean.
dirs = {}
errors = []
reviewer_in_subdirs = [
".well-known",
"css",
"css/vendor-imports",
]
for path in paths:
if os.name == "nt":
path = path.replace("\\", "/")
source_file = SourceFile(repo_root, path, "/")
if not source_file.dir_path:
continue # Skip top-level files
parts = source_file.dir_path.split(os.path.sep)
level = 0
for dir in reviewer_in_subdirs:
if path.startswith(dir):
level = dir.count("/") + 1
if len(parts) <= level:
continue
key = "/".join(parts[:level + 1])
if key not in dirs:
dirs[key] = False
if path.endswith("/META.yml") and len(parts) == level + 1:
dirs[key] = True
for dir in dirs:
if dirs[dir] is False:
errors.append(("MISSING-META-YML", "Directory is missing META.yml file.", dir, None))
return errors
def parse_whitelist(f):
"""
Parse the whitelist file given by `f`, and return the parsed structure.
@ -426,6 +472,26 @@ def check_regexp_line(repo_root, path, f):
return errors
meta_yml_extensions_pattern = re.compile(b"^[a-zA-z0-9_]+:$")
meta_yml_item_pattern = re.compile(b"^ - [a-zA-Z0-9-]+$")
def check_meta_yml_contents(repo_root, path, contents):
errors = []
for i, line in enumerate(contents.splitlines()):
if i == 0:
if line != b"suggested_reviewers:":
errors.append(("INVALID-META-YML", "First line was not `suggested_reviewers:`", path, i+1))
else:
if meta_yml_extensions_pattern.match(line):
break # Allow extensions in META.yml without having to update the linter.
if not meta_yml_item_pattern.match(line):
errors.append(("INVALID-META-YML", "Expected item with username", path, i+1))
if i < 1:
errors.append(("INVALID-META-YML", "Expected item with username", path, i+1))
return errors
def check_parsed(repo_root, path, f):
source_file = SourceFile(repo_root, path, "/", contents=f.read())
@ -442,6 +508,9 @@ def check_parsed(repo_root, path, f):
not source_file.spec_links):
return [("MISSING-LINK", "Testcase file must have a link to a spec", path, None)]
if source_file.filename == "META.yml":
return check_meta_yml_contents(repo_root, path, source_file.contents)
if source_file.name_is_non_test:
return []
@ -460,7 +529,9 @@ def check_parsed(repo_root, path, f):
for reftest_node in source_file.reftest_nodes:
href = reftest_node.attrib.get("href", "").strip(space_chars)
parts = urlsplit(href)
if (parts.scheme or parts.netloc) and parts != urlsplit("about:blank"):
if parts == urlsplit("about:blank"):
continue
if parts.scheme or parts.netloc:
errors.append(("ABSOLUTE-URL-REF",
"Reference test with a reference file specified via an absolute URL: '%s'" % href, path, None))
continue
@ -902,7 +973,7 @@ def lint(repo_root, paths, output_format):
return sum(itervalues(error_count))
path_lints = [check_path_length, check_worker_collision, check_ahem_copy]
all_paths_lints = [check_css_globally_unique]
all_paths_lints = [check_css_globally_unique, check_meta_yml]
file_lints = [check_regexp_line, check_parsed, check_python_ast, check_script_metadata]
# Don't break users of the lint that don't have git installed.

Просмотреть файл

@ -0,0 +1,2 @@
suggested_reviewers:
- gsnedders

Просмотреть файл

@ -1 +1 @@
*:broken_ignored.html
*:tests/broken_ignored.html

Просмотреть файл

@ -0,0 +1,2 @@
suggested_reviewers:
- gsnedders

Просмотреть файл

@ -1 +1 @@
<link rel="match" href="/dependency.html">
<link rel="match" href="/tests/dependency.html">

Просмотреть файл

@ -0,0 +1,2 @@
suggested_reviewers:
- zcorpan

Просмотреть файл

@ -0,0 +1,2 @@
suggested_reviewers:
- zcorpan

Просмотреть файл

@ -0,0 +1 @@
OHOY

Просмотреть файл

@ -115,7 +115,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")
rv = lint(_dummy_repo, ["tests/broken_ignored.html"], "normal")
assert rv == 0
assert not mocked_check_path.called
assert not mocked_check_file_contents.called
@ -126,7 +126,7 @@ def test_lint_not_existing_file(caplog):
with _mock_lint("check_path") as mocked_check_path:
with _mock_lint("check_file_contents") as mocked_check_file_contents:
# really long path-linted filename
name = "a" * 256 + ".html"
name = "tests/a" * 256 + ".html"
rv = lint(_dummy_repo, [name], "normal")
assert rv == 0
assert not mocked_check_path.called
@ -137,20 +137,22 @@ 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")
rv = lint(_dummy_repo, ["tests/okay.html",
"tests/META.yml"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert caplog.text == ""
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")
rv = lint(_dummy_repo, ["tests/broken.html",
"tests/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert "TRAILING WHITESPACE" in caplog.text
assert "broken.html:1" in caplog.text
@ -158,30 +160,33 @@ 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")
rv = lint(_dummy_repo, ["ref/existent_relative.html",
"ref/META.yml"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert caplog.text == ""
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")
rv = lint(_dummy_repo, ["ref/existent_root_relative.html",
"ref/META.yml"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert caplog.text == ""
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")
rv = lint(_dummy_repo, ["ref/non_existent_relative.html",
"ref/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert "NON-EXISTENT-REF" in caplog.text
assert "ref/non_existent_relative.html" in caplog.text
assert "non_existent_file.html" in caplog.text
@ -190,10 +195,11 @@ 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")
rv = lint(_dummy_repo, ["ref/non_existent_root_relative.html",
"ref/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert "NON-EXISTENT-REF" in caplog.text
assert "ref/non_existent_root_relative.html" in caplog.text
assert "/non_existent_file.html" in caplog.text
@ -203,10 +209,11 @@ 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")
rv = lint(_dummy_repo, ["ref/absolute.html",
"ref/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert "ABSOLUTE-URL-REF" in caplog.text
assert "http://example.com/reference.html" in caplog.text
assert "ref/absolute.html" in caplog.text
@ -215,20 +222,22 @@ def test_ref_absolute_url(caplog):
def test_about_blank_as_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, ["about_blank-ref.html"], "normal")
rv = lint(_dummy_repo, ["ref/about_blank-ref.html",
"ref/META.yml"], "normal")
assert rv == 0
assert not mocked_check_path.called
assert not mocked_check_file_contents.called
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert caplog.text == ""
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")
rv = lint(_dummy_repo, ["ref/same_file_empty.html",
"ref/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert "SAME-FILE-REF" in caplog.text
assert "same_file_empty.html" in caplog.text
@ -236,23 +245,26 @@ 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")
rv = lint(_dummy_repo, ["ref/same_file_path.html",
"ref/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert "SAME-FILE-REF" in caplog.text
assert "same_file_path.html" in caplog.text
def test_manual_path_testharness(caplog):
rv = lint(_dummy_repo, ["tests/relative-testharness-manual.html"], "normal")
rv = lint(_dummy_repo, ["tests/relative-testharness-manual.html",
"tests/META.yml"], "normal")
assert rv == 2
assert "TESTHARNESS-PATH" in caplog.text
assert "TESTHARNESSREPORT-PATH" in caplog.text
def test_css_visual_path_testharness(caplog):
rv = lint(_dummy_repo, ["css/css-unique/relative-testharness.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/relative-testharness.html",
"css/css-unique/META.yml"], "normal")
assert rv == 3
assert "CONTENT-VISUAL" in caplog.text
assert "TESTHARNESS-PATH" in caplog.text
@ -260,7 +272,8 @@ def test_css_visual_path_testharness(caplog):
def test_css_manual_path_testharness(caplog):
rv = lint(_dummy_repo, ["css/css-unique/relative-testharness-interact.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/relative-testharness-interact.html",
"css/css-unique/META.yml"], "normal")
assert rv == 3
assert "CONTENT-MANUAL" in caplog.text
assert "TESTHARNESS-PATH" in caplog.text
@ -270,134 +283,228 @@ def test_css_manual_path_testharness(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")
rv = lint(_dummy_repo, ["tests/broken.html",
"tests/okay.html",
"tests/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert mocked_check_path.call_count == 3
assert mocked_check_file_contents.call_count == 3
assert "TRAILING WHITESPACE" in caplog.text
assert "broken.html:1" in caplog.text
assert "okay.html" not in caplog.text
assert "tests/broken.html:1" in caplog.text
assert "tests/okay.html" not in caplog.text
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/css-unique/match/a.html", "css/css-unique/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/match/a.html",
"css/css-unique/a.html",
"css/css-unique/META.yml"], "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 == 3
assert mocked_check_file_contents.call_count == 3
assert caplog.text == ""
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/css-unique/not-match/a.html", "css/css-unique/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/not-match/a.html",
"css/css-unique/a.html",
"css/css-unique/META.yml"], "normal")
assert rv == 2
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert mocked_check_path.call_count == 3
assert mocked_check_file_contents.call_count == 3
assert "CSS-COLLIDING-TEST-NAME" in caplog.text
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/css-unique/selectors/a.html", "css/css-unique/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/selectors/a.html",
"css/css-unique/a.html",
"css/css-unique/META.yml"], "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 == 3
assert mocked_check_file_contents.call_count == 3
assert caplog.text == ""
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/css-unique/support/a.html", "css/css-unique/support/tools/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/support/a.html",
"css/css-unique/support/tools/a.html",
"css/css-unique/META.yml"], "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 == 3
assert mocked_check_file_contents.call_count == 3
assert caplog.text == ""
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/css-unique/support/a.html", "css/css-unique/match/support/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/support/a.html",
"css/css-unique/match/support/a.html",
"css/css-unique/META.yml"], "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 == 3
assert mocked_check_file_contents.call_count == 3
assert caplog.text == ""
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/css-unique/not-match/support/a.html", "css/css-unique/support/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/not-match/support/a.html",
"css/css-unique/support/a.html",
"css/css-unique/META.yml"], "normal")
assert rv == 2
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert mocked_check_path.call_count == 3
assert mocked_check_file_contents.call_count == 3
assert "CSS-COLLIDING-SUPPORT-NAME" in caplog.text
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/css-unique/support/a.html", "css/css-unique/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/support/a.html",
"css/css-unique/a.html",
"css/css-unique/META.yml"], "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 == 3
assert mocked_check_file_contents.call_count == 3
assert caplog.text == ""
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/css-unique/a-ref.html", "css/css-unique/match/a-ref.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/a-ref.html",
"css/css-unique/match/a-ref.html",
"css/css-unique/META.yml"], "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 == 3
assert mocked_check_file_contents.call_count == 3
assert caplog.text == ""
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/css-unique/not-match/a-ref.html", "css/css-unique/a-ref.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/not-match/a-ref.html",
"css/css-unique/a-ref.html",
"css/css-unique/META.yml"], "normal")
assert rv == 2
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert mocked_check_path.call_count == 3
assert mocked_check_file_contents.call_count == 3
assert "CSS-COLLIDING-REF-NAME" in caplog.text
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/css-unique/a-ref.html", "css/css-unique/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/a-ref.html",
"css/css-unique/a.html",
"css/css-unique/META.yml"], "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 == 3
assert mocked_check_file_contents.call_count == 3
assert caplog.text == ""
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/css-unique/tools/a.html", "css/css-unique/not-match/tools/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/tools/a.html",
"css/css-unique/not-match/tools/a.html",
"css/css-unique/META.yml"], "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 == 3
assert mocked_check_file_contents.call_count == 3
assert caplog.text == ""
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/css-unique/support/a.html"], "normal")
rv = lint(_dummy_repo, ["css/css-unique/support/a.html",
"css/css-unique/META.yml"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert caplog.text == ""
# Test file META.yml file Errors
# tests/okay.html - 1
# tests/foo/okay.html - 1
# tests/okay.html tests/META.yml 0
# tests/foo/okay.html tests/META.yml 0
# tests/okay.html tests/foo/META.yml 1
# tests/foo/okay.html tests/foo/META.yml 1
def test_check_meta_yml_test_l1_no_meta_yml(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, ["tests/okay.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert "MISSING-META-YML" in caplog.text
def test_check_meta_yml_test_l2_no_meta_yml(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, ["tests/foo/okay.html"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 1
assert mocked_check_file_contents.call_count == 1
assert "MISSING-META-YML" in caplog.text
def test_check_meta_yml_test_l1_meta_yml_l1(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, ["tests/okay.html",
"tests/META.yml"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert caplog.text == ""
def test_check_meta_yml_test_l2_meta_yml_l1(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, ["tests/foo/okay.html",
"tests/META.yml"], "normal")
assert rv == 0
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert caplog.text == ""
def test_check_meta_yml_test_l1_meta_yml_l2(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, ["tests/okay.html",
"tests/foo/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert "MISSING-META-YML" in caplog.text
def test_check_meta_yml_test_l2_meta_yml_l2(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, ["tests/foo/okay.html",
"tests/foo/META.yml"], "normal")
assert rv == 1
assert mocked_check_path.call_count == 2
assert mocked_check_file_contents.call_count == 2
assert "MISSING-META-YML" in caplog.text
def test_all_filesystem_paths():
with mock.patch(

Просмотреть файл

@ -264,6 +264,8 @@ class SourceFile(object):
self.name_prefix("MANIFEST") or
self.filename == "META.yml" or
self.filename.startswith(".") or
self.filename == "OWNERS" or
self.filename == "META.yml" or
self.type_flag == "support" or
self.in_non_test_dir())