wpt
wpt copied to clipboard
WEB_FEATURES.yml should allow for exclusion
Currently, the WEB_FEATURES.yml allows for:
**- Recursive wildcard (special case)<OPTIONAL TEXT>*<OPTIONAL TEXT>- Wildcard at the current directory- Listing out the individual files
There are some cases where users would like to do pattern matching with some exclusion syntax.
Currently, WEB_FEATURES.yml uses fnmatchcase for the matching.
https://github.com/web-platform-tests/wpt/blob/8ab167e4b1c7aa77b90e3c9d7685454a7c248379/tools/metadata/webfeatures/schema.py#L33-L36
Given our limited syntax now, we could move over to use python's re package. Which would allow users to specify patterns like:
^(?!foo\.html$).*- include everything but foo.html
But we would need to go through each WEB_FEATURES.yml and change the usage of * to .*
We could also invent our own custom syntax that works on top of fnmatch case to do exclusion. But that doesn't seem sustainable in case there are other requests.
cc: @foolip
For a custom syntax, could we simply use a leading exclamation mark? Evaluate the pattern after it using fnmatch, and remove any matches from the set.
One thing I'm not sure about is the interact with "**". Does an exclusion in a subdirectory exclude from the recursive wildcard? I don't have a use case for it, but some people might assume it would work. Should it be an error instead?