Update web-platform-tests to revision 89aa3f42131cce5a77268ddaeb2fab8a2e29c2a6

This commit is contained in:
WPT Sync Bot 2019-11-17 10:33:25 +00:00
parent 39963266ae
commit ea00d34098
392 changed files with 5974 additions and 7614 deletions

View file

@ -80,11 +80,13 @@ exclude_patterns = [
'.DS_Store'
]
from docs.wpt_lint_rules import WPTLintRules
# Enable inline reStructured Text within Markdown-formatted files
# https://recommonmark.readthedocs.io/en/latest/auto_structify.html
from recommonmark.transform import AutoStructify
def setup(app):
app.add_transform(AutoStructify)
app.add_directive('wpt-lint-rules', WPTLintRules)
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None

View file

@ -0,0 +1,78 @@
from docutils.parsers.rst import Directive, nodes
from docutils.utils import new_document
from recommonmark.parser import CommonMarkParser
import importlib
import textwrap
class WPTLintRules(Directive):
"""A docutils directive to generate documentation for the
web-platform-test-test's linting tool from its source code. Requires a
single argument: a Python module specifier for a file which declares
linting rules."""
has_content = True
required_arguments = 1
optional_arguments = 0
_md_parser = CommonMarkParser()
@staticmethod
def _parse_markdown(markdown):
WPTLintRules._md_parser.parse(markdown, new_document("<string>"))
return WPTLintRules._md_parser.document.children[0]
@property
def module_specifier(self):
return self.arguments[0]
def _get_rules(self):
try:
module = importlib.import_module(self.module_specifier)
except ImportError:
raise ImportError(
"""wpt-lint-rules: unable to resolve the module at "{}".""".format(self.module_specifier)
)
for binding_name, value in module.__dict__.iteritems():
if hasattr(value, "__abstractmethods__") and len(value.__abstractmethods__):
continue
description = getattr(value, "description", None)
name = getattr(value, "name", None)
to_fix = getattr(value, "to_fix", None)
if description is None:
continue
if to_fix is not None:
to_fix = textwrap.dedent(to_fix)
yield {
"name": name,
"description": textwrap.dedent(description),
"to_fix": to_fix
}
def run(self):
definition_list = nodes.definition_list()
for rule in sorted(self._get_rules(), key=lambda rule: rule['name']):
item = nodes.definition_list_item()
definition = nodes.definition()
term = nodes.term()
item += term
item += definition
definition_list += item
term += nodes.literal(text=rule["name"])
definition += WPTLintRules._parse_markdown(rule["description"])
if rule["to_fix"]:
definition += nodes.strong(text="To fix:")
definition += WPTLintRules._parse_markdown(rule["to_fix"])
if len(definition_list.children) == 0:
raise Exception(
"""wpt-lint-rules: no linting rules found at "{}".""".format(self.module_specifier)
)
return [definition_list]

View file

@ -22,81 +22,14 @@ those cases you can [whitelist test files](#updating-the-whitelist)
to suppress the errors. In all other cases, follow the instructions
below to fix all errors reported.
* **CONSOLE**: Test-file line has a `console.*(...)` call; **fix**: remove
the `console.*(...)` call (and in some cases, consider adding an
`assert_*` of some kind in place of it).
<!--
This listing is automatically generated from the linting tool's Python source
code.
-->
* **CR AT EOL**: Test-file line ends with CR (U+000D) character; **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).
* **EARLY-TESTHARNESSREPORT**: Test file has an instance of
`<script src='/resources/testharnessreport.js'>` prior to
`<script src='/resources/testharness.js'>`; **fix**: flip the order.
* **GENERATE_TESTS**: Test file line has a generate_tests call; **fix**: remove
the call and call `test()` a number of times instead.
* **INDENT TABS**: Test-file line starts with one or more tab characters;
**fix**: use spaces to replace any tab characters at beginning of lines.
* **INVALID-TIMEOUT**: Test file with `<meta name='timeout'...>` element
that has a `content` attribute whose value is not `long`; **fix**:
replace the value of the `content` attribute with `long`.
* **LATE-TIMEOUT**: Test file with `<meta name="timeout"...>` element after
`<script src='/resources/testharnessreport.js'>` element ; **fix**: move
the `<meta name="timeout"...>` element to precede the `script` element.
* **LAYOUTTESTS APIS**: Test file uses `eventSender`, `testRunner`, or
`internals` which are LayoutTests-specific APIs used in WebKit/Blink.
* **MALFORMED-VARIANT**: Test file with a `<meta name='variant'...>`
element whose `content` attribute has a malformed value; **fix**: ensure
the value of the `content` attribute starts with `?` or `#` or is empty.
* **MISSING-LINK**: CSS test file is missing a link to a spec. **fix**: Ensure that there is a `<link rel="help" href="[url]">` for the spec.
* Note: `MISSING-LINK` is 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/](http://test.csswg.org/), which doesn't use `wptserve`, so `*.any.js` and similar tests won't work there; stick with the `.html` equivalent.
* **MISSING-TESTHARNESSREPORT**: Test file is missing an instance of
`<script src='/resources/testharnessreport.js'>`; **fix**: ensure each
test file contains `<script src='/resources/testharnessreport.js'>`.
* **MULTIPLE-TESTHARNESS**: Test file with multiple instances of
`<script src='/resources/testharness.js'>`; **fix**: ensure each test
has only one `<script src='/resources/testharness.js'>` instance.
* **MULTIPLE-TESTHARNESSREPORT**: Test file with multiple instances of
`<script src='/resources/testharnessreport.js'>`; **fix**: ensure each test
has only one `<script src='/resources/testharnessreport.js'>` instance.
* **MULTIPLE-TIMEOUT**: Test file with multiple `<meta name="timeout"...>`
elements; **fix**: ensure each test file has only one instance of a
`<meta name="timeout"...>` element.
* **PARSE-FAILED**: Test file failed parsing by manifest builder; **fix**:
examine the file to find the causes of any parse errors, and fix them.
* **PATH LENGTH**: Test file's pathname has a total length greater than 150
characters; **fix**: use shorter filename to rename the test file.
* **PRINT STATEMENT**: A server-side python support file contains a `print`
statement; **fix**: remove the `print` statement or replace it with
something else that achieves the intended effect (e.g., a logging call).
* **SET TIMEOUT**: Test-file line has `setTimeout(...)` call; **fix**:
replace all `setTimeout(...)` calls with `step_timeout(...)` calls.
* **TRAILING WHITESPACE**: Test-file line has trailing whitespace; **fix**:
remove trailing whitespace from all lines in the file.
* **VARIANT-MISSING**: Test file with a `<meta name='variant'...>` element
that's missing a `content` attribute; **fix**: add a `content` attribute
with an appropriate value to the `<meta name='variant'...>` element.
* **W3C-TEST.ORG**: Test-file line has the string `w3c-test.org`; **fix**:
either replace the `w3c-test.org` string with the expression
`{{host}}:{{ports[http][0]}}` or a generic hostname like `example.org`.
```eval_rst
.. wpt-lint-rules:: tools.lint.rules
```
## Updating the whitelist