Skip to content

Commit 16c30a6

Browse files
authored
Merge pull request #2230 from bnbarham/disable-raw-test-pre-6.2
Only run raw identifier tests for >= 6.2
2 parents 750ddf7 + bd5b6af commit 16c30a6

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

Sources/SKTestSupport/SkipUnless.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,39 @@ package actor SkipUnless {
352352
return .featureSupported
353353
}
354354
}
355+
356+
package static func haveRawIdentifiers(
357+
file: StaticString = #filePath,
358+
line: UInt = #line
359+
) async throws {
360+
return try await shared.skipUnlessSupportedByToolchain(
361+
swiftVersion: SwiftVersion(6, 2),
362+
file: file,
363+
line: line
364+
) {
365+
let testClient = try await TestSourceKitLSPClient()
366+
let uri = DocumentURI(for: .swift)
367+
testClient.openDocument(
368+
"""
369+
let `1 * 1` = 1
370+
_ = `1 * 1`
371+
""",
372+
uri: uri
373+
)
374+
375+
let response = try unwrap(
376+
await testClient.send(DocumentSemanticTokensRequest(textDocument: TextDocumentIdentifier(uri)))
377+
)
378+
379+
let tokens = SyntaxHighlightingTokens(lspEncodedTokens: response.data)
380+
return tokens.tokens.last
381+
== SourceKitLSP.SyntaxHighlightingToken(
382+
range: Position(line: 1, utf16index: 4)..<Position(line: 1, utf16index: 11),
383+
kind: .variable,
384+
modifiers: []
385+
)
386+
}
387+
}
355388
}
356389

357390
// MARK: - Parsing Swift compiler version

Tests/SourceKitLSPTests/DocumentTestDiscoveryTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ final class DocumentTestDiscoveryTests: XCTestCase {
704704
}
705705

706706
func testSwiftTestingTestWithRawIdentifiers() async throws {
707+
try await SkipUnless.haveRawIdentifiers()
708+
707709
let testClient = try await TestSourceKitLSPClient()
708710
let uri = DocumentURI(for: .swift)
709711

@@ -784,6 +786,8 @@ final class DocumentTestDiscoveryTests: XCTestCase {
784786
}
785787

786788
func testSwiftTestingTestWithNestedRawIdentifiers() async throws {
789+
try await SkipUnless.haveRawIdentifiers()
790+
787791
let testClient = try await TestSourceKitLSPClient()
788792
let uri = DocumentURI(for: .swift)
789793

@@ -844,6 +848,8 @@ final class DocumentTestDiscoveryTests: XCTestCase {
844848
}
845849

846850
func testSwiftTestingTestWithNestedRawIdentifiersExtension() async throws {
851+
try await SkipUnless.haveRawIdentifiers()
852+
847853
let testClient = try await TestSourceKitLSPClient()
848854
let uri = DocumentURI(for: .swift)
849855

@@ -909,6 +915,8 @@ final class DocumentTestDiscoveryTests: XCTestCase {
909915
}
910916

911917
func testSwiftTestingTestWithSlashRawIdentifiers() async throws {
918+
try await SkipUnless.haveRawIdentifiers()
919+
912920
let testClient = try await TestSourceKitLSPClient()
913921
let uri = DocumentURI(for: .swift)
914922

Tests/SourceKitLSPTests/SemanticTokensTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,8 @@ final class SemanticTokensTests: XCTestCase {
882882
}
883883

884884
func testRawIdentifier() async throws {
885+
try await SkipUnless.haveRawIdentifiers()
886+
885887
try await assertSemanticTokens(
886888
markedContents: """
887889
1️⃣func 2️⃣`square returns x * x`() {}

0 commit comments

Comments
 (0)