@@ -272,70 +272,71 @@ final class SwiftSourceKitPluginTests: XCTestCase {
272
272
}
273
273
274
274
func testCancellation( ) async throws {
275
- try await SkipUnless . sourcekitdSupportsPlugin ( )
276
- let sourcekitd = try await getSourceKitD ( )
277
- let path = scratchFilePath ( )
278
- let positions = try await sourcekitd. openDocument (
279
- path,
280
- contents: """
281
- struct A: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
282
- struct B: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
283
- struct C: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
284
-
285
- func + (lhs: A, rhs: B) -> A { fatalError() }
286
- func + (lhs: B, rhs: C) -> A { fatalError() }
287
- func + (lhs: C, rhs: A) -> A { fatalError() }
288
-
289
- func + (lhs: B, rhs: A) -> B { fatalError() }
290
- func + (lhs: C, rhs: B) -> B { fatalError() }
291
- func + (lhs: A, rhs: C) -> B { fatalError() }
292
-
293
- func + (lhs: C, rhs: B) -> C { fatalError() }
294
- func + (lhs: B, rhs: C) -> C { fatalError() }
295
- func + (lhs: A, rhs: A) -> C { fatalError() }
296
-
297
- class Foo {
298
- func slow(x: Invalid1, y: Invalid2) {
299
- let x: C = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 1️⃣
300
- }
301
-
302
- struct Foo {
303
- let fooMember: String
275
+ for _ in 0 ..< 10_000 {
276
+ let sourcekitd = try await getSourceKitD ( )
277
+ let path = scratchFilePath ( )
278
+ let positions = try await sourcekitd. openDocument (
279
+ path,
280
+ contents: """
281
+ struct A: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
282
+ struct B: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
283
+ struct C: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
284
+
285
+ func + (lhs: A, rhs: B) -> A { fatalError() }
286
+ func + (lhs: B, rhs: C) -> A { fatalError() }
287
+ func + (lhs: C, rhs: A) -> A { fatalError() }
288
+
289
+ func + (lhs: B, rhs: A) -> B { fatalError() }
290
+ func + (lhs: C, rhs: B) -> B { fatalError() }
291
+ func + (lhs: A, rhs: C) -> B { fatalError() }
292
+
293
+ func + (lhs: C, rhs: B) -> C { fatalError() }
294
+ func + (lhs: B, rhs: C) -> C { fatalError() }
295
+ func + (lhs: A, rhs: A) -> C { fatalError() }
296
+
297
+ class Foo {
298
+ func slow(x: Invalid1, y: Invalid2) {
299
+ let x: C = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 1️⃣
300
+ }
301
+
302
+ struct Foo {
303
+ let fooMember: String
304
+ }
305
+
306
+ func fast(a: Foo) {
307
+ a.2️⃣
308
+ }
304
309
}
310
+ """ ,
311
+ compilerArguments: [ path]
312
+ )
305
313
306
- func fast(a: Foo) {
307
- a.2️⃣
308
- }
314
+ let slowCompletionResultReceived = self . expectation ( description: " slow completion " )
315
+ let slowCompletionTask = Task {
316
+ do {
317
+ _ = try await sourcekitd. completeOpen (
318
+ path: path,
319
+ position: positions [ " 1️⃣ " ] ,
320
+ filter: " "
321
+ )
322
+ XCTFail ( " Expected completion to be cancelled " )
323
+ } catch {
324
+ XCTAssert ( error is CancellationError , " Expected completion to be cancelled, failed with \( error) " )
309
325
}
310
- """ ,
311
- compilerArguments: [ path]
312
- )
313
-
314
- let slowCompletionResultReceived = self . expectation ( description: " slow completion " )
315
- let slowCompletionTask = Task {
316
- do {
317
- _ = try await sourcekitd. completeOpen (
318
- path: path,
319
- position: positions [ " 1️⃣ " ] ,
320
- filter: " "
321
- )
322
- XCTFail ( " Expected completion to be cancelled " )
323
- } catch {
324
- XCTAssert ( error is CancellationError , " Expected completion to be cancelled, failed with \( error) " )
326
+ slowCompletionResultReceived. fulfill ( )
325
327
}
326
- slowCompletionResultReceived. fulfill ( )
327
- }
328
- slowCompletionTask. cancel ( )
329
- try await fulfillmentOfOrThrow ( [ slowCompletionResultReceived] , timeout: 30 )
328
+ slowCompletionTask. cancel ( )
329
+ try await fulfillmentOfOrThrow ( [ slowCompletionResultReceived] , timeout: 30 )
330
330
331
- let fastCompletionStarted = Date ( )
332
- let result = try await sourcekitd. completeOpen (
333
- path: path,
334
- position: positions [ " 2️⃣ " ] ,
335
- filter: " "
336
- )
337
- XCTAssert ( result. items. count > 0 )
338
- XCTAssertLessThan ( Date ( ) . timeIntervalSince ( fastCompletionStarted) , 30 )
331
+ let fastCompletionStarted = Date ( )
332
+ let result = try await sourcekitd. completeOpen (
333
+ path: path,
334
+ position: positions [ " 2️⃣ " ] ,
335
+ filter: " "
336
+ )
337
+ XCTAssert ( result. items. count > 0 )
338
+ XCTAssertLessThan ( Date ( ) . timeIntervalSince ( fastCompletionStarted) , 30 )
339
+ }
339
340
}
340
341
341
342
func testEdits( ) async throws {
0 commit comments