Skip to content

[5.4] fix "build complete" message #3484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions Sources/Build/BuildDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,26 @@ public final class BuildDelegate: BuildSystemDelegate, SwiftCompilerOutputParser
onCommmandFailure?()
}

func buildComplete(success: Bool) {
queue.sync {
if success {
self.progressAnimation.update(
step: self.taskTracker.finishedCount,
total: self.taskTracker.totalCount,
text: "Build complete!")
}
self.progressAnimation.complete(success: success)
}
}

// MARK: Private
private func updateProgress() {
if let progressText = taskTracker.latestFinishedText {
progressAnimation.update(
self.progressAnimation.update(
step: taskTracker.finishedCount,
total: taskTracker.totalCount,
text: progressText)
text: progressText
)
}
}
}
Expand All @@ -603,13 +617,6 @@ fileprivate struct CommandTaskTracker {
totalCount -= 1
break
case .isComplete:
if (totalCount == finishedCount) {
let latestOutput: String? = latestFinishedText
latestFinishedText = """
\(latestOutput ?? "")\n
* Build Completed!
"""
}
break
@unknown default:
assertionFailure("unhandled command status kind \(kind) for command \(command)")
Expand Down
5 changes: 3 additions & 2 deletions Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
let llbuildTarget = try computeLLBuildTargetName(for: subset)
let success = buildSystem.build(target: llbuildTarget)

buildDelegate?.progressAnimation.complete(success: success)
buildDelegate?.buildComplete(success: success)

guard success else { throw Diagnostics.fatalError }

// Create backwards-compatibilty symlink to old build path.
// Create backwards-compatibility symlink to old build path.
let oldBuildPath = buildParameters.dataPath.parentDirectory.appending(
component: buildParameters.configuration.dirname
)
Expand Down
18 changes: 18 additions & 0 deletions Tests/CommandsTests/BuildToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,22 @@ final class BuildToolTests: XCTestCase {
}
}
}

func testBuildCompleteMessage() {
fixture(name: "DependencyResolution/Internal/Simple") { path in
do {
let result = try execute([], packagePath: path)
#if os(macOS)
XCTAssertTrue(result.stdout.contains("[6/6] Build complete!"), result.stdout)
#else
XCTAssertTrue(result.stdout.contains("[8/8] Build complete!"), result.stdout)
#endif
}

do {
let result = try execute([], packagePath: path)
XCTAssertTrue(result.stdout.contains("[0/0] Build complete!"), result.stdout)
}
}
}
}