wpt icon indicating copy to clipboard operation
wpt copied to clipboard

WEB_FEATURES.yml should allow for exclusion

Open jcscottiii opened this issue 1 year ago • 1 comments

Currently, the WEB_FEATURES.yml allows for:

  1. ** - Recursive wildcard (special case)
  2. <OPTIONAL TEXT>*<OPTIONAL TEXT> - Wildcard at the current directory
  3. 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

jcscottiii avatar May 31 '24 20:05 jcscottiii

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?

foolip avatar May 31 '24 21:05 foolip