[6.4] Ensure targets merged into products by the build system can still be selected using --target#10281
Merged
Merged
Conversation
…selected using --target
Contributor
Author
|
@swift-ci test |
bkhouri
approved these changes
Jul 9, 2026
bkhouri
left a comment
Contributor
There was a problem hiding this comment.
Looks good, though I have a few non-blocking comments related to the tests
Comment on lines
+568
to
+569
| #expect(error.stderr.contains("Could not find target named 'notarealtarget'") || | ||
| error.stderr.contains("no target named 'notarealtarget'")) |
Contributor
There was a problem hiding this comment.
suggestion: can we split the expectation to each build system validate the expected error message?
Suggested change
| #expect(error.stderr.contains("Could not find target named 'notarealtarget'") || | |
| error.stderr.contains("no target named 'notarealtarget'")) | |
| let expectedErrorMessage = switch buildSystem { | |
| case .native: | |
| // to be updated with expected string | |
| "Could not find target named 'notarealtarget'" | |
| case .swiftbuild: | |
| // to be updated with expected string | |
| "no target named 'notarealtarget'" | |
| } | |
| #expect(error.stderr.contains(expectedErrorMessage) |
Comment on lines
+545
to
+558
| let result = try await build( | ||
| ["--target", "exec2"], | ||
| packagePath: fullPath, | ||
| configuration: data.config, | ||
| buildSystem: buildSystem, | ||
| ) | ||
| switch buildSystem { | ||
| case .native: | ||
| #expect(result.binContents.contains("exec2.build")) | ||
| #expect(!result.binContents.contains("exec1.build")) | ||
| case .swiftbuild, .xcode: | ||
| #expect(result.binContents.contains(executableName("exec2"))) | ||
| #expect(!result.binContents.contains(executableName("exec1"))) | ||
| } |
Contributor
There was a problem hiding this comment.
suggestion: can we wrap this in a do{} block to ensure the two use cases will always be tested?
Suggested change
| let result = try await build( | |
| ["--target", "exec2"], | |
| packagePath: fullPath, | |
| configuration: data.config, | |
| buildSystem: buildSystem, | |
| ) | |
| switch buildSystem { | |
| case .native: | |
| #expect(result.binContents.contains("exec2.build")) | |
| #expect(!result.binContents.contains("exec1.build")) | |
| case .swiftbuild, .xcode: | |
| #expect(result.binContents.contains(executableName("exec2"))) | |
| #expect(!result.binContents.contains(executableName("exec1"))) | |
| } | |
| do { | |
| let result = try await build( | |
| ["--target", "exec2"], | |
| packagePath: fullPath, | |
| configuration: data.config, | |
| buildSystem: buildSystem, | |
| ) | |
| switch buildSystem { | |
| case .native: | |
| #expect(result.binContents.contains("exec2.build")) | |
| #expect(!result.binContents.contains("exec1.build")) | |
| case .swiftbuild, .xcode: | |
| #expect(result.binContents.contains(executableName("exec2"))) | |
| #expect(!result.binContents.contains(executableName("exec1"))) | |
| } | |
| } |
Contributor
Author
|
I'll look at some of the test cleanups in a followup since they're comparatively minor |
This was referenced Jul 9, 2026
Closed
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10275
Closes #9138
When generating PIF, a package target representing an executable or test target may be merged into a product. These remain targets in the user-facing model, and should be selectable using --target on the CLI. Update BuildSubset.pifTargetName to account for this case, fixup an existing test for executables, and add a new one for tests.