Skip to content

Commit c94df76

Browse files
authored
Ensure a newline is printed after Planning build (#8050)
If a PackageStructure build needs to occur during a `swift test list --skip-build` command there is no newline printed to the terminal, causing the first line of listed tests to appear on the same line as the progress, i.e: `[1/1] Planning buildTestPackageTests.example()` This doesn't occur when you omit `--skip-build` because there is code in the `LLBuildProgressTracker.swift` that calls `progressAnimation.complete(success:)` when a build completes. Ideally I'd like to contain this logic to the LLBuildProgressTracker, however for a PackageStructure build the relevant buildComplete delegate method is never called.
1 parent 4fbe8e8 commit c94df76

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Sources/Build/BuildOperation.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,15 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
770770
self.current = (buildSystem, tracker)
771771

772772
// Build the package structure target which will re-generate the llbuild manifest, if necessary.
773-
return buildSystem.build(target: "PackageStructure")
773+
let buildSuccess = buildSystem.build(target: "PackageStructure")
774+
775+
// If progress has been printed this will add a newline to separate it from what could be
776+
// the output of the command. For instance `swift test --skip-build` may print progress for
777+
// the Planning Build stage, followed immediately by a list of tests. Without this finialize()
778+
// call the first entry in the list appear on the same line as the Planning Build progress.
779+
tracker.finalize(success: true)
780+
781+
return buildSuccess
774782
}
775783

776784
/// Create the build system using the given build description.

Sources/Build/LLBuildProgressTracker.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut
187187
}
188188
}
189189

190+
public func finalize(success: Bool) {
191+
self.queue.async {
192+
self.progressAnimation.complete(success: success)
193+
}
194+
}
195+
190196
// MARK: llbuildSwift.BuildSystemDelegate
191197

192198
var fs: SPMLLBuild.FileSystem? {

0 commit comments

Comments
 (0)