File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public struct IndexedSingleSwiftFileWorkspace {
38
38
_ markedText: String ,
39
39
indexSystemModules: Bool = false ,
40
40
workspaceDirectory: URL ? = nil ,
41
- cleanUp: Bool = true ,
41
+ cleanUp: Bool = cleanScratchDirectories ,
42
42
testName: String = #function
43
43
) async throws {
44
44
let testWorkspaceDirectory = try workspaceDirectory ?? testScratchDir ( testName: testName)
Original file line number Diff line number Diff line change @@ -105,7 +105,9 @@ public class MultiFileTestWorkspace {
105
105
self . testClient = try await TestSourceKitLSPClient (
106
106
workspaceFolders: workspaces ( scratchDirectory) ,
107
107
cleanUp: { [ scratchDirectory] in
108
- try ? FileManager . default. removeItem ( at: scratchDirectory)
108
+ if cleanScratchDirectories {
109
+ try ? FileManager . default. removeItem ( at: scratchDirectory)
110
+ }
109
111
}
110
112
)
111
113
}
Original file line number Diff line number Diff line change @@ -44,15 +44,20 @@ extension DocumentURI {
44
44
}
45
45
}
46
46
47
+ public let cleanScratchDirectories = ( ProcessInfo . processInfo. environment [ " SOURCEKITLSP_KEEP_TEST_SCRATCH_DIR " ] == nil )
48
+
47
49
/// An empty directory in which a test with `#function` name `testName` can store temporary data.
48
50
public func testScratchDir( testName: String = #function) throws -> URL {
49
51
let testBaseName = testName. prefix ( while: \. isLetter)
50
52
53
+ var uuid = UUID ( ) . uuidString [ ... ]
54
+ if let firstDash = uuid. firstIndex ( of: " - " ) {
55
+ uuid = uuid [ ..< firstDash]
56
+ }
51
57
let url = FileManager . default. temporaryDirectory
52
58
. realpath
53
59
. appendingPathComponent ( " sourcekit-lsp-test-scratch " )
54
- . appendingPathComponent ( UUID ( ) . uuidString)
55
- . appendingPathComponent ( String ( testBaseName) )
60
+ . appendingPathComponent ( " \( testBaseName) - \( uuid) " )
56
61
try ? FileManager . default. removeItem ( at: url)
57
62
try FileManager . default. createDirectory ( at: url, withIntermediateDirectories: true )
58
63
return url
You can’t perform that action at this time.
0 commit comments