Skip to content

Commit 7e83b58

Browse files
committed
Infer properties of derived test target.
Right now, when we construct the derived test target used on Linux/Windows with corelibs-xctest, we don't preserve the `platforms` property. The toolchain then infers a value for it based on the current OS. Since Swift doesn't currently support versioning on those platforms, the end result is the same. However, if we want to start using a derived test target with swift-testing on Apple platforms, we need to propagate this information correctly. This PR does that.
1 parent bcad083 commit 7e83b58

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Sources/Build/BuildPlan/BuildPlan+Test.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ extension BuildPlan {
8686
let discoveryResolvedTarget = ResolvedTarget(
8787
target: discoveryTarget,
8888
dependencies: testProduct.targets.map { .target($0, conditions: []) },
89-
defaultLocalization: .none, // safe since this is a derived target
90-
platforms: .init(declared: [], derivedXCTestPlatformProvider: .none) // safe since this is a derived target
89+
defaultLocalization: testProduct.defaultLocalization,
90+
platforms: testProduct.platforms
9191
)
9292
let discoveryTargetBuildDescription = try SwiftTargetBuildDescription(
9393
package: package,
@@ -119,8 +119,8 @@ extension BuildPlan {
119119
let entryPointResolvedTarget = ResolvedTarget(
120120
target: entryPointTarget,
121121
dependencies: testProduct.targets.map { .target($0, conditions: []) } + [.target(discoveryResolvedTarget, conditions: [])],
122-
defaultLocalization: .none, // safe since this is a derived target
123-
platforms: .init(declared: [], derivedXCTestPlatformProvider: .none) // safe since this is a derived target
122+
defaultLocalization: testProduct.defaultLocalization,
123+
platforms: testProduct.platforms
124124
)
125125
return try SwiftTargetBuildDescription(
126126
package: package,
@@ -148,8 +148,8 @@ extension BuildPlan {
148148
let entryPointResolvedTarget = ResolvedTarget(
149149
target: entryPointTarget,
150150
dependencies: entryPointResolvedTarget.dependencies + [.target(discoveryTargets.resolved, conditions: [])],
151-
defaultLocalization: .none, // safe since this is a derived target
152-
platforms: .init(declared: [], derivedXCTestPlatformProvider: .none) // safe since this is a derived target
151+
defaultLocalization: testProduct.defaultLocalization,
152+
platforms: testProduct.platforms
153153
)
154154
let entryPointTargetBuildDescription = try SwiftTargetBuildDescription(
155155
package: package,

Sources/PackageGraph/ResolvedProduct.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public final class ResolvedProduct {
6969
return ResolvedTarget(
7070
target: swiftTarget,
7171
dependencies: targets.map { .target($0, conditions: []) },
72-
defaultLocalization: .none, // safe since this is a derived product
73-
platforms: .init(declared: [], derivedXCTestPlatformProvider: .none) // safe since this is a derived product
72+
defaultLocalization: targets[0].defaultLocalization,
73+
platforms: targets[0].platforms
7474
)
7575
}
7676

0 commit comments

Comments
 (0)