Skip to content

Commit 94e97b6

Browse files
neonichuahoppen
authored andcommitted
Add subsetDescriptor to completion message
If we build just a specific product or target, add a `subsetDescriptor` to the complete message. This improves the confusing output when plugins are using executables, because we end up with multiple 'Build complete' messages.
1 parent b368b96 commit 94e97b6

File tree

5 files changed

+38
-17
lines changed

5 files changed

+38
-17
lines changed

IntegrationTests/Tests/IntegrationTests/BasicTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ final class BasicTests: XCTestCase {
249249
XCTAssertContents(runError) { checker in
250250
checker.check(.regex("Compiling .*secho.*"))
251251
checker.check(.regex("Linking .*secho"))
252-
checker.check(.contains("Build complete"))
252+
checker.check(.contains("Build of product 'secho' complete"))
253253
}
254254
XCTAssertEqual(runOutput, "1 \"two\"\n")
255255
}

Sources/Build/BuildOperation.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,21 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
286286

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

289-
self.buildSystemDelegate?.buildComplete(success: success, duration: duration)
289+
let subsetDescriptor: String?
290+
switch subset {
291+
case .product(let productName):
292+
subsetDescriptor = "product '\(productName)'"
293+
case .target(let targetName):
294+
subsetDescriptor = "target: '\(targetName)'"
295+
case .allExcludingTests, .allIncludingTests:
296+
subsetDescriptor = nil
297+
}
298+
299+
self.buildSystemDelegate?.buildComplete(
300+
success: success,
301+
duration: duration,
302+
subsetDescriptor: subsetDescriptor
303+
)
290304
self.delegate?.buildSystem(self, didFinishWithResult: success)
291305
guard success else { throw Diagnostics.fatalError }
292306

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,11 +956,18 @@ final class BuildOperationBuildSystemDelegateHandler: LLBuildBuildSystemDelegate
956956
}
957957
}
958958

959-
func buildComplete(success: Bool, duration: DispatchTimeInterval) {
959+
func buildComplete(success: Bool, duration: DispatchTimeInterval, subsetDescriptor: String? = nil) {
960+
let subsetString: String
961+
if let subsetDescriptor {
962+
subsetString = "of \(subsetDescriptor) "
963+
} else {
964+
subsetString = ""
965+
}
966+
960967
queue.sync {
961968
self.progressAnimation.complete(success: success)
962969
if success {
963-
let message = cancelled ? "Build cancelled!" : "Build complete!"
970+
let message = cancelled ? "Build \(subsetString)cancelled!" : "Build \(subsetString)complete!"
964971
self.progressAnimation.clear()
965972
self.outputStream.send("\(message) (\(duration.descriptionInSeconds))\n")
966973
self.outputStream.flush()

Tests/CommandsTests/PackageToolTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,7 @@ final class PackageToolTests: CommandsTestCase {
23982398
XCTAssertNoMatch(stdout, .contains("Building for production..."))
23992399
XCTAssertMatch(stdout, .contains("-module-name MyExecutable"))
24002400
XCTAssertMatch(stdout, .contains("-DEXTRA_SWIFT_FLAG"))
2401-
XCTAssertMatch(stdout, .contains("Build complete!"))
2401+
XCTAssertMatch(stdout, .contains("Build of product 'MyExecutable' complete!"))
24022402
XCTAssertMatch(stdout, .contains("succeeded: true"))
24032403
XCTAssertMatch(stdout, .and(.contains("artifact-path:"), .contains("debug/MyExecutable")))
24042404
XCTAssertMatch(stdout, .and(.contains("artifact-kind:"), .contains("executable")))
@@ -2410,7 +2410,7 @@ final class PackageToolTests: CommandsTestCase {
24102410
XCTAssertMatch(stdout, .contains("Building for production..."))
24112411
XCTAssertNoMatch(stdout, .contains("Building for debug..."))
24122412
XCTAssertNoMatch(stdout, .contains("-module-name MyExecutable"))
2413-
XCTAssertMatch(stdout, .contains("Build complete!"))
2413+
XCTAssertMatch(stdout, .contains("Build of product 'MyExecutable' complete!"))
24142414
XCTAssertMatch(stdout, .contains("succeeded: true"))
24152415
XCTAssertMatch(stdout, .and(.contains("artifact-path:"), .contains("release/MyExecutable")))
24162416
XCTAssertMatch(stdout, .and(.contains("artifact-kind:"), .contains("executable")))
@@ -2422,7 +2422,7 @@ final class PackageToolTests: CommandsTestCase {
24222422
XCTAssertMatch(stdout, .contains("Building for production..."))
24232423
XCTAssertNoMatch(stdout, .contains("Building for debug..."))
24242424
XCTAssertNoMatch(stdout, .contains("-module-name MyLibrary"))
2425-
XCTAssertMatch(stdout, .contains("Build complete!"))
2425+
XCTAssertMatch(stdout, .contains("Build of product 'MyStaticLibrary' complete!"))
24262426
XCTAssertMatch(stdout, .contains("succeeded: true"))
24272427
XCTAssertMatch(stdout, .and(.contains("artifact-path:"), .contains("release/libMyStaticLibrary.")))
24282428
XCTAssertMatch(stdout, .and(.contains("artifact-kind:"), .contains("staticLibrary")))
@@ -2434,7 +2434,7 @@ final class PackageToolTests: CommandsTestCase {
24342434
XCTAssertMatch(stdout, .contains("Building for production..."))
24352435
XCTAssertNoMatch(stdout, .contains("Building for debug..."))
24362436
XCTAssertNoMatch(stdout, .contains("-module-name MyLibrary"))
2437-
XCTAssertMatch(stdout, .contains("Build complete!"))
2437+
XCTAssertMatch(stdout, .contains("Build of product 'MyDynamicLibrary' complete!"))
24382438
XCTAssertMatch(stdout, .contains("succeeded: true"))
24392439
XCTAssertMatch(stdout, .and(.contains("artifact-path:"), .contains("release/libMyDynamicLibrary.")))
24402440
XCTAssertMatch(stdout, .and(.contains("artifact-kind:"), .contains("dynamicLibrary")))

Tests/FunctionalTests/PluginTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class PluginTests: XCTestCase {
3030
XCTAssert(stdout.contains("Linking MySourceGenBuildTool"), "stdout:\n\(stdout)")
3131
XCTAssert(stdout.contains("Generating foo.swift from foo.dat"), "stdout:\n\(stdout)")
3232
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
33-
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
33+
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
3434
}
3535
}
3636

@@ -43,7 +43,7 @@ class PluginTests: XCTestCase {
4343
XCTAssert(stdout.contains("Linking MySourceGenBuildTool"), "stdout:\n\(stdout)")
4444
XCTAssert(stdout.contains("Generating foo.swift from foo.dat"), "stdout:\n\(stdout)")
4545
XCTAssert(stdout.contains("Linking MyTool"), "stdout:\n\(stdout)")
46-
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
46+
XCTAssert(stdout.contains("Build of product 'MyTool' complete!"), "stdout:\n\(stdout)")
4747
}
4848
}
4949

@@ -56,7 +56,7 @@ class PluginTests: XCTestCase {
5656
XCTAssert(stdout.contains("Compiling MyOtherLocalTool bar.swift"), "stdout:\n\(stdout)")
5757
XCTAssert(stdout.contains("Compiling MyOtherLocalTool baz.swift"), "stdout:\n\(stdout)")
5858
XCTAssert(stdout.contains("Linking MyOtherLocalTool"), "stdout:\n\(stdout)")
59-
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
59+
XCTAssert(stdout.contains("Build of product 'MyOtherLocalTool' complete!"), "stdout:\n\(stdout)")
6060
}
6161
}
6262

@@ -125,7 +125,7 @@ class PluginTests: XCTestCase {
125125
XCTAssert(stdout.contains("Linking MySourceGenBuildTool"), "stdout:\n\(stdout)")
126126
XCTAssert(stdout.contains("Generating foo.swift from foo.dat"), "stdout:\n\(stdout)")
127127
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
128-
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
128+
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
129129
}
130130
}
131131

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

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

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

@@ -525,7 +525,7 @@ class PluginTests: XCTestCase {
525525
XCTAssert(stderr.contains("Linking RemoteTool"), "stdout:\n\(stderr)\n\(stdout)")
526526
XCTAssert(stderr.contains("Linking LocalTool"), "stdout:\n\(stderr)\n\(stdout)")
527527
XCTAssert(stderr.contains("Linking ImpliedLocalTool"), "stdout:\n\(stderr)\n\(stdout)")
528-
XCTAssert(stderr.contains("Build complete!"), "stdout:\n\(stderr)\n\(stdout)")
528+
XCTAssert(stderr.contains("Build of product 'ImpliedLocalTool' complete!"), "stdout:\n\(stderr)\n\(stdout)")
529529
XCTAssert(stdout.contains("A message from the remote tool."), "stdout:\n\(stderr)\n\(stdout)")
530530
XCTAssert(stdout.contains("A message from the local tool."), "stdout:\n\(stderr)\n\(stdout)")
531531
XCTAssert(stdout.contains("A message from the implied local tool."), "stdout:\n\(stderr)\n\(stdout)")
@@ -1065,7 +1065,7 @@ class PluginTests: XCTestCase {
10651065
XCTAssert(stdout.contains("Linking MySourceGenBuildTool"), "stdout:\n\(stdout)")
10661066
XCTAssert(stdout.contains("Creating foo.swift from foo.dat"), "stdout:\n\(stdout)")
10671067
XCTAssert(stdout.contains("Linking MyLocalTool"), "stdout:\n\(stdout)")
1068-
XCTAssert(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
1068+
XCTAssert(stdout.contains("Build of product 'MyLocalTool' complete!"), "stdout:\n\(stdout)")
10691069
}
10701070
}
10711071

0 commit comments

Comments
 (0)