Skip to content

Enable cross-import overlays in test targets. #8158

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 3 commits into from
Dec 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,15 @@ public final class SwiftModuleBuildDescription {
if self.isTestTarget {
// test targets must be built with -enable-testing
// since its required for test discovery (the non objective-c reflection kind)
return ["-enable-testing"]
var result = ["-enable-testing"]

// Test targets need to enable cross-import overlays because Swift
// Testing cannot directly link to most other modules and needs to
// provide API that works with e.g. Foundation. (Developers can
// override this flag by passing -disable-cross-import-overlays.)
result += ["-Xfrontend", "-enable-cross-import-overlays"]

return result
} else if self.buildParameters.enableTestability {
return ["-enable-testing"]
} else {
Expand Down
2 changes: 2 additions & 0 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,8 @@ final class BuildPlanTests: XCTestCase {
"-enable-batch-mode",
"-Onone",
"-enable-testing",
"-Xfrontend",
"-enable-cross-import-overlays",
.equal(self.j),
"-DSWIFT_PACKAGE",
"-DDEBUG",
Expand Down