Skip to content

Fix two cases where we weren’t cleaning up test scratch directories #1383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Sources/SKTestSupport/SwiftPMDependencyProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ import struct TSCBasic.ProcessResult
/// A SwiftPM package that gets written to disk and for which a Git repository is initialized with a commit tagged
/// `1.0.0`. This repository can then be used as a dependency for another package, usually a `SwiftPMTestProject`.
public class SwiftPMDependencyProject {
/// The scratch directory created for the dependency project.
public let scratchDirectory: URL

/// The directory in which the repository lives.
public let packageDirectory: URL
public var packageDirectory: URL {
return scratchDirectory.appendingPathComponent("MyDependency")
}

private func runGitCommand(_ arguments: [String], workingDirectory: URL) async throws {
enum Error: Swift.Error {
Expand Down Expand Up @@ -66,7 +71,7 @@ public class SwiftPMDependencyProject {
manifest: String = defaultPackageManifest,
testName: String = #function
) async throws {
packageDirectory = try testScratchDir(testName: testName).appendingPathComponent("MyDependency")
scratchDirectory = try testScratchDir(testName: testName)

var files = files
files["Package.swift"] = manifest
Expand Down Expand Up @@ -94,7 +99,7 @@ public class SwiftPMDependencyProject {

deinit {
if cleanScratchDirectories {
try? FileManager.default.removeItem(at: packageDirectory)
try? FileManager.default.removeItem(at: scratchDirectory)
}
}

Expand Down
1 change: 1 addition & 0 deletions Tests/SourceKitLSPTests/IndexTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ final class IndexTests: XCTestCase {
2️⃣foo()
}
""",
workspaceDirectory: workspaceDirectory,
cleanUp: cleanUp
)

Expand Down