Skip to content

Commit 72e6dd5

Browse files
committed
Support statically defined tags
To remove namespacing ambiguity, support statically defined tags only.
1 parent 172df77 commit 72e6dd5

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Sources/SourceKitLSP/Swift/SwiftTestingScanner.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ struct TestingAttributeData {
103103
} else if components.starts(with: ["Tag"]) {
104104
components = components.dropFirst(1)
105105
}
106-
return components.joined(separator: ".")
106+
107+
// Tags.foo resolves to ".foo", Tags.Nested.foo resolves to "Nested.foo"
108+
let prefix = components.count == 1 ? "." : ""
109+
return "\(prefix)\(components.joined(separator: "."))"
107110
}
108111
return nil
109112
}

Tests/SourceKitLSPTests/DocumentTestDiscoveryTests.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ final class DocumentTestDiscoveryTests: XCTestCase {
585585
)
586586
}
587587

588-
func testSwiftTestingTestWithStringTags() async throws {
588+
func testSwiftTestingTestWithTags() async throws {
589589
let testClient = try await TestSourceKitLSPClient()
590590
let uri = DocumentURI.for(.swift)
591591

@@ -622,7 +622,7 @@ final class DocumentTestDiscoveryTests: XCTestCase {
622622
style: TestStyle.swiftTesting,
623623
location: Location(uri: uri, range: positions["2️⃣"]..<positions["3️⃣"]),
624624
children: [],
625-
tags: [TestTag(id: "red"), TestTag(id: "blue")]
625+
tags: [TestTag(id: ".red"), TestTag(id: ".blue")]
626626
)
627627
],
628628
tags: [TestTag(id: "green")]
@@ -702,6 +702,7 @@ final class DocumentTestDiscoveryTests: XCTestCase {
702702
import Testing
703703
704704
extension Tag {
705+
@Tag static var suite: Self
705706
@Tag static var foo: Self
706707
@Tag static var bar: Self
707708
@Tag static var baz: Self
@@ -711,7 +712,7 @@ final class DocumentTestDiscoveryTests: XCTestCase {
711712
}
712713
}
713714
714-
1️⃣@Suite(.tags("Suites"))
715+
1️⃣@Suite(.tags(.suite))
715716
struct MyTests {
716717
2️⃣@Test(.tags(.foo, Nested.foo, Testing.Tag.bar, Tag.baz))
717718
func oneIsTwo() {
@@ -740,10 +741,15 @@ final class DocumentTestDiscoveryTests: XCTestCase {
740741
style: TestStyle.swiftTesting,
741742
location: Location(uri: uri, range: positions["2️⃣"]..<positions["3️⃣"]),
742743
children: [],
743-
tags: [TestTag(id: "foo"), TestTag(id: "Nested.foo"), TestTag(id: "bar"), TestTag(id: "baz")]
744+
tags: [
745+
TestTag(id: ".foo"),
746+
TestTag(id: "Nested.foo"),
747+
TestTag(id: ".bar"),
748+
TestTag(id: ".baz")
749+
]
744750
)
745751
],
746-
tags: [TestTag(id: "Suites")]
752+
tags: [TestTag(id: ".suite")]
747753
)
748754
]
749755
)

0 commit comments

Comments
 (0)