Skip to content

Infer properties of derived test target. #7041

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
Oct 31, 2023
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
12 changes: 6 additions & 6 deletions Sources/Build/BuildPlan/BuildPlan+Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ extension BuildPlan {
let discoveryResolvedTarget = ResolvedTarget(
target: discoveryTarget,
dependencies: testProduct.targets.map { .target($0, conditions: []) },
defaultLocalization: .none, // safe since this is a derived target
platforms: .init(declared: [], derivedXCTestPlatformProvider: .none) // safe since this is a derived target
defaultLocalization: testProduct.defaultLocalization,
platforms: testProduct.platforms
)
let discoveryTargetBuildDescription = try SwiftTargetBuildDescription(
package: package,
Expand Down Expand Up @@ -119,8 +119,8 @@ extension BuildPlan {
let entryPointResolvedTarget = ResolvedTarget(
target: entryPointTarget,
dependencies: testProduct.targets.map { .target($0, conditions: []) } + [.target(discoveryResolvedTarget, conditions: [])],
defaultLocalization: .none, // safe since this is a derived target
platforms: .init(declared: [], derivedXCTestPlatformProvider: .none) // safe since this is a derived target
defaultLocalization: testProduct.defaultLocalization,
platforms: testProduct.platforms
)
return try SwiftTargetBuildDescription(
package: package,
Expand Down Expand Up @@ -148,8 +148,8 @@ extension BuildPlan {
let entryPointResolvedTarget = ResolvedTarget(
target: entryPointTarget,
dependencies: entryPointResolvedTarget.dependencies + [.target(discoveryTargets.resolved, conditions: [])],
defaultLocalization: .none, // safe since this is a derived target
platforms: .init(declared: [], derivedXCTestPlatformProvider: .none) // safe since this is a derived target
defaultLocalization: testProduct.defaultLocalization,
platforms: testProduct.platforms
)
let entryPointTargetBuildDescription = try SwiftTargetBuildDescription(
package: package,
Expand Down
18 changes: 10 additions & 8 deletions Sources/PackageGraph/ResolvedProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ public final class ResolvedProduct {
self.underlyingProduct = product
self.targets = targets

// defaultLocalization is currently shared across the entire package
// this may need to be enhanced if / when we support localization per target or product
let defaultLocalization = self.targets.first?.defaultLocalization
self.defaultLocalization = defaultLocalization

let platforms = Self.computePlatforms(targets: targets)
self.platforms = platforms

self.testEntryPointTarget = underlyingProduct.testEntryPointPath.map { testEntryPointPath in
// Create an executable resolved target with the entry point file, adding product's targets as dependencies.
let dependencies: [Target.Dependency] = product.targets.map { .target($0, conditions: []) }
Expand All @@ -69,16 +77,10 @@ public final class ResolvedProduct {
return ResolvedTarget(
target: swiftTarget,
dependencies: targets.map { .target($0, conditions: []) },
defaultLocalization: .none, // safe since this is a derived product
platforms: .init(declared: [], derivedXCTestPlatformProvider: .none) // safe since this is a derived product
defaultLocalization: defaultLocalization ?? .none, // safe since this is a derived product
platforms: platforms
)
}

// defaultLocalization is currently shared across the entire package
// this may need to be enhanced if / when we support localization per target or product
self.defaultLocalization = self.targets.first?.defaultLocalization

self.platforms = Self.computePlatforms(targets: targets)
}

/// True if this product contains Swift targets.
Expand Down