Skip to content

Commit ff4d19a

Browse files
committed
fix "build complete" message
motivation: print "build complete" message reliably changes: * move the logic to printg the "build complete" message to the build complete handler * add tests rdar://77669218
1 parent 7cd58d6 commit ff4d19a

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

Sources/Build/BuildDelegate.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,26 @@ public final class BuildDelegate: BuildSystemDelegate, SwiftCompilerOutputParser
575575
onCommmandFailure?()
576576
}
577577

578+
func buildComplete(success: Bool) {
579+
queue.sync {
580+
if success {
581+
self.progressAnimation.update(
582+
step: self.taskTracker.finishedCount,
583+
total: self.taskTracker.totalCount,
584+
text: "Build complete!")
585+
}
586+
self.progressAnimation.complete(success: success)
587+
}
588+
}
589+
590+
// MARK: Private
578591
private func updateProgress() {
579592
if let progressText = taskTracker.latestFinishedText {
580-
progressAnimation.update(
593+
self.progressAnimation.update(
581594
step: taskTracker.finishedCount,
582595
total: taskTracker.totalCount,
583-
text: progressText)
596+
text: progressText
597+
)
584598
}
585599
}
586600
}
@@ -603,13 +617,6 @@ fileprivate struct CommandTaskTracker {
603617
totalCount -= 1
604618
break
605619
case .isComplete:
606-
if (totalCount == finishedCount) {
607-
let latestOutput: String? = latestFinishedText
608-
latestFinishedText = """
609-
\(latestOutput ?? "")\n
610-
* Build Completed!
611-
"""
612-
}
613620
break
614621
@unknown default:
615622
assertionFailure("unhandled command status kind \(kind) for command \(command)")

Sources/Build/BuildOperation.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
116116
let llbuildTarget = try computeLLBuildTargetName(for: subset)
117117
let success = buildSystem.build(target: llbuildTarget)
118118

119-
buildDelegate?.progressAnimation.complete(success: success)
119+
buildDelegate?.buildComplete(success: success)
120+
120121
guard success else { throw Diagnostics.fatalError }
121122

122-
// Create backwards-compatibilty symlink to old build path.
123+
// Create backwards-compatibility symlink to old build path.
123124
let oldBuildPath = buildParameters.dataPath.parentDirectory.appending(
124125
component: buildParameters.configuration.dirname
125126
)

Tests/CommandsTests/BuildToolTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,22 @@ final class BuildToolTests: XCTestCase {
242242
}
243243
}
244244
}
245+
246+
func testBuildCompleteMessage() {
247+
fixture(name: "DependencyResolution/Internal/Simple") { path in
248+
do {
249+
let result = try execute([], packagePath: path)
250+
#if os(macOS)
251+
XCTAssertTrue(result.stdout.contains("[6/6] Build complete!"), result.stdout)
252+
#else
253+
XCTAssertTrue(result.stdout.contains("[8/8] Build complete!"), result.stdout)
254+
#endif
255+
}
256+
257+
do {
258+
let result = try execute([], packagePath: path)
259+
XCTAssertTrue(result.stdout.contains("[0/0] Build complete!"), result.stdout)
260+
}
261+
}
262+
}
245263
}

0 commit comments

Comments
 (0)