@@ -51,7 +51,7 @@ public enum SkipUnless {
51
51
/// guaranteed to be up-to-date.
52
52
private static func skipUnlessSupportedByToolchain(
53
53
swiftVersion: SwiftVersion ,
54
- featureName: String ,
54
+ featureName: String = #function ,
55
55
file: StaticString ,
56
56
line: UInt ,
57
57
featureCheck: ( ) async throws -> Bool
@@ -99,12 +99,7 @@ public enum SkipUnless {
99
99
file: StaticString = #file,
100
100
line: UInt = #line
101
101
) async throws {
102
- try await skipUnlessSupportedByToolchain (
103
- swiftVersion: SwiftVersion ( 5 , 11 ) ,
104
- featureName: " semantic token support in sourcekitd " ,
105
- file: file,
106
- line: line
107
- ) {
102
+ try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
108
103
let testClient = try await TestSourceKitLSPClient ( )
109
104
let uri = DocumentURI . for ( . swift)
110
105
testClient. openDocument ( " 0.bitPattern " , uri: uri)
@@ -134,12 +129,7 @@ public enum SkipUnless {
134
129
file: StaticString = #file,
135
130
line: UInt = #line
136
131
) async throws {
137
- try await skipUnlessSupportedByToolchain (
138
- swiftVersion: SwiftVersion ( 5 , 11 ) ,
139
- featureName: " rename support in sourcekitd " ,
140
- file: file,
141
- line: line
142
- ) {
132
+ try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
143
133
let testClient = try await TestSourceKitLSPClient ( )
144
134
let uri = DocumentURI . for ( . swift)
145
135
let positions = testClient. openDocument ( " func 1️⃣test() {} " , uri: uri)
@@ -159,12 +149,7 @@ public enum SkipUnless {
159
149
file: StaticString = #file,
160
150
line: UInt = #line
161
151
) async throws {
162
- try await skipUnlessSupportedByToolchain (
163
- swiftVersion: SwiftVersion ( 5 , 11 ) ,
164
- featureName: " rename support in clangd " ,
165
- file: file,
166
- line: line
167
- ) {
152
+ try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
168
153
let testClient = try await TestSourceKitLSPClient ( )
169
154
let uri = DocumentURI . for ( . c)
170
155
let positions = testClient. openDocument ( " void 1️⃣test() {} " , uri: uri)
@@ -194,12 +179,7 @@ public enum SkipUnless {
194
179
file: StaticString = #file,
195
180
line: UInt = #line
196
181
) async throws {
197
- try await skipUnlessSupportedByToolchain (
198
- swiftVersion: SwiftVersion ( 5 , 11 ) ,
199
- featureName: " SwiftPM stores modules in subdirectory " ,
200
- file: file,
201
- line: line
202
- ) {
182
+ try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
203
183
let workspace = try await SwiftPMTestWorkspace (
204
184
files: [ " test.swift " : " " ] ,
205
185
build: true
@@ -217,16 +197,40 @@ public enum SkipUnless {
217
197
file: StaticString = #file,
218
198
line: UInt = #line
219
199
) async throws {
220
- try await skipUnlessSupportedByToolchain (
221
- swiftVersion: SwiftVersion ( 5 , 11 ) ,
222
- featureName: " Toolchain contains swift-format " ,
223
- file: file,
224
- line: line
225
- ) {
200
+ try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 5 , 11 ) , file: file, line: line) {
226
201
return await ToolchainRegistry . forTesting. default? . swiftFormat != nil
227
202
}
228
203
}
229
204
205
+ public static func sourcekitdReturnsRawDocumentationResponse(
206
+ file: StaticString = #file,
207
+ line: UInt = #line
208
+ ) async throws {
209
+ struct ExpectedMarkdownContentsError : Error { }
210
+
211
+ return try await skipUnlessSupportedByToolchain ( swiftVersion: SwiftVersion ( 6 , 0 ) , file: file, line: line) {
212
+ // The XML-based doc comment conversion did not preserve `Precondition`.
213
+ let testClient = try await TestSourceKitLSPClient ( )
214
+ let uri = DocumentURI . for ( . swift)
215
+ let positions = testClient. openDocument (
216
+ """
217
+ /// - Precondition: Must have an apple
218
+ func 1️⃣test() {}
219
+ """ ,
220
+ uri: uri
221
+ )
222
+ let response = try await testClient. send (
223
+ HoverRequest ( textDocument: TextDocumentIdentifier ( uri) , position: positions [ " 1️⃣ " ] )
224
+ )
225
+ let hover = try XCTUnwrap ( response, file: file, line: line)
226
+ XCTAssertNil ( hover. range, file: file, line: line)
227
+ guard case . markupContent( let content) = hover. contents else {
228
+ throw ExpectedMarkdownContentsError ( )
229
+ }
230
+ return content. value. contains ( " Precondition " )
231
+ }
232
+ }
233
+
230
234
public static func longTestsEnabled( ) throws {
231
235
if let value = ProcessInfo . processInfo. environment [ " SKIP_LONG_TESTS " ] , value == " 1 " || value == " YES " {
232
236
throw XCTSkip ( " Long tests disabled using the `SKIP_LONG_TESTS` environment variable " )
@@ -295,7 +299,7 @@ private func getSwiftVersion(_ swiftcPath: AbsolutePath) async throws -> SwiftVe
295
299
let result = try await process. waitUntilExit ( )
296
300
let output = String ( bytes: try result. output. get ( ) , encoding: . utf8)
297
301
let regex = Regex {
298
- " Apple Swift version "
302
+ " Swift version "
299
303
Capture { OneOrMore ( . digit) }
300
304
" . "
301
305
Capture { OneOrMore ( . digit) }
0 commit comments