Skip to content

Enable testability if test discovery is enabled #2918

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 1 commit into from
Sep 10, 2020
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: 11 additions & 1 deletion Sources/XCBuildSupport/PIFBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ import PackageGraph
/// The parameters required by `PIFBuilder`.
public struct PIFBuilderParameters {

/// Whether or not test discovery is enabled.
public let enableTestDiscovery: Bool

/// Whether to create dylibs for dynamic library products.
public let shouldCreateDylibForDynamicProducts: Bool

/// Creates a `PIFBuilderParameters` instance.
/// - Parameters:
/// - enableTestDiscovery: Whether or not test discovery is enabled.
/// - shouldCreateDylibForDynamicProducts: Whether to create dylibs for dynamic library products.
public init(shouldCreateDylibForDynamicProducts: Bool) {
public init(enableTestDiscovery: Bool, shouldCreateDylibForDynamicProducts: Bool) {
self.enableTestDiscovery = enableTestDiscovery
self.shouldCreateDylibForDynamicProducts = shouldCreateDylibForDynamicProducts
}
}
Expand Down Expand Up @@ -315,6 +320,11 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
releaseSettings[.DEBUG_INFORMATION_FORMAT] = "dwarf-with-dsym"
releaseSettings[.GCC_OPTIMIZATION_LEVEL] = "s"
releaseSettings[.SWIFT_OPTIMIZATION_LEVEL] = "-Owholemodule"

if parameters.enableTestDiscovery {
releaseSettings[.ENABLE_TESTABILITY] = "YES"
}

addBuildConfiguration(name: "Release", settings: releaseSettings)

for product in package.products.sorted(by: { $0.name < $1.name }) {
Expand Down
1 change: 1 addition & 0 deletions Sources/XCBuildSupport/XcodeBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ extension BuildConfiguration {
extension PIFBuilderParameters {
public init(_ buildParameters: BuildParameters) {
self.init(
enableTestDiscovery: buildParameters.enableTestDiscovery,
shouldCreateDylibForDynamicProducts: buildParameters.shouldCreateDylibForDynamicProducts
)
}
Expand Down
1 change: 1 addition & 0 deletions Tests/XCBuildSupportTests/PIFBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2162,6 +2162,7 @@ extension PIFBuilderParameters {
shouldCreateDylibForDynamicProducts: Bool = false
) -> Self {
PIFBuilderParameters(
enableTestDiscovery: false,
shouldCreateDylibForDynamicProducts: shouldCreateDylibForDynamicProducts
)
}
Expand Down