@@ -19,32 +19,31 @@ import SKTestSupport
19
19
import SourceKitD
20
20
import XCTest
21
21
22
- import class ISDBTibs. TibsBuilder
23
22
import struct TSCBasic. AbsolutePath
24
23
25
- final class DiagnoseTests : XCTestCase {
26
- /// If a default SDK is present on the test machine, return the `-sdk` argument that can be placed in the request
27
- /// YAML. Otherwise, return an empty string.
28
- private var sdkArg : String {
29
- if let sdk = TibsBuilder . defaultSDKPath {
30
- return """
31
- " -sdk " , " \( sdk) " ,
32
- """
33
- } else {
34
- return " "
35
- }
24
+ /// If a default SDK is present on the test machine, return the `-sdk` argument that can be placed in the request
25
+ /// YAML. Otherwise, return an empty string.
26
+ private let sdkArg : String = {
27
+ if let sdk = defaultSDKPath {
28
+ return """
29
+ " -sdk " , " \( sdk) " ,
30
+ """
31
+ } else {
32
+ return " "
36
33
}
37
-
38
- /// If a default SDK is present on the test machine, return the `-sdk` argument that can be placed in the request
39
- /// YAML. Otherwise , return an empty string.
40
- private var sdkArgs : [ String ] {
41
- if let sdk = TibsBuilder . defaultSDKPath {
42
- return [ " -sdk " , " \( sdk ) " ]
43
- } else {
44
- return [ ]
45
- }
34
+ } ( )
35
+
36
+ /// If a default SDK is present on the test machine , return the `-sdk` argument that can be placed in the request
37
+ /// YAML. Otherwise, return an empty string.
38
+ private let sdkArgs : [ String ] = {
39
+ if let sdk = defaultSDKPath {
40
+ return [ " -sdk " , " \( sdk ) " ]
41
+ } else {
42
+ return [ ]
46
43
}
44
+ } ( )
47
45
46
+ final class DiagnoseTests : XCTestCase {
48
47
func testRemoveCodeItemsAndMembers( ) async throws {
49
48
// We consider the test case reproducing if cursor info returns the two ambiguous results including their doc
50
49
// comments.
@@ -232,25 +231,25 @@ final class DiagnoseTests: XCTestCase {
232
231
private func assertReduceSourceKitD(
233
232
_ markedFileContents: String ,
234
233
request: String ,
235
- reproducerPredicate: @escaping ( String ) -> Bool ,
234
+ reproducerPredicate: @Sendable @ escaping ( String ) -> Bool ,
236
235
expectedReducedFileContents: String ,
237
- file: StaticString = #file ,
236
+ file: StaticString = #filePath ,
238
237
line: UInt = #line
239
238
) async throws {
240
239
let ( markers, fileContents) = extractMarkers ( markedFileContents)
241
240
242
241
let toolchain = try await unwrap ( ToolchainRegistry . forTesting. default)
243
242
logger. debug ( " Using \( toolchain. path? . pathString ?? " <nil> " ) to reduce source file " )
244
- let requestExecutor = try InProcessSourceKitRequestExecutor (
245
- toolchain: toolchain,
246
- reproducerPredicate: NSPredicate ( block: { ( requestResponse, _) -> Bool in
247
- reproducerPredicate ( requestResponse as! String )
248
- } )
249
- )
250
243
251
244
let markerOffset = try XCTUnwrap ( markers [ " 1️⃣ " ] , " Failed to find position marker 1️⃣ in file contents " )
252
245
253
246
try await withTestScratchDir { scratchDir in
247
+ let requestExecutor = try InProcessSourceKitRequestExecutor (
248
+ toolchain: toolchain,
249
+ reproducerPredicate: NSPredicate ( block: { ( requestResponse, _) -> Bool in
250
+ reproducerPredicate ( requestResponse as! String )
251
+ } )
252
+ )
254
253
let testFilePath = scratchDir. appending ( component: " test.swift " ) . pathString
255
254
try fileContents. write ( toFile: testFilePath, atomically: false , encoding: . utf8)
256
255
0 commit comments