Skip to content

Add subsetDescriptor to completion message #7208

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
Jan 2, 2024
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
2 changes: 1 addition & 1 deletion IntegrationTests/Tests/IntegrationTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ final class BasicTests: XCTestCase {
XCTAssertContents(runError) { checker in
checker.check(.regex("Compiling .*secho.*"))
checker.check(.regex("Linking .*secho"))
checker.check(.contains("Build complete"))
checker.check(.contains("Build of product 'secho' complete"))
}
XCTAssertEqual(runOutput, "1 \"two\"\n")
}
Expand Down
16 changes: 15 additions & 1 deletion Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,21 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS

let duration = buildStartTime.distance(to: .now())

self.buildSystemDelegate?.buildComplete(success: success, duration: duration)
let subsetDescriptor: String?
switch subset {
case .product(let productName):
subsetDescriptor = "product '\(productName)'"
case .target(let targetName):
subsetDescriptor = "target: '\(targetName)'"
case .allExcludingTests, .allIncludingTests:
subsetDescriptor = nil
}

self.buildSystemDelegate?.buildComplete(
success: success,
duration: duration,
subsetDescriptor: subsetDescriptor
)
self.delegate?.buildSystem(self, didFinishWithResult: success)
guard success else { throw Diagnostics.fatalError }

Expand Down
11 changes: 9 additions & 2 deletions Sources/Build/BuildOperationBuildSystemDelegateHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -956,11 +956,18 @@ final class BuildOperationBuildSystemDelegateHandler: LLBuildBuildSystemDelegate
}
}

func buildComplete(success: Bool, duration: DispatchTimeInterval) {
func buildComplete(success: Bool, duration: DispatchTimeInterval, subsetDescriptor: String? = nil) {
let subsetString: String
if let subsetDescriptor {
subsetString = "of \(subsetDescriptor) "
} else {
subsetString = ""
}

queue.sync {
self.progressAnimation.complete(success: success)
if success {
let message = cancelled ? "Build cancelled!" : "Build complete!"
let message = cancelled ? "Build \(subsetString)cancelled!" : "Build \(subsetString)complete!"
self.progressAnimation.clear()
self.outputStream.send("\(message) (\(duration.descriptionInSeconds))\n")
self.outputStream.flush()
Expand Down
8 changes: 4 additions & 4 deletions Tests/CommandsTests/PackageToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,7 @@ final class PackageToolTests: CommandsTestCase {
XCTAssertNoMatch(stdout, .contains("Building for production..."))
XCTAssertMatch(stdout, .contains("-module-name MyExecutable"))
XCTAssertMatch(stdout, .contains("-DEXTRA_SWIFT_FLAG"))
XCTAssertMatch(stdout, .contains("Build complete!"))
XCTAssertMatch(stdout, .contains("Build of product 'MyExecutable' complete!"))
XCTAssertMatch(stdout, .contains("succeeded: true"))
XCTAssertMatch(stdout, .and(.contains("artifact-path:"), .contains("debug/MyExecutable")))
XCTAssertMatch(stdout, .and(.contains("artifact-kind:"), .contains("executable")))
Expand All @@ -2410,7 +2410,7 @@ final class PackageToolTests: CommandsTestCase {
XCTAssertMatch(stdout, .contains("Building for production..."))
XCTAssertNoMatch(stdout, .contains("Building for debug..."))
XCTAssertNoMatch(stdout, .contains("-module-name MyExecutable"))
XCTAssertMatch(stdout, .contains("Build complete!"))
XCTAssertMatch(stdout, .contains("Build of product 'MyExecutable' complete!"))
XCTAssertMatch(stdout, .contains("succeeded: true"))
XCTAssertMatch(stdout, .and(.contains("artifact-path:"), .contains("release/MyExecutable")))
XCTAssertMatch(stdout, .and(.contains("artifact-kind:"), .contains("executable")))
Expand All @@ -2422,7 +2422,7 @@ final class PackageToolTests: CommandsTestCase {
XCTAssertMatch(stdout, .contains("Building for production..."))
XCTAssertNoMatch(stdout, .contains("Building for debug..."))
XCTAssertNoMatch(stdout, .contains("-module-name MyLibrary"))
XCTAssertMatch(stdout, .contains("Build complete!"))
XCTAssertMatch(stdout, .contains("Build of product 'MyStaticLibrary' complete!"))
XCTAssertMatch(stdout, .contains("succeeded: true"))
XCTAssertMatch(stdout, .and(.contains("artifact-path:"), .contains("release/libMyStaticLibrary.")))
XCTAssertMatch(stdout, .and(.contains("artifact-kind:"), .contains("staticLibrary")))
Expand All @@ -2434,7 +2434,7 @@ final class PackageToolTests: CommandsTestCase {
XCTAssertMatch(stdout, .contains("Building for production..."))
XCTAssertNoMatch(stdout, .contains("Building for debug..."))
XCTAssertNoMatch(stdout, .contains("-module-name MyLibrary"))
XCTAssertMatch(stdout, .contains("Build complete!"))
XCTAssertMatch(stdout, .contains("Build of product 'MyDynamicLibrary' complete!"))
XCTAssertMatch(stdout, .contains("succeeded: true"))
XCTAssertMatch(stdout, .and(.contains("artifact-path:"), .contains("release/libMyDynamicLibrary.")))
XCTAssertMatch(stdout, .and(.contains("artifact-kind:"), .contains("dynamicLibrary")))
Expand Down
18 changes: 9 additions & 9 deletions Tests/FunctionalTests/PluginTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PluginTests: XCTestCase {
XCTAssert(stdout.contains("Linking MySourceGenBuildTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Generating foo.swift from foo.dat"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
}
}

Expand All @@ -43,7 +43,7 @@ class PluginTests: XCTestCase {
XCTAssert(stdout.contains("Linking MySourceGenBuildTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Generating foo.swift from foo.dat"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Linking MyTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build of product 'MyTool' complete!"), "stdout:\n\(stdout)")
}
}

Expand All @@ -56,7 +56,7 @@ class PluginTests: XCTestCase {
XCTAssert(stdout.contains("Compiling MyOtherLocalTool bar.swift"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Compiling MyOtherLocalTool baz.swift"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Linking MyOtherLocalTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build of product 'MyOtherLocalTool' complete!"), "stdout:\n\(stdout)")
}
}

Expand Down Expand Up @@ -125,7 +125,7 @@ class PluginTests: XCTestCase {
XCTAssert(stdout.contains("Linking MySourceGenBuildTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Generating foo.swift from foo.dat"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
}
}

Expand All @@ -138,7 +138,7 @@ class PluginTests: XCTestCase {
try fixture(name: "Miscellaneous/Plugins") { fixturePath in
let (stdout, _) = try executeSwiftBuild(fixturePath.appending("SandboxTesterPlugin"), configuration: .Debug, extraArgs: ["--product", "MyLocalTool"])
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
}
}

Expand All @@ -151,7 +151,7 @@ class PluginTests: XCTestCase {
try fixture(name: "Miscellaneous/Plugins") { fixturePath in
let (stdout, _) = try executeSwiftBuild(fixturePath.appending("MyBinaryToolPlugin"), configuration: .Debug, extraArgs: ["--product", "MyLocalTool"])
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
}
}

Expand All @@ -164,7 +164,7 @@ class PluginTests: XCTestCase {
try fixture(name: "Miscellaneous/Plugins") { fixturePath in
let (stdout, _) = try executeSwiftBuild(fixturePath.appending("BinaryToolProductPlugin"), configuration: .Debug, extraArgs: ["--product", "MyLocalTool"])
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
}
}

Expand Down Expand Up @@ -525,7 +525,7 @@ class PluginTests: XCTestCase {
XCTAssert(stderr.contains("Linking RemoteTool"), "stdout:\n\(stderr)\n\(stdout)")
XCTAssert(stderr.contains("Linking LocalTool"), "stdout:\n\(stderr)\n\(stdout)")
XCTAssert(stderr.contains("Linking ImpliedLocalTool"), "stdout:\n\(stderr)\n\(stdout)")
XCTAssert(stderr.contains("Build complete!"), "stdout:\n\(stderr)\n\(stdout)")
XCTAssert(stderr.contains("Build of product 'ImpliedLocalTool' complete!"), "stdout:\n\(stderr)\n\(stdout)")
XCTAssert(stdout.contains("A message from the remote tool."), "stdout:\n\(stderr)\n\(stdout)")
XCTAssert(stdout.contains("A message from the local tool."), "stdout:\n\(stderr)\n\(stdout)")
XCTAssert(stdout.contains("A message from the implied local tool."), "stdout:\n\(stderr)\n\(stdout)")
Expand Down Expand Up @@ -1065,7 +1065,7 @@ class PluginTests: XCTestCase {
XCTAssert(stdout.contains("Linking MySourceGenBuildTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Creating foo.swift from foo.dat"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
}
}

Expand Down