Skip to content

Commit e1a6b44

Browse files
Fix hang using multi-node package plugin on Swift 6+ (#1208)
1 parent 70b36af commit e1a6b44

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Package.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ var targets: [PackageDescription.Target] = [
9292
intent: .custom(verb: "multi-node", description: "Run MultiNodeTestKit based tests across multiple processes or physical compute nodes")
9393
// permissions: needs full network access
9494
),
95-
dependencies: []
95+
dependencies: [
96+
"MultiNodeTestKitRunner"
97+
]
9698
),
9799
.target(
98100
name: "MultiNodeTestKit",

Plugins/MultiNodeTestPlugin/plugin.swift

+8-5
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ final class MultiNodeTestPlugin: CommandPlugin {
3939
}
4040
}
4141

42+
// Find the executable dependency frome the plugin context.
43+
let tool = try context.tool(named: "MultiNodeTestKitRunner")
44+
4245
// Terminate all previous runners
43-
Process.killall(name: "MultiNodeTestKitRunner")
46+
Process.killall(name: tool.name)
4447

4548
switch self.buildConfiguration {
4649
case .debug:
@@ -71,14 +74,14 @@ final class MultiNodeTestPlugin: CommandPlugin {
7174
log("Detected multi-node test runner: \(multiNodeRunner.path.lastComponent)")
7275

7376
let process = Process()
74-
process.binaryPath = "/usr/bin/swift"
75-
process.arguments = ["run", "MultiNodeTestKitRunner"]
77+
process.binaryPath = tool.path.string
78+
process.arguments = []
7679
for arg in arguments {
7780
process.arguments?.append(arg)
7881
}
7982

8083
do {
81-
log("> swift \(process.arguments?.joined(separator: " ") ?? "")")
84+
log("> \(tool.name) \(process.arguments?.joined(separator: " ") ?? "")")
8285
try process.runProcess()
8386
process.waitUntilExit()
8487
} catch {
@@ -144,7 +147,7 @@ extension Process {
144147
static func killall(name: String) {
145148
let killAllRunners = Process()
146149
killAllRunners.binaryPath = "/usr/bin/killall"
147-
killAllRunners.arguments = ["-9", "MultiNodeTestKitRunner"]
150+
killAllRunners.arguments = ["-9", name]
148151
try? killAllRunners.runProcess()
149152
killAllRunners.waitUntilExit()
150153
}

0 commit comments

Comments
 (0)