Add ability to filter/skip by tags using a special tag: prefix#1531
Add ability to filter/skip by tags using a special tag: prefix#1531gmedori wants to merge 4 commits intoswiftlang:mainfrom
tag: prefix#1531Conversation
|
Holding off on approval because this will also need a Swift Evolution proposal and possibly changes to Swift Package Manager. But in terms of the technical implementation, seems reasonable. :) |
| var nonTagFilterRegexes: [String] = [] | ||
| var nonTagSkipRegexes: [String] = [] | ||
|
|
||
| for var filter in args.filter ?? [] { |
There was a problem hiding this comment.
I'd suggest adding some more comments in the new code explaining what it's doing.
There was a problem hiding this comment.
I added a bunch more comments in eab4679, I think it should be clearer now! Let me know if I've overshot, or if we need more. Still mentally calibrating the right balance 🙂
|
|
||
| for var skip in args.skip ?? [] { | ||
| if skip.hasPrefix(tagPrefix) { | ||
| filters.append(Configuration.TestFilter(includingAnyOf: [Tag(userProvidedStringValue: String(skip.dropFirst(4)))])) |
There was a problem hiding this comment.
As above. Can we combine the code for filter and skip? Looks basically identical?
There was a problem hiding this comment.
I've gone and just made the testFilter nested function more comprehensive to DRY this up. It's a nested function and didn't have any doc comments before, so I left it that way, but let me know if doc comments on it would be beneficial. I think the inline comments are sufficient since it's not a publicly visible symbol and the inline comments do a decent job.
eab4679 to
753e7c5
Compare
|
Adding test coverage to this one before I take it out of draft status! |
tag: prefixtag: prefix
51d6a48 to
162016a
Compare
|
Just updated with some tests and fleshed out the PR description! The Swift Evolution proposal for this change is currently a WIP. Waiting on some folks to proofread it before I put it up because it's my very first one. |
… using a special `tag:` prefix
…ilters regardless of type, regex or tag
6c131a2 to
07b97d2
Compare
While Xcode has had the ability to filter based on tags, this ability has been missing from the command line. This PR introduces a special prefix you can apply to your
--filterand--skipoption arguments:tag:.When prefixing your argument with
tag:, rather than treating the following characters as a regular expression, it's treated as a string literal that matches exactly against your test tags. For example, suppose you define a tag in your code as follows.If you then add that tag to some suites or tests, you'll be able to run those tests exclusively by running:
Resolves #591.
Resolves rdar://132989780.
CleanShot.2026-02-05.at.16.21.38.mp4
Modifications:
This PR enhances the nested
testFilterfunction inside ofconfigurationForEntryPoint(from:)function. ThetestFilterfunction now:tag:as string literals to be interpreted as tagstag:prefix with the following syntax:tag\:myRegexto force the entire string to be read as a regex (as it would be normally prior to this change). This allows for filtering on test names that containtag:.Checklist: