Skip to content

Commit 0e93697

Browse files
John ButeJohn Bute
John Bute
authored and
John Bute
committed
fixed bug where .build directory was not built yet when testing spm
1 parent f9d259d commit 0e93697

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Sources/Basics/Concurrency/PID.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ public struct PIDFile: PIDFileHandler {
6868

6969
/// Write .pid file containing PID of process currently using .build directory
7070
public func writePID(pid: pid_t) throws {
71+
let parent = self.lockFilePath.parentDirectory
72+
try FileManager.default.createDirectory(
73+
at: parent.asURL,
74+
withIntermediateDirectories: true,
75+
attributes: nil
76+
)
77+
7178
try "\(pid)".write(to: self.lockFilePath.asURL, atomically: true, encoding: .utf8)
7279
}
7380

Sources/CoreCommands/SwiftCommandState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,14 +1074,14 @@ public final class SwiftCommandState {
10741074
if self.options.locations.ignoreLock {
10751075
self.outputStream
10761076
.write(
1077-
"Another instance of SwiftPM (pid \(pidInfo)) is already running using '\(self.scratchDirectory)', but this will be ignored since `--ignore-lock` has been passed"
1077+
"Another instance of SwiftPM \(pidInfo) is already running using '\(self.scratchDirectory)', but this will be ignored since `--ignore-lock` has been passed"
10781078
.utf8
10791079
)
10801080
self.outputStream.flush()
10811081
} else {
10821082
self.outputStream
10831083
.write(
1084-
"Another instance of SwiftPM (pid \(pidInfo)) is already running using '\(self.scratchDirectory)', waiting until that process has finished execution..."
1084+
"Another instance of SwiftPM \(pidInfo) is already running using '\(self.scratchDirectory)', waiting until that process has finished execution..."
10851085
.utf8
10861086
)
10871087
self.outputStream.flush()

Tests/CommandsTests/SwiftCommandStateTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ final class SwiftCommandStateTests: CommandsTestCase {
539539
let scratchPath = tmpDir.appending(component: "scratch")
540540
try localFileSystem.createDirectory(scratchPath)
541541

542-
var pidHandler = PIDFile(scratchDirectory: scratchPath)
542+
let pidHandler = PIDFile(scratchDirectory: scratchPath)
543543

544544
// Ensure no PID file exists initially
545545
XCTAssertNil(pidHandler.readPID(), "No PID should exist initially")

0 commit comments

Comments
 (0)