Skip to content

Commit fb67bfc

Browse files
Workaround SwiftPM API breakage checker limitation (#1211)
### Motivation In order to address a hanging integration test on newer Swift versions, #1208 added a target dependency on the executable used in the multi-node test plugin and stopped shelling out to `swift run`. This addressed the hang, but it has surfaced another issue: that SwiftPM's API breakage checker has issues with some packages that contain plugins, and now that pipeline is reproducibly resulting in false positives. ### Modifications This patch removes that dependency in the package manifest and reverts to running it from within the plugin. There was already code in the plugin to build the package and locate the required binary in the built artifacts, which I hadn't noticed in the previous patch, so the use of `swift run` seemed unnecessary. This patch just executes that found executable without `swift run`, which (hopefully) resolves both issues. ### Result: - Integration test should run to completion on all Swift versions (not hang on 6+) - API breakage pipeline should pass.
1 parent 3b9eef6 commit fb67bfc

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

Package.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ var targets: [PackageDescription.Target] = [
9393
// permissions: needs full network access
9494
),
9595
dependencies: [
96-
"MultiNodeTestKitRunner"
96+
/// NOTE: Usually a Swift package plugin would declare any internal executable targets it depends on here
97+
/// and make use of them from the context passed in by SwiftPM. However, this causes issues when
98+
/// running the API breakage checker on this package, for unrelated reasons. So this command plugin is
99+
/// building the package itself as part of its run.
97100
]
98101
),
99102
.target(

Plugins/MultiNodeTestPlugin/plugin.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ final class MultiNodeTestPlugin: CommandPlugin {
3939
}
4040
}
4141

42-
// Find the executable dependency frome the plugin context.
43-
let tool = try context.tool(named: "MultiNodeTestKitRunner")
42+
let toolName = "MultiNodeTestKitRunner"
4443

4544
// Terminate all previous runners
46-
Process.killall(name: tool.name)
45+
Process.killall(name: toolName)
4746

4847
switch self.buildConfiguration {
4948
case .debug:
@@ -66,22 +65,19 @@ final class MultiNodeTestPlugin: CommandPlugin {
6665

6766
let multiNodeRunner = buildResult.builtArtifacts
6867
.filter { $0.kind == .executable }
69-
.first { $0.path.lastComponent.starts(with: "MultiNodeTestKitRunner") }
68+
.first { $0.path.lastComponent.starts(with: toolName) }
7069
guard let multiNodeRunner = multiNodeRunner else {
7170
throw MultiNodeTestPluginError(message: "Failed")
7271
}
7372

7473
log("Detected multi-node test runner: \(multiNodeRunner.path.lastComponent)")
7574

7675
let process = Process()
77-
process.binaryPath = tool.path.string
78-
process.arguments = []
79-
for arg in arguments {
80-
process.arguments?.append(arg)
81-
}
76+
process.binaryPath = multiNodeRunner.path.string
77+
process.arguments = arguments
8278

8379
do {
84-
log("> \(tool.name) \(process.arguments?.joined(separator: " ") ?? "")")
80+
log("> \(toolName) \(process.arguments?.joined(separator: " ") ?? "")")
8581
try process.runProcess()
8682
process.waitUntilExit()
8783
} catch {

0 commit comments

Comments
 (0)