wpt icon indicating copy to clipboard operation
wpt copied to clipboard

[wptmanifest] Improve parser/serializer comment support

Open jonathan-j-lee opened this issue 3 years ago • 1 comments

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.

jonathan-j-lee avatar Aug 04 '22 16:08 jonathan-j-lee

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.

jonathan-j-lee avatar Sep 08 '22 20:09 jonathan-j-lee

(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)

jgraham avatar Oct 12 '22 18:10 jgraham

(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.

jonathan-j-lee avatar Oct 20 '22 18:10 jonathan-j-lee