Lint Tool¶
We have a lint tool for catching common mistakes in test files. You can run
it manually by running the wpt lint command from the root of your local
web-platform-tests working directory like this:
./wpt lint
The lint tool is also run automatically for every submitted pull request, and reviewers will not merge branches with tests that have lint errors, so you must either fix all lint errors, or you must add an exception to suppress the errors.
Fixing lint errors¶
You must fix any errors the lint tool reports, unless an error is for something essential to a certain test or that for some other exceptional reason shouldn’t prevent the test from being merged; in those cases you can add an exception to suppress the errors. In all other cases, follow the instructions below to fix all errors reported.
ABSOLUTE-URL-REFReference test with a reference file specified via an absolute URL: ‘%s’
AHEM COPYDon’t add extra copies of Ahem, use /fonts/Ahem.ttf
AHEM SYSTEM FONTDon’t use Ahem as a system font, use /fonts/ahem.css
ASSERT-PRECONDITIONTest-file line has an
To fix:assert_precondition(...)callReplace with
assert_implementsorassert_implements_optionalASSERT_THROWSTest-file line has an
To fix:assert_throws(...)callReplace with
assert_throws_domorassert_throws_jsorassert_throws_exactlyBROKEN-GLOBAL-METADATAInvalid global metadata: %s
BROKEN-METADATAMetadata comment is not formatted correctly
CONSOLETest-file line has a
To fix:console.*(...)callremove the
console.*(...)call (and in some cases, consider adding anassert_*of some kind in place of it)CONTENT-MANUALManual test whose filename doesn’t end in ‘-manual’
CONTENT-VISUALVisual test whose filename doesn’t end in ‘-visual’
CR AT EOLTest-file line ends with CR (U+000D) character
To fix:reformat file so each line just has LF (U+000A) line ending (standard, cross-platform “Unix” line endings instead of, e.g., DOS line endings).
DUPLICATE-BASENAME-PATHFile has identical basename path (path excluding extension) as other file(s) (found extensions: %s)
To fix:rename files so they have unique basename paths
DUPLICATE-CASE-INSENSITIVE-PATHPath differs from path %s only in case
To fix:rename files so they are unique irrespective of case
EARLY-TESTDRIVER-VENDORTest file has an instance of
To fix:<script src='/resources/testdriver-vendor.js'>prior to<script src='/resources/testdriver.js'>flip the order
EARLY-TESTHARNESSREPORTTest file has an instance of
To fix:<script src='/resources/testharnessreport.js'>prior to<script src='/resources/testharness.js'>flip the order
FILE TYPE/%s is an unsupported file type (%s)
GENERATE_TESTSTest file line has a generate_tests call
To fix:remove the call and call
test()a number of times insteadGITIGNORE.gitignore found outside the root
HTML INVALID SYNTAXTest-file line has a non-void HTML tag with /> syntax
To fix:Replace with start tag and end tag
IGNORED PATH%s matches an ignore filter in .gitignore - please add a .gitignore exception
INDENT TABSTest-file line starts with one or more tab characters
To fix:use spaces to replace any tab characters at beginning of lines
INDENTED-METADATAMetadata comments should start the line
INVALID-META-FILEThe META.yml is not a YAML file with the expected structure
INVALID-TIMEOUTTest file with
To fix:<meta name='timeout'...>element that has acontentattribute whose value is notlong: %sreplace the value of the
contentattribute withlongINVALID-WEB-FEATURES-FILEThe WEB_FEATURES.yml file contains an invalid structure
LATE-TIMEOUTTest file with
To fix:<meta name='timeout'...>element after<script src='/resources/testharnessreport.js'>elementmove the
<meta name="timeout"...>element to precede thescriptelement.LAYOUTTESTS APISeventSender/testRunner/internals used; these are LayoutTests-specific APIs (WebKit/Blink)
MALFORMED-VARIANT%s must be a non empty string and start with ‘?’ or ‘#’
MISSING DEPENDENCYChromium-specific content referenced
To fix:Reimplement the test to use well-documented testing interfaces
MISSING-LINKTestcase file must have a link to a spec
To fix:Ensure that there is a
<link rel="help" href="[url]">for the spec.MISSING-LINKis designed to ensure that the CSS build tool can find the tests. Note that the CSS build system is primarily used by test.csswg.org/, which doesn’t usewptserve, so*.any.jsand similar tests won’t work there; stick with the.htmlequivalent.MISSING-REFTESTWAITMissing
To fix:class=reftest-waitensure tests that include reftest-wait.js also use class=reftest-wait on the root element.
MISSING-TESTDRIVER-VENDORMissing
<script src='/resources/testdriver-vendor.js'>MISSING-TESTHARNESSREPORTMissing
To fix:<script src='/resources/testharnessreport.js'>ensure each test file contains
<script src='/resources/testharnessreport.js'>MISSING-WEB-FEATURES-FILEThe WEB_FEATURES.yml file references a test that does not exist: ‘%s’
MOJOM-JSDon’t check *.mojom.js files into WPT
To fix:Check if the file is already included in mojojs.zip: https://source.chromium.org/chromium/chromium/src/+/master:chrome/tools/build/linux/FILES.cfg If yes, use
loadMojoResourcesfromresources/test-only-api.jsto load it; if not, contact ecosystem-infra@chromium.org for adding new files to mojojs.zip.MULTIPLE-TESTDRIVERMore than one
<script src='/resources/testdriver.js'>MULTIPLE-TESTDRIVER-VENDORMore than one
<script src='/resources/testdriver-vendor.js'>MULTIPLE-TESTHARNESSMore than one
To fix:<script src='/resources/testharness.js'>Ensure each test has only one
<script src='/resources/testharness.js'>instance. For.jstests, remove// META: script=/resources/testharness.js, which wptserve already adds to the boilerplate markup.MULTIPLE-TESTHARNESSREPORTMore than one
To fix:<script src='/resources/testharnessreport.js'>Ensure each test has only one
<script src='/resources/testharnessreport.js'>instance. For.jstests, remove// META: script=/resources/testharnessreport.js, which wptserve already adds to the boilerplate markup.MULTIPLE-TIMEOUTMore than one meta name=’timeout’
To fix:ensure each test file has only one instance of a
<meta name="timeout"...>elementNON-EXISTENT-REFReference test with a non-existent ‘%s’ relationship reference: ‘%s’
OPEN-NO-MODEFile opened without providing an explicit mode (note: binary files must be read with ‘b’ in the mode flags)
PARSE-FAILEDUnable to parse file
To fix:examine the file to find the causes of any parse errors, and fix them.
PATH LENGTH/%s longer than maximum path length (%d > 150)
To fix:use shorter filename to rename the test file
PRINT STATEMENTA server-side python support file contains a
To fix:printstatementremove the
printstatement or replace it with something else that achieves the intended effect (e.g., a logging call)PROMISE_REJECTSTest-file line has a
To fix:promise_rejects(...)callReplace with promise_rejects_dom or promise_rejects_js or
promise_rejects_exactlyREFERENCE-IN-OTHER-TYPEReference link included in a %s test
SAME-FILE-REFReference test which points at itself as a reference
SET TIMEOUTsetTimeout used
To fix:replace all
setTimeout(...)calls withstep_timeout(...)callsSPECIALPOWERS APISpecialPowers used; this is gecko-specific and not supported in wpt
STRAY-METADATAMetadata comments should start the file
TENTATIVE-DIRECTORY-NAMEDirectories for tentative tests must be named exactly ‘tentative’
To fix:rename directory to be called ‘tentative’
TEST DRIVER INTERNALTest-file uses test_driver_internal API
To fix:Only use test_driver public API
TESTDRIVER-IN-UNSUPPORTED-TYPEtestdriver.js included in a %s test, which doesn’t support testdriver.js
TESTDRIVER-PATHtestdriver.js script seen with incorrect path
TESTDRIVER-UNSUPPORTED-QUERY-PARAMETERtestdriver.js script seen with unsupported query parameters
TESTDRIVER-VENDOR-PATHtestdriver-vendor.js script seen with incorrect path
TESTHARNESS-IN-OTHER-TYPEtestharness.js included in a %s test
TESTHARNESS-PATHtestharness.js script seen with incorrect path
TESTHARNESSREPORT-PATHtestharnessreport.js script seen with incorrect path
TRAILING WHITESPACEWhitespace at EOL
To fix:Remove trailing whitespace from all lines in the file.
UNKNOWN-GLOBAL-METADATAUnexpected value for global metadata
UNKNOWN-METADATAUnexpected kind of metadata
UNKNOWN-TIMEOUT-METADATAUnexpected value for timeout metadata
VARIANT-MISSINGTest file with a
To fix:<meta name='variant'...>element that’s missing acontentattributeadd a
contentattribute with an appropriate value to the<meta name='variant'...>elementW3C-TEST.ORGTest-file line has the string
To fix:w3c-test.orgeither replace the
w3c-test.orgstring with the expression{{host}}:{{ports[http][0]}}or a generic hostname likeexample.orgWEB-PLATFORM.TESTInternal web-platform.test domain used
To fix:use server-side substitution, along with the
.subfilename-flag, to replace web-platform.test with{{domains[]}}WEBIDL2.JSLegacy webidl2.js script used
WORKER COLLISIONpath ends with %s which collides with generated tests from %s files
Updating the ignored files¶
Normally you must fix all lint errors. But in the
unusual case of error reports for things essential to certain tests or that
for other exceptional reasons shouldn’t prevent a merge of a test, you can
update and commit the lint.ignore file in the web-platform-tests root
directory to suppress errors the lint tool would report for a test file.
To add a test file or directory to the list, use the following format:
ERROR TYPE:file/name/pattern
For example, to ignore all TRAILING WHITESPACE errors in the file
example/file.html, add the following line to the lint.ignore file:
TRAILING WHITESPACE:example/file.html
To ignore errors for an entire directory rather than just one file, use the *
wildcard. For example, to ignore all TRAILING WHITESPACE errors in the
example directory, add the following line to the lint.ignore file:
TRAILING WHITESPACE:example/*
Similarly, you can also use shell-style wildcards to express other filename patterns or directory-name patterns.
Finally, to ignore just one line in a file, use the following format:
ERROR TYPE:file/name/pattern:line_number
For example, to ignore the TRAILING WHITESPACE error for just line 128 of the
file example/file.html, add the following to the lint.ignore file:
TRAILING WHITESPACE:example/file.html:128