Skip to content

Commit 848924e

Browse files
authored
Stop build if there were build-tool plugin failures (#5946)
rdar://102989296
1 parent 835bdac commit 848924e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sources/Build/BuildOperation.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
405405
)
406406

407407
// Surface any diagnostics from build tool plugins.
408+
var succeeded = true
408409
for (target, results) in buildToolPluginInvocationResults {
409410
// There is one result for each plugin that gets applied to a target.
410411
for result in results {
@@ -420,9 +421,14 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
420421
for diag in result.diagnostics {
421422
diagnosticsEmitter.emit(diag)
422423
}
424+
succeeded = succeeded && result.succeeded
423425
}
424426
}
425427

428+
if !succeeded {
429+
throw StringError("build stopped due to build-tool plugin failures")
430+
}
431+
426432
// Run any prebuild commands provided by build tool plugins. Any failure stops the build.
427433
let prebuildCommandResults = try graph.reachableTargets.reduce(into: [:], { partial, target in
428434
partial[target] = try buildToolPluginInvocationResults[target].map { try self.runPrebuildCommands(for: $0) }

Tests/CommandsTests/PackageToolTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ final class PackageToolTests: CommandsTestCase {
14081408
XCTAssertNotEqual(result.exitStatus, .terminated(code: 0), "output: \(output)")
14091409
XCTAssertMatch(output, .contains("This is text from the plugin"))
14101410
XCTAssertMatch(output, .contains("error: This is an error from the plugin"))
1411-
XCTAssertMatch(output, .contains("Build complete!"))
1411+
XCTAssertMatch(output, .contains("build stopped due to build-tool plugin failures"))
14121412
}
14131413
}
14141414

0 commit comments

Comments
 (0)