Skip to content

Enable testing when building when test discovery is enabled #2400

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
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
19 changes: 18 additions & 1 deletion Sources/Build/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ public final class SwiftTargetBuildDescription {
args += buildParameters.indexStoreArguments
args += buildParameters.toolchain.extraSwiftCFlags
args += optimizationArguments
args += testingArguments
args += ["-g"]
args += ["-j\(ProcessInfo.processInfo.activeProcessorCount)"]
args += activeCompilationConditions
Expand Down Expand Up @@ -743,6 +744,7 @@ public final class SwiftTargetBuildDescription {
result += buildParameters.targetTripleArgs(for: target)
result += ["-swift-version", swiftVersion.rawValue]
result += optimizationArguments
result += testingArguments
result += ["-g"]
result += ["-j\(ProcessInfo.processInfo.activeProcessorCount)"]
result += activeCompilationConditions
Expand Down Expand Up @@ -790,6 +792,7 @@ public final class SwiftTargetBuildDescription {
result += buildParameters.indexStoreArguments
result += buildParameters.toolchain.extraSwiftCFlags
result += optimizationArguments
result += testingArguments
result += ["-g"]
result += ["-j\(ProcessInfo.processInfo.activeProcessorCount)"]
result += activeCompilationConditions
Expand Down Expand Up @@ -928,12 +931,26 @@ public final class SwiftTargetBuildDescription {
private var optimizationArguments: [String] {
switch buildParameters.configuration {
case .debug:
return ["-Onone", "-enable-testing"]
return ["-Onone"]
case .release:
return ["-O"]
}
}

/// Testing arguments according to the build configuration.
private var testingArguments: [String] {
switch buildParameters.configuration {
case .debug:
return ["-enable-testing"]
case .release:
if self.buildParameters.enableTestDiscovery {
return ["-enable-testing"]
} else {
return []
}
}
}

/// Module cache arguments.
private var moduleCacheArgs: [String] {
return ["-module-cache-path", buildParameters.moduleCache.pathString]
Expand Down