Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tools] Disallow refs to some non-existent files #18509

Merged
merged 1 commit into from Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions lint.whitelist
Expand Up @@ -822,3 +822,11 @@ WEB-PLATFORM.TEST:signed-exchange/resources/generate-test-sxgs.sh

SET TIMEOUT: inert/inert-retargeting.tentative.html
SET TIMEOUT: inert/inert-retargeting-iframe.tentative.html

# https://github.com/web-platform-tests/wpt/issues/16455
MISSING DEPENDENCY: idle-detection/interceptor.https.html
MISSING DEPENDENCY: sms/sms_provider.js
MISSING DEPENDENCY: web-nfc/resources/nfc-helpers.js
MISSING DEPENDENCY: shape-detection/resources/shapedetection-helpers.js
MISSING DEPENDENCY: webxr/resources/webxr_util.js
MISSING DEPENDENCY: contacts/resources/helpers.js
1 change: 1 addition & 0 deletions tools/lint/lint.py
Expand Up @@ -389,6 +389,7 @@ def filter_whitelist_errors(data, errors):
rules.GenerateTestsRegexp,
rules.PrintRegexp,
rules.LayoutTestsRegexp,
rules.MissingDepsRegexp,
rules.SpecialPowersRegexp]]

def check_regexp_line(repo_root, path, f):
Expand Down
7 changes: 7 additions & 0 deletions tools/lint/rules.py
Expand Up @@ -350,6 +350,13 @@ class LayoutTestsRegexp(Regexp):
file_extensions = [".html", ".htm", ".js", ".xht", ".xhtml", ".svg"]
description = "eventSender/testRunner/internals used; these are LayoutTests-specific APIs (WebKit/Blink)"

class MissingDepsRegexp(Regexp):
pattern = br"[^\w]/gen/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm so in theory we can probably do better than a regexp here, but it's also likely not worth it.

name = "MISSING DEPENDENCY"
file_extensions = [".html", ".htm", ".js", ".xht", ".xhtml", ".svg"]
description = "Chromium-specific content referenced"
to_fix = "Reimplement the test to use well-documented testing interfaces"

class SpecialPowersRegexp(Regexp):
pattern = b"SpecialPowers"
name = "SPECIALPOWERS API"
Expand Down
30 changes: 30 additions & 0 deletions tools/lint/tests/test_file_lints.py
Expand Up @@ -203,6 +203,36 @@ def test_internals():
1)]


def test_missing_deps():
error_map = check_with_files(b"<script src='/gen/foo.js'></script>")

for (filename, (errors, kind)) in error_map.items():
check_errors(errors)

if kind == "python":
assert errors == [("PARSE-FAILED", "Unable to parse file", filename, 1)]
else:
assert errors == [('MISSING DEPENDENCY',
'Chromium-specific content referenced',
filename,
1)]


def test_no_missing_deps():
error_map = check_with_files(b"""<head>
<script src='/foo/gen/foo.js'></script>
<script src='/gens/foo.js'></script>
</head>""")

for (filename, (errors, kind)) in error_map.items():
check_errors(errors)

if kind == "python":
assert errors == [("PARSE-FAILED", "Unable to parse file", filename, 1)]
else:
assert errors == []


def test_meta_timeout():
code = b"""
<html xmlns="http://www.w3.org/1999/xhtml">
Expand Down