Skip to content

Tests: use FileManager instead of cp #4872

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
Apr 5, 2023
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
8 changes: 8 additions & 0 deletions IntegrationTests/Tests/IntegrationTests/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ func fixture(
if localFileSystem.isFile(fixtureDir.appending(component: "Package.swift")) {
// It's a single package, so copy the whole directory as-is.
let dstDir = tmpDirPath.appending(component: copyName)
#if os(Windows)
try localFileSystem.copy(from: fixtureDir, to: dstDir)
#else
try systemQuietly("cp", "-R", "-H", fixtureDir.pathString, dstDir.pathString)
#endif

// Invoke the block, passing it the path of the copied fixture.
try body(dstDir)
Expand All @@ -231,7 +235,11 @@ func fixture(
let srcDir = fixtureDir.appending(component: fileName)
guard localFileSystem.isDirectory(srcDir) else { continue }
let dstDir = tmpDirPath.appending(component: fileName)
#if os(Windows)
try localFileSystem.copy(from: srcDir, to: dstDir)
#else
try systemQuietly("cp", "-R", "-H", srcDir.pathString, dstDir.pathString)
#endif
initGitRepo(dstDir, tag: "1.2.3", addFile: false)
}

Expand Down
8 changes: 8 additions & 0 deletions Sources/SPMTestSupport/misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ public func fixture(
if localFileSystem.isFile(fixtureDir.appending(component: "Package.swift")) {
// It's a single package, so copy the whole directory as-is.
let dstDir = tmpDirPath.appending(component: copyName)
#if os(Windows)
try localFileSystem.copy(from: fixtureDir, to: dstDir)
#else
try systemQuietly("cp", "-R", "-H", fixtureDir.pathString, dstDir.pathString)
#endif

// Invoke the block, passing it the path of the copied fixture.
try body(dstDir)
Expand All @@ -79,7 +83,11 @@ public func fixture(
let srcDir = fixtureDir.appending(component: fileName)
guard localFileSystem.isDirectory(srcDir) else { continue }
let dstDir = tmpDirPath.appending(component: fileName)
#if os(Windows)
try localFileSystem.copy(from: srcDir, to: dstDir)
#else
try systemQuietly("cp", "-R", "-H", srcDir.pathString, dstDir.pathString)
#endif
if createGitRepo {
initGitRepo(dstDir, tag: "1.2.3", addFile: false)
}
Expand Down