Skip to content

Commit

Permalink
Add a REFERENCE-IN-OTHER-TYPE lint
Browse files Browse the repository at this point in the history
This is similar to the TESTHARNESS-IN-OTHER-TYPE lint
  • Loading branch information
gsnedders committed May 11, 2024
1 parent 9566e54 commit 8f48f40
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lint.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,17 @@ TESTHARNESS-IN-OTHER-TYPE: svg/svg-in-svg/svg-in-svg-circular-filter-reference-c
# Adding the testharnessreport.js script causes the test to never complete.
MISSING-TESTHARNESSREPORT: accessibility/crashtests/computed-node-checked.html

# Existing manual tests with references
REFERENCE-IN-OTHER-TYPE: css/CSS2/backgrounds/background-root-012a.xht
REFERENCE-IN-OTHER-TYPE: css/CSS2/backgrounds/background-root-013a.xht
REFERENCE-IN-OTHER-TYPE: css/CSS2/backgrounds/background-root-014a.xht
REFERENCE-IN-OTHER-TYPE: css/CSS2/cascade/html-precedence-004.xht
REFERENCE-IN-OTHER-TYPE: css/css-flexbox/css-flexbox-height-animation-stretch.html
REFERENCE-IN-OTHER-TYPE: css/css-transforms/css-transform-scale-001-manual.html

# Needs control of page size
REFERENCE-IN-OTHER-TYPE: css/css-multicol/moz-multicol3-column-balancing-break-inside-avoid-1.html

PRINT STATEMENT: webdriver/tests/bidi/browsing_context/print/*
PRINT STATEMENT: webdriver/tests/classic/print/*
PRINT STATEMENT: webdriver/tests/support/fixtures_bidi.py
Expand Down
4 changes: 4 additions & 0 deletions tools/lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ def check_parsed(repo_root: Text, path: Text, f: IO[bytes]) -> List[rules.Error]
errors.append(rules.NonexistentRef.error(path,
(reference_rel, href)))

if source_file.reftest_nodes:
if test_type not in ("print-reftest", "reftest"):
errors.append(rules.ReferenceInOtherType.error(path, (test_type,)))

if len(source_file.timeout_nodes) > 1:
errors.append(rules.MultipleTimeout.error(path))

Expand Down
5 changes: 5 additions & 0 deletions tools/lint/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ class TestharnessInOtherType(Rule):
description = "testharness.js included in a %s test"


class ReferenceInOtherType(Rule):
name = "REFERENCE-IN-OTHER-TYPE"
description = "Reference link included in a %s test"


class DuplicateBasenamePath(Rule):
name = "DUPLICATE-BASENAME-PATH"
description = collapse("""
Expand Down
35 changes: 35 additions & 0 deletions tools/lint/tests/test_file_lints.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,41 @@ def test_late_timeout():
]


def test_reference_in_non_reference():
code = b"""
<html xmlns="http://www.w3.org/1999/xhtml">
<link rel="match" href="test-ref.html"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</html>
"""
error_map = check_with_files(code)

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

if kind in ["web-lax", "web-strict"]:
assert errors == [
(
"NON-EXISTENT-REF",
"Reference test with a non-existent 'match' relationship reference: "
"'test-ref.html'",
filename,
None,
),
(
"REFERENCE-IN-OTHER-TYPE",
"Reference link included in a testharness test",
filename,
None,
),
]
elif kind == "python":
assert errors == [
("PARSE-FAILED", "Unable to parse file", filename, 2),
]


def test_print_function():
error_map = check_with_files(b"def foo():\n print('function')\n")

Expand Down

0 comments on commit 8f48f40

Please sign in to comment.