-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Include search path for Swift Testing's macro plugin from toolchain if present #8670
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
stmontgomery
merged 1 commit into
swiftlang:main
from
stmontgomery:testing-macros-plugin-path
May 15, 2025
Merged
Include search path for Swift Testing's macro plugin from toolchain if present #8670
stmontgomery
merged 1 commit into
swiftlang:main
from
stmontgomery:testing-macros-plugin-path
May 15, 2025
Conversation
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
@swift-ci please test |
dschaefer2
approved these changes
May 15, 2025
briancroom
approved these changes
May 15, 2025
jakepetroules
approved these changes
May 15, 2025
Does SwiftBuild need any similar change here? |
Nope, SwiftBuild does the correct thing already! See the relevant code. |
xedin
added a commit
to xedin/swift-package-manager
that referenced
this pull request
May 21, 2025
…lchain if present (swiftlang#8670)" This reverts commit 0c47332.
stmontgomery
added a commit
to stmontgomery/swift-package-manager
that referenced
this pull request
May 21, 2025
…f present (swiftlang#8670) This modifies the logic for determining compiler flags for locating Swift Testing content such that it will always include a search path for Swift Testing's macro plugin at its newer, testing-specific location in the toolchain, if that directory exists. ### Motivation: Swift Testing installs a macro plugin library named `TestingMacros` into the official Swift toolchains for several platforms. By convention, most Swift macro plugins are installed into the toolchain's `usr/lib/swift/host/plugins` directory. However, testing libraries are somewhat special in the sense that they should generally only be available for use in "non-product" targets, i.e. targets which are not intended for distribution and only intended for use in qualifying the main product targets which _will_ be distributed. For that reason, in Darwin toolchains, Swift Testing's plugin is installed into a different location than for other platforms: `usr/lib/swift/host/plugins/testing` (note the final `testing/` directory) — see the [CMake rules](https://github.com/swiftlang/swift-testing/blob/72afbb418542654781a6b7853479c7e70a862b6f/Sources/TestingMacros/CMakeLists.txt#L67-L75) where that is controlled. Over time, we'd like to move the macro plugin on other platforms to that location for consistency, because the current _inconsistent_ install path has caused friction for users if they attempt to form search paths to the plugin on their own — see swiftlang/swift-testing#1039. So this PR paves the way for Swift Testing to begin to relocate its plugin by ensuring that _if_ this distinct plugin directory exists in a toolchain, it will be preferred. ### Modifications: - Modify logic in `UserToolchain.swift` to begin passing `-plugin-path` whenever the relevant, testing-specific plugin path exists in a toolchain. - Add a new test which validates this, by simulating the scenario of _not_ having a custom toolchain and validating the expected flags are passed. (This most closely matches the current scenario today of using the toolchain included in Xcode, and in that toolchain the plugin is already installed into the `testing/`-suffixed path.) rdar://151319768
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
build system
Changes to interactions with build systems
enhancement
macros
Support for macros
swift test
Changes impacting `swift test` tool
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.
This modifies the logic for determining compiler flags for locating Swift Testing content such that it will always include a search path for Swift Testing's macro plugin at its newer, testing-specific location in the toolchain, if that directory exists.
Motivation:
Swift Testing installs a macro plugin library named
TestingMacros
into the official Swift toolchains for several platforms. By convention, most Swift macro plugins are installed into the toolchain'susr/lib/swift/host/plugins
directory. However, testing libraries are somewhat special in the sense that they should generally only be available for use in "non-product" targets, i.e. targets which are not intended for distribution and only intended for use in qualifying the main product targets which will be distributed.For that reason, in Darwin toolchains, Swift Testing's plugin is installed into a different location than for other platforms:
usr/lib/swift/host/plugins/testing
(note the finaltesting/
directory) — see the CMake rules where that is controlled. Over time, we'd like to move the macro plugin on other platforms to that location for consistency, because the current inconsistent install path has caused friction for users if they attempt to form search paths to the plugin on their own — see swiftlang/swift-testing#1039. So this PR paves the way for Swift Testing to begin to relocate its plugin by ensuring that if this distinct plugin directory exists in a toolchain, it will be preferred.Modifications:
UserToolchain.swift
to begin passing-plugin-path
whenever the relevant, testing-specific plugin path exists in a toolchain.testing/
-suffixed path.)rdar://151319768