From b78d5e13483d54c32794b42c08b2fa1b139c45d8 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Wed, 16 Oct 2024 16:14:05 -0400 Subject: [PATCH] Ensure a newline is printed after Planning build If a PackageStructure build needs to occur during a `swift test --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 `[1/1] Planning Build`. 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 t othe LLBuildProgressTracker, however for a PackageStructure build the relevant buildComplete delegate method is never called. --- Sources/Build/BuildOperation.swift | 10 +++++++++- Sources/Build/LLBuildProgressTracker.swift | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Sources/Build/BuildOperation.swift b/Sources/Build/BuildOperation.swift index 2efa0111c9a..34eb300dbb7 100644 --- a/Sources/Build/BuildOperation.swift +++ b/Sources/Build/BuildOperation.swift @@ -770,7 +770,15 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS self.current = (buildSystem, tracker) // Build the package structure target which will re-generate the llbuild manifest, if necessary. - return buildSystem.build(target: "PackageStructure") + let buildSuccess = buildSystem.build(target: "PackageStructure") + + // If progress has been printed this will add a newline to separate it from what could be + // the output of the command. For instance `swift test --skip-build` may print progress for + // the Planning Build stage, followed immediately by a list of tests. Without this finialize() + // call the first entry in the list appear on the same line as the Planning Build progress. + tracker.finalize(success: true) + + return buildSuccess } /// Create the build system using the given build description. diff --git a/Sources/Build/LLBuildProgressTracker.swift b/Sources/Build/LLBuildProgressTracker.swift index 9f79f6f93ac..6728bea0c0d 100644 --- a/Sources/Build/LLBuildProgressTracker.swift +++ b/Sources/Build/LLBuildProgressTracker.swift @@ -187,6 +187,12 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut } } + public func finalize(success: Bool) { + self.queue.async { + self.progressAnimation.complete(success: success) + } + } + // MARK: llbuildSwift.BuildSystemDelegate var fs: SPMLLBuild.FileSystem? {