# \[Pitch\] List Swift Testing tags with swift test list --tags

**URL:** <https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032>\
**Category:** Pitches\
**Tags:** packagemanager, testing, swift-testing\
**Created:** [October 13, 2026, 2:56am UTC](https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032 "2026-10-13T02:56:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![letsgobjones](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/letsgobjones/32/45625_2.png) [@letsgobjones](https://forums.swift.org/u/letsgobjones)\
**Post date:** [October 13, 2026, 2:56am UTC](https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032/1 "2026-10-13T02:56:50Z")

</div>

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](https://github.com/swiftlang/swift-package-manager/issues/8889)  
**Implementation (prototype):** [Add `--tags` option to list Swift Testing tags by letsgobjones · Pull Request #10563 · swiftlang/swift-package-manager · GitHub](https://github.com/swiftlang/swift-package-manager/pull/10563)  
**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](https://github.com/swiftlang/swift-testing/pull/1531)

I'd especially like feedback on:

1. Should this list only the tags (`--tags`), tests together with their tags (`--include-tags`), or both?
2. Is `--tags` the right flag name?
3. Is it correct to show a suite's tags on the suite and not on the tests inside it?
4. 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](https://github.com/letsgobjones)
- Review Manager: TBD
- Status: **Awaiting implementation**
- Implementation: [swiftlang/swift-package-manager#10563](https://github.com/swiftlang/swift-package-manager/pull/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:

```swift
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
$ 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 list` for 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
$ 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.

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [October 13, 2026, 4:08am UTC](https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032/2 "2026-10-13T04:08:06Z")

</div>

I replied to your GitHub PR. We will want a PR on Swift Testing that does the enumeration; a change in SwiftPM can then be made that is minimal (just adds the flag to forward.)

Please also open a PR in the swift-evolution repo containing your .md file based on the Swift Testing proposal template. (If you have done so already, please add a link to it here.)

Thanks!

---

<div class="post-metadata">

**Author:** ![letsgobjones](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/letsgobjones/32/45625_2.png) [@letsgobjones](https://forums.swift.org/u/letsgobjones)\
**Post date:** [October 14, 2026, 12:49am UTC](https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032/3 "2026-10-14T00:49:13Z")

</div>

Thanks, @grynspan. That makes sense, and it matches how `swift test list`  
already works for Swift Testing, so I'll rework this so that Swift Testing does  
the enumeration and SwiftPM only forwards the flag.

Two questions so I get the shape right:

1. On the Swift Testing side, would you like `--list-tests` to accept  
`--include-tags` and print each test with its tags, as you suggested? Or  
should there also be a mode that prints only the unique tags?
2. I'll move the proposal to the Swift Testing template and open a PR against  
swift-evolution under `proposals/testing/`. Should it be a draft PR until  
the design settles?

I'll drop `--format`, since as you say, including tags is separate from the  
output format. I'll post the swift-evolution PR link here once it's up.

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [October 14, 2026, 1:06am UTC](https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032/4 "2026-10-14T01:06:00Z")

</div>

> [@letsgobjones](#):
>
> 1. On the Swift Testing side, would you like `--list-tests` to accept  
> `--include-tags` and print each test with its tags, as you suggested? Or  
> should there also be a mode that prints only the unique tags?

I don't think a separate tags-only output is valuable here for humans to read, and automated systems can already consume the JSON output. But it is up to you to make the case for whatever you propose.

> [@letsgobjones](#):
>
> 1. I'll move the proposal to the Swift Testing template and open a PR against  
> swift-evolution under `proposals/testing/`. Should it be a draft PR until  
> the design settles?

The Testing Workgroup is likely going to ignore a draft proposal on the assumption you're not ready for us to review it. Whether or not your PR is a draft should therefore depend on whether or not you consider it ready for review.

I would _strongly_ recommend you do not use an LLM to author your entire proposal, by the way. The LLM will excel at describing the implementation details of your PRs, but those are not important to the proposal process. We want to know why you're proposing a change, the public interface of the change, and how the proposed change will benefit the Swift ecosystem.

---

<div class="post-metadata">

**Author:** ![letsgobjones](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/letsgobjones/32/45625_2.png) [@letsgobjones](https://forums.swift.org/u/letsgobjones)\
**Post date:** [October 14, 2026, 1:20am UTC](https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032/5 "2026-10-14T01:20:51Z")

</div>

> [@grynspan](#):
>
> I would _strongly_ recommend you do not use an LLM to author your entire proposal, by the way. The LLM will excel at describing the implementation details of your PRs, but those are not important to the proposal process. We want to know why you're proposing a change, the public interface of the change, and how the proposed change will benefit the Swift ecosystem.

Understood.

When I resubmit I will describe how it will benefit the Swift community and ecosystem in more detail. I thought it had to be more "technical", so my apologies on that.

I appreciate the feedback.  
And thank you for answering my other questions too. 🙏

---

<div class="post-metadata">

**Author:** ![smontgomery](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/smontgomery/32/965_2.png) [@smontgomery](https://forums.swift.org/u/smontgomery)\
**Post date:** [October 19, 2026, 7:37pm UTC](https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032/6 "2026-10-19T19:37:33Z")

</div>

I definitely think the feature is worthwhile overall. IMO it should support _both_ listing the unique tags standalone _and_ listing the tags associated with each test. The former could be via a new subcommand like `swift test list tags`, and for the latter, I like the `--include-tags` flag on `swift test list` that you suggested in the Alternatives Considered. I think it would make the proposal more well-rounded to cover both use cases.

I agree with @grynspan that the implementation of this feature should involve Swift Testing, and it would likely be more efficient to expose specific hooks for querying this info.

---

<div class="post-metadata">

**Author:** ![maartene](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/maartene/32/42076_2.png) [@maartene](https://forums.swift.org/u/maartene)\
**Post date:** [November 2, 2026, 9:37pm UTC](https://forums.swift.org/t/pitch-list-swift-testing-tags-with-swift-test-list-tags/90032/7 "2026-11-02T21:37:39Z")

</div>

Hi @letsgobjones

Thanks for drafting this proposal!

My main question is: how/where would you use this information in this format? What use cases are you looking at?
