Skip to content

Commit 64e1f9d

Browse files
authored
Apply the 'traitRelated' tag to more tests and suites (#1199)
This is a small, test-only enhancement which applies the `.traitRelated` tag to more tests and suites which are related to specific traits or the trait subsystem. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 0022e29 commit 64e1f9d

File tree

7 files changed

+26
-6
lines changed

7 files changed

+26
-6
lines changed

Tests/TestingMacrosTests/TestDeclarationMacroTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ struct TestDeclarationMacroTests {
452452
}
453453

454454
@Test("Valid tag expressions are allowed",
455+
.tags(.traitRelated),
455456
arguments: [
456457
#"@Test(.tags(.f)) func f() {}"#,
457458
#"@Test(Tag.List.tags(.f)) func f() {}"#,
@@ -472,6 +473,7 @@ struct TestDeclarationMacroTests {
472473
}
473474

474475
@Test("Invalid tag expressions are detected",
476+
.tags(.traitRelated),
475477
arguments: [
476478
"f()", ".f()", "loose",
477479
"WrongType.tag", "WrongType.f()",
@@ -490,6 +492,7 @@ struct TestDeclarationMacroTests {
490492
}
491493

492494
@Test("Valid bug identifiers are allowed",
495+
.tags(.traitRelated),
493496
arguments: [
494497
#"@Test(.bug(id: 12345)) func f() {}"#,
495498
#"@Test(.bug(id: "12345")) func f() {}"#,
@@ -512,6 +515,7 @@ struct TestDeclarationMacroTests {
512515
}
513516

514517
@Test("Invalid bug URLs are detected",
518+
.tags(.traitRelated),
515519
arguments: [
516520
"mailto: [email protected]", "example.com",
517521
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// This source file is part of the Swift.org open source project
3+
//
4+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
5+
// Licensed under Apache License v2.0 with Runtime Library Exception
6+
//
7+
// See https://swift.org/LICENSE.txt for license information
8+
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
//
10+
11+
import Testing
12+
13+
extension Tag {
14+
/// A tag indicating that a test is related to a trait.
15+
@Tag static var traitRelated: Self
16+
}

Tests/TestingTests/PlanTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ struct PlanTests {
369369
#expect(!planTests.contains(testC))
370370
}
371371

372-
@Test("Recursive trait application")
372+
@Test("Recursive trait application", .tags(.traitRelated))
373373
func recursiveTraitApplication() async throws {
374374
let outerTestType = try #require(await test(for: OuterTest.self))
375375
// Intentionally omitting intermediate tests here...
@@ -387,7 +387,7 @@ struct PlanTests {
387387
#expect(testWithTraitAdded.traits.contains { $0 is DummyRecursiveTrait })
388388
}
389389

390-
@Test("Relative order of recursively applied traits")
390+
@Test("Relative order of recursively applied traits", .tags(.traitRelated))
391391
func recursiveTraitOrder() async throws {
392392
let testSuiteA = try #require(await test(for: RelativeTraitOrderingTests.A.self))
393393
let testSuiteB = try #require(await test(for: RelativeTraitOrderingTests.A.B.self))

Tests/TestingTests/SwiftPMTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct SwiftPMTests {
133133
#expect(planTests.contains(test2))
134134
}
135135

136-
@Test(".hidden trait")
136+
@Test(".hidden trait", .tags(.traitRelated))
137137
func hidden() async throws {
138138
let configuration = try configurationForEntryPoint(withArguments: ["PATH"])
139139
let test1 = Test(name: "hello") {}

Tests/TestingTests/Test.SnapshotTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct Test_SnapshotTests {
9898
private static let bug: Bug = Bug.bug(id: 12345, "Lorem ipsum")
9999

100100
@available(_clockAPI, *)
101-
@Test("timeLimit property", _timeLimitIfAvailable(minutes: 999_999_999))
101+
@Test("timeLimit property", .tags(.traitRelated), _timeLimitIfAvailable(minutes: 999_999_999))
102102
func timeLimit() async throws {
103103
let test = try #require(Test.current)
104104
let snapshot = Test.Snapshot(snapshotting: test)

Tests/TestingTests/Traits/IssueHandlingTraitTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@testable @_spi(Experimental) @_spi(ForToolsIntegrationOnly) import Testing
1212

13-
@Suite("IssueHandlingTrait Tests")
13+
@Suite("IssueHandlingTrait Tests", .tags(.traitRelated))
1414
struct IssueHandlingTraitTests {
1515
@Test("Transforming an issue by appending a comment")
1616
func addComment() async throws {

Tests/TestingTests/Traits/TestScopingTraitTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@testable @_spi(Experimental) @_spi(ForToolsIntegrationOnly) import Testing
1212

13-
@Suite("TestScoping-conforming Trait Tests")
13+
@Suite("TestScoping-conforming Trait Tests", .tags(.traitRelated))
1414
struct TestScopingTraitTests {
1515
@Test("Execute code before and after a non-parameterized test.")
1616
func executeCodeBeforeAndAfterNonParameterizedTest() async {

0 commit comments

Comments
 (0)