Hello everyone,
swift test --filter tag:<name> can already run Swift Testing tests by tag, but there is no way to see which tags a package uses. I'd like to propose swift test list --tags, which prints the unique tags used by a package's Swift Testing tests. The full proposal is below.
Original issue: Add support for listing all test tags · Issue #8889 · swiftlang/swift-package-manager · GitHub
Implementation (prototype): Add `--tags` option to list Swift Testing tags by letsgobjones · Pull Request #10563 · swiftlang/swift-package-manager · GitHub
Related: tag filtering in Swift Testing, Add ability to filter/skip by tags using a special `tag:` prefix by gmedori · Pull Request #1531 · swiftlang/swift-testing · GitHub
I'd especially like feedback on:
- Should this list only the tags (
--tags), tests together with their tags (--include-tags), or both? - Is
--tagsthe right flag name? - Is it correct to show a suite's tags on the suite and not on the tests inside it?
- If you work in a package with many tags, how do you find them today?
P.S. This is my first pitch. I'm part of the Swift Mentorship Program for 2026, and I'm grateful for my mentor's guidance. I'd also love to try this on real packages, so if you have one that uses a lot of tags, please share it here.
List Swift Testing Tags
- Proposal: SE-NNNN
- Authors: Brandon Jones
- Review Manager: TBD
- Status: Awaiting implementation
- Implementation: swiftlang/swift-package-manager#10563
Introduction
swift test can run Swift Testing tests by tag, but it cannot show which tags a package uses. This proposal adds swift test list --tags, which prints the unique tags used by a package's Swift Testing tests.
Motivation
Swift Testing lets you attach tags to tests and suites:
extension Tag {
@Tag static var slow: Self
}
@Test(.tags(.slow)) func importLargeFile() { ... }
swift test --filter tag:slow then runs only the tests with that tag. Using this requires knowing which tags exist. Today, swift test list prints test names only, so the only way to discover the tags of an unfamiliar package is to read its test sources. In a large package, where tags are declared in one place and applied in many, this is slow.
Proposed solution
Add a --tags flag to swift test list. It prints the unique tags used by the package's Swift Testing tests, sorted, one per line:
$ swift test list --tags
integration
slow
smoke
swift test list without --tags is unchanged.
Detailed design
Command line
swift test list --tags is a new Boolean flag on the existing list subcommand.
How tags are found
SwiftPM already runs each Swift Testing test product with --list-tests. With --tags, it also passes --event-stream-output-path with a temporary file, one file per test product, because each test binary truncates its output file.
The event stream contains a record of kind test for every discovered test and suite. Since Swift 6.4, these records include a tags field. SwiftPM reads the tags of every test record, combines them across all test products, removes duplicates, sorts them, and prints them. The temporary files are removed afterwards. No change to Swift Testing is required.
Behavior
- A suite's tags appear on the suite's record and are listed as written. They are not copied onto the tests inside the suite.
- XCTest has no tags, so XCTest tests are skipped.
- If there are no tests, no tags, or the toolchain's Swift Testing does not report tags, the command prints nothing and exits successfully. This matches
swift test listfor a package with no tests.
Security
The command runs the same test binaries that swift test list already runs, and writes temporary files that are removed afterwards. There is no other impact on security, safety, or privacy.
Impact on existing packages
None. This is a new opt-in flag, and existing commands are unchanged.
Alternatives considered
A different flag name
--list-tags is an alternative. It repeats the word "list" that is already in swift test list, so this proposal uses --tags.
Listing tests together with their tags
A different design would list each test along with its tags, using a flag such as --include-tags. One possible format, for discussion only:
$ swift test list --include-tags
MyTests.SuiteA/one() slow
MyTests.three() slow, smoke
MyTests.untagged()
This answers a different question ("which tests have this tag?"). It also raises design questions that this proposal does not try to settle: whether a test should be shown with its suite's tags, and what machine-readable format scripts should consume. It is left to the community to decide whether it should be added, or added instead of --tags.
Future directions
If tests and tags are listed together, a --format option (for example --format json) would give scripts a stable, machine-readable output.