Skip to content

Hande Swift Testing-specific prefixes#10287

Open
gmedori wants to merge 2 commits into
swiftlang:mainfrom
gmedori:goose/xctest-filter-prefixes
Open

Hande Swift Testing-specific prefixes#10287
gmedori wants to merge 2 commits into
swiftlang:mainfrom
gmedori:goose/xctest-filter-prefixes

Conversation

@gmedori

@gmedori gmedori commented Jul 11, 2026

Copy link
Copy Markdown

Depends on swiftlang/swift-testing#1531

This PR accompanies swiftlang/swift-testing#1531 as the implementation for ST-0025, which enables users to pass an argument prefixed with tag: to swift test --filter in order to filter tests by tag in Swift Testing.

Motivation:

This particular PR accounts for what happens to XCTests when we pass in such a filter. XCTest doesn't have a concept of tags. Another way of saying this is that every XCTest has an empty set of tags, which means that supplying --filter tag:foo should not run any XCTests, since none of them have the appropriate tag. Similarly, supplying --skip tag:foo should not skip any XCTests.

We generalize this idea by saying that if any prefix is encountered (with one exception), we shouldn't match any XCTests. The exception is the id: prefix which behaves the same as passing no prefix at all. We only introduced the id: prefix in swiftlang/swift-testing#1531 in order to allow for disambiguation purposes, which don't apply when dealing with XCTests.

Examples

Here's a table of select examples to help illustrate what happens when you pass in various combinations of filter & skip specifiers:

Argument Swift Testing XCTest
--filter id:myTestName runs matching tests runs tests whose ID matches myTestName
--filter tag:integration runs tests tagged integration runs nothing (XCTest tests have no tags)
--filter id:… --filter tag:… runs tests matching the id and tag runs nothing (the tag can't be satisfied)
--skip id:myTestName skips matching tests skips tests whose ID matches
--skip tag:integration skips tests tagged integration skips nothing (all XCTest tests run)

Modifications:

  • Renamed testCaseSpecifierxctestFilterSpecifier, skippedTestsxctestSkippedSpecifier to indicate their XCTest-specific nature (for Swift Testing, the arguments are passed directly and parsed over there).
  • Added a function that normalizes the specifier for XCTest by stripping id: prefixes and deriving the correct behavior for other prefixes.
  • Accounted for the slightly different semantics of the --filter and --skip specifiers.

Result:

Existing uses won't change, but you will now be able to pass prefixes to --filter and --skip and have well-defined behavior as described above.

gmedori added 2 commits July 6, 2026 13:53
…from running if we encounter a Swift Testing-specific prefix

This commit also adds some tests to validate the behavior

@owenv owenv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although we should probably not merge until the swift-testing parts land

@owenv

owenv commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@swift-ci test

@plemarquand plemarquand left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks!

var shouldPrintCodeCovPath: Bool = false

var testCaseSpecifier: TestCaseSpecifier {
var xctestFilterSpecifier: TestCaseSpecifier {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: This is a wonderful rename and give clarity that it applies only to XCTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants