Skip to content

Commit 2da283b

Browse files
committed
Fix two cases where we weren’t cleaning up test scratch directories
1 parent d439d12 commit 2da283b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Sources/SKTestSupport/SwiftPMDependencyProject.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ import struct TSCBasic.ProcessResult
2222
/// A SwiftPM package that gets written to disk and for which a Git repository is initialized with a commit tagged
2323
/// `1.0.0`. This repository can then be used as a dependency for another package, usually a `SwiftPMTestProject`.
2424
public class SwiftPMDependencyProject {
25+
/// The scratch directory created for the dependency project.
26+
public let scratchDirectory: URL
27+
2528
/// The directory in which the repository lives.
26-
public let packageDirectory: URL
29+
public var packageDirectory: URL {
30+
return scratchDirectory.appendingPathComponent("MyDependency")
31+
}
2732

2833
private func runGitCommand(_ arguments: [String], workingDirectory: URL) async throws {
2934
enum Error: Swift.Error {
@@ -66,7 +71,7 @@ public class SwiftPMDependencyProject {
6671
manifest: String = defaultPackageManifest,
6772
testName: String = #function
6873
) async throws {
69-
packageDirectory = try testScratchDir(testName: testName).appendingPathComponent("MyDependency")
74+
scratchDirectory = try testScratchDir(testName: testName)
7075

7176
var files = files
7277
files["Package.swift"] = manifest
@@ -94,7 +99,7 @@ public class SwiftPMDependencyProject {
9499

95100
deinit {
96101
if cleanScratchDirectories {
97-
try? FileManager.default.removeItem(at: packageDirectory)
102+
try? FileManager.default.removeItem(at: scratchDirectory)
98103
}
99104
}
100105

Tests/SourceKitLSPTests/IndexTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ final class IndexTests: XCTestCase {
120120
2️⃣foo()
121121
}
122122
""",
123+
workspaceDirectory: workspaceDirectory,
123124
cleanUp: cleanUp
124125
)
125126

0 commit comments

Comments
 (0)