Running the tests for a specific tag from command line

I apologize if I missed it, but is there a way to execute the tasks for a given tag using the command-line tool? I tried using filter but was likely holding it wrong. I'd love to see something like

i.e. swift test --tag=someTag

Thank you,

Daniel

1 Like

This isn't something we currently support, but we definitely want to. There's a subtlety here though, because we need to correctly handle multiple tags and XCTest (which does not support tags.) For example:

swift test --tag foo --tag bar

Should this match tests with either .foo or .bar, or with both? And should it exclude XCTest-based tests, or include them?

So the command-line interface for tags probably needs to be a bit more flexible, and we need to design that properly. That's beyond our goals for Swift 6, but if you take a look in the source for our JSON schema specification, you'll see we've started sketching out what we think we'll need for the next Swift release. :slightly_smiling_face:

I don't believe we have a GitHub issue tracking this (although we're tracking it internally at Apple with a radar.) Please feel free to open one!

Thank you - will do.

I agree there's a lot to think through and appreciate your team is doing the hard work.

The easy answer IMO is to do what Xcode does and only allow one --tag so that the multiple doesn't come up. It would be nice (though I say this without knowing if I'd ever use it) to be able to specify foo&bar for the intersection of tests that are tagged with both and foo|bar for the union of tests that are tagged with either.

Since XCTest-based tests can't be tagged I would exclude them.

Again - I defer to your team's expertise and experience

Thank you,

Daniel

Xcode actually supports all those variations! Watch Go further with Swift Testing for more info.

1 Like

My current example is a Swift Package and I didn't see how/where to add testing plans in a package. I'll revisit in the next chapter when my example is a Project

1 Like