wpt
wpt copied to clipboard
[wptmanifest] Improve parser/serializer comment support
This change enables the metadata parser/serializer to preserve comments documenting test expectations. Currently, the parser ignores comments, which are lost when updating metadata from logs.
-
The tokenizer now allows comments on their own lines.
-
The tokenizer emits tokens for comments.
-
The parser attaches comments to AST nodes. Comments are not AST nodes themselves, since operations on ASTs expect certain shapes.
-
The serializer formats comment lines on a best-effort basis, like so:
# <comment 1> # ... <node> # <optional inline comment>The
<node>can be a key, heading, condition, or list/value when used as the default after a list of conditions.
I'd like your thoughts on this change @jgraham. According to the blame, I think you're the expert on the test metadata format?
For some context, we're building a CLI frontend in Chromium that automatically updates expectations in bulk from wptreports generated by the CI system. Stripping out comments (as done currently) disallows documentation and creates noisy diffs.
(also I note that wpt-update already exists for updating the metadata; are you using that or something else? We use it for Gecko and it seems to work OK, but the lack of roundtrip support for comments has been a problem, just never a high enough priority to actually fix)
(also I note that wpt-update already exists for updating the metadata; are you using that or something else? We use it for Gecko and it seems to work OK, but the lack of roundtrip support for comments has been a problem, just never a high enough priority to actually fix)
Something else that's Chromium-opinionated, although we delegate all the heavy lifting to the wpt backend.