Skip to content

Commit 95c4baa

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
1 parent e2799da commit 95c4baa

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

Bar-1.2.3.zip

476 Bytes
Binary file not shown.

Sources/Build/BuildOperation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
128128
let llbuildTarget = try computeLLBuildTargetName(for: subset)
129129
let success = buildSystem.build(target: llbuildTarget)
130130

131-
buildSystemDelegate?.progressAnimation.complete(success: success)
131+
buildSystemDelegate?.buildComplete(success: success)
132132
delegate?.buildSystem(self, didFinishWithResult: success)
133133
guard success else { throw Diagnostics.fatalError }
134134

135-
// Create backwards-compatibilty symlink to old build path.
135+
// Create backwards-compatibility symlink to old build path.
136136
let oldBuildPath = buildParameters.dataPath.parentDirectory.appending(
137137
component: buildParameters.configuration.dirname
138138
)

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,25 @@ final class BuildOperationBuildSystemDelegateHandler: LLBuildBuildSystemDelegate
608608
onCommmandFailure?()
609609
}
610610

611+
func buildComplete(success: Bool) {
612+
if success {
613+
self.progressAnimation.update(
614+
step: taskTracker.finishedCount,
615+
total: taskTracker.totalCount,
616+
text: "Build complete!")
617+
}
618+
self.progressAnimation.complete(success: success)
619+
}
620+
611621
// MARK: Private
612622

613623
private func updateProgress() {
614624
if let progressText = taskTracker.latestFinishedText {
615-
progressAnimation.update(
625+
self.progressAnimation.update(
616626
step: taskTracker.finishedCount,
617627
total: taskTracker.totalCount,
618-
text: progressText)
628+
text: progressText
629+
)
619630
}
620631
}
621632
}
@@ -638,13 +649,7 @@ fileprivate struct CommandTaskTracker {
638649
case .isUpToDate:
639650
totalCount -= 1
640651
case .isComplete:
641-
if (totalCount == finishedCount) {
642-
let latestOutput: String? = latestFinishedText
643-
latestFinishedText = """
644-
\(latestOutput ?? "")\n
645-
* Build Completed!
646-
"""
647-
}
652+
break
648653
@unknown default:
649654
assertionFailure("unhandled command status kind \(kind) for command \(command)")
650655
break

Tests/CommandsTests/BuildToolTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,18 @@ 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+
XCTAssertTrue(result.stdout.contains("[6/6] Build complete!"), result.stdout)
251+
}
252+
253+
do {
254+
let result = try execute([], packagePath: path)
255+
XCTAssertTrue(result.stdout.contains("[0/0] Build complete!"), result.stdout)
256+
}
257+
}
258+
}
245259
}

Tests/FunctionalTests/ExtensionTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ExtensionTests: XCTestCase {
2222
XCTAssert(stdout.contains("Linking MySourceGenTool"), "stdout:\n\(stdout)")
2323
XCTAssert(stdout.contains("Generating Foo.swift from Foo.dat"), "stdout:\n\(stdout)")
2424
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
25-
XCTAssert(stdout.contains("Build Completed"), "stdout:\n\(stdout)")
25+
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
2626
}
2727
catch {
2828
print(error)
@@ -38,7 +38,7 @@ class ExtensionTests: XCTestCase {
3838
XCTAssert(stdout.contains("Linking MySourceGenTool"), "stdout:\n\(stdout)")
3939
XCTAssert(stdout.contains("Generating Foo.swift from Foo.dat"), "stdout:\n\(stdout)")
4040
XCTAssert(stdout.contains("Linking MyTool"), "stdout:\n\(stdout)")
41-
XCTAssert(stdout.contains("Build Completed"), "stdout:\n\(stdout)")
41+
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
4242
}
4343
catch {
4444
print(error)

0 commit comments

Comments
 (0)