-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Generate entrypoints for test bundles on macOS #9018
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,7 +413,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { | |
throw error | ||
} | ||
|
||
let request = try self.makeBuildRequest(configuredTargets: configuredTargets, derivedDataPath: derivedDataPath, genSymbolGraph: genSymbolGraph) | ||
let request = try await self.makeBuildRequest(session: session, configuredTargets: configuredTargets, derivedDataPath: derivedDataPath, genSymbolGraph: genSymbolGraph) | ||
|
||
struct BuildState { | ||
private var targetsByID: [Int: SwiftBuild.SwiftBuildMessage.TargetStartedInfo] = [:] | ||
|
@@ -521,7 +521,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { | |
case .taskComplete(let info): | ||
let startedInfo = try buildState.completed(task: info) | ||
if info.result != .success { | ||
self.observabilityScope.emit(severity: .error, message: "\(startedInfo.ruleInfo) failed with a nonzero exit code") | ||
self.observabilityScope.emit(severity: .error, message: "\(startedInfo.ruleInfo) failed with a nonzero exit code. Command line: \(startedInfo.commandLineDisplayString ?? "<no command line>")") | ||
} | ||
let targetInfo = try buildState.target(for: startedInfo) | ||
self.delegate?.buildSystem(self, didFinishCommand: BuildSystemCommand(startedInfo, targetInfo: targetInfo)) | ||
|
@@ -631,7 +631,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { | |
) | ||
} | ||
|
||
private func makeBuildParameters(genSymbolGraph: Bool) throws -> SwiftBuild.SWBBuildParameters { | ||
private func makeBuildParameters(session: SWBBuildServiceSession, genSymbolGraph: Bool) async throws -> SwiftBuild.SWBBuildParameters { | ||
// Generate the run destination parameters. | ||
let runDestination = makeRunDestination() | ||
|
||
|
@@ -642,11 +642,20 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { | |
|
||
// Generate a table of any overriding build settings. | ||
var settings: [String: String] = [:] | ||
// An error with determining the override should not be fatal here. | ||
settings["CC"] = try? buildParameters.toolchain.getClangCompiler().pathString | ||
// Always specify the path of the effective Swift compiler, which was determined in the same way as for the | ||
// native build system. | ||
settings["SWIFT_EXEC"] = buildParameters.toolchain.swiftCompilerPath.pathString | ||
|
||
// If the SwiftPM toolchain corresponds to a toolchain registered with the lower level build system, add it to the toolchain stack. | ||
// Otherwise, apply overrides for each component of the SwiftPM toolchain. | ||
if let toolchainID = try await session.lookupToolchain(at: buildParameters.toolchain.toolchainDir.pathString) { | ||
settings["TOOLCHAINS"] = "\(toolchainID.rawValue) $(inherited)" | ||
} else { | ||
// FIXME: This list of overrides is incomplete. | ||
// An error with determining the override should not be fatal here. | ||
settings["CC"] = try? buildParameters.toolchain.getClangCompiler().pathString | ||
// Always specify the path of the effective Swift compiler, which was determined in the same way as for the | ||
// native build system. | ||
settings["SWIFT_EXEC"] = buildParameters.toolchain.swiftCompilerPath.pathString | ||
} | ||
|
||
// FIXME: workaround for old Xcode installations such as what is in CI | ||
settings["LM_SKIP_METADATA_EXTRACTION"] = "YES" | ||
if genSymbolGraph { | ||
|
@@ -705,6 +714,11 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { | |
settings["ARCHS"] = architectures.joined(separator: " ") | ||
} | ||
|
||
// When building with the CLI for macOS, test bundles should generate entrypoints for compatibility with swiftpm-testing-helper. | ||
if buildParameters.triple.isMacOSX { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. macOS, or all Darwin? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well we don't support command-line execution of tests on other Apple platforms anyway, so... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Execution doesn't matter, this is about the build. The build system does not assume that the machine/tool building the tests is the one running them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay: we support neither building nor executing tests on iOS using SwiftPM. |
||
settings["GENERATE_TEST_ENTRYPOINTS_FOR_BUNDLES"] = "YES" | ||
} | ||
|
||
func reportConflict(_ a: String, _ b: String) throws -> String { | ||
throw StringError("Build parameters constructed conflicting settings overrides '\(a)' and '\(b)'") | ||
} | ||
|
@@ -727,9 +741,9 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { | |
return params | ||
} | ||
|
||
public func makeBuildRequest(configuredTargets: [SWBTargetGUID], derivedDataPath: Basics.AbsolutePath, genSymbolGraph: Bool) throws -> SWBBuildRequest { | ||
public func makeBuildRequest(session: SWBBuildServiceSession, configuredTargets: [SWBTargetGUID], derivedDataPath: Basics.AbsolutePath, genSymbolGraph: Bool) async throws -> SWBBuildRequest { | ||
var request = SWBBuildRequest() | ||
request.parameters = try makeBuildParameters(genSymbolGraph: genSymbolGraph) | ||
request.parameters = try await makeBuildParameters(session: session, genSymbolGraph: genSymbolGraph) | ||
request.configuredTargets = configuredTargets.map { SWBConfiguredTarget(guid: $0.rawValue, parameters: request.parameters) } | ||
request.useParallelTargets = true | ||
request.useImplicitDependencies = false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,7 +221,6 @@ struct TestCommandTests { | |
} | ||
|
||
@Test( | ||
.issue("https://github.com/swiftlang/swift-package-manager/issues/8955", relationship: .defect), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: This issue is merged. Can we remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also hits a different underlying issue now that the first one is fixed which needs further investigation |
||
arguments: SupportedBuildSystemOnAllPlatforms, BuildConfiguration.allCases, | ||
) | ||
func enableDisableTestabilityDefaultShouldRunWithTestability( | ||
|
@@ -274,7 +273,7 @@ struct TestCommandTests { | |
} | ||
|
||
#expect( | ||
stderr.contains("was not compiled for testing"), | ||
stderr.contains("was not compiled for testing") || stderr.contains("ignore swiftmodule built without '-enable-testing'"), | ||
"got stdout: \(stdout), stderr: \(stderr)", | ||
) | ||
} | ||
|
@@ -668,7 +667,6 @@ struct TestCommandTests { | |
} when: { | ||
(buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem) | ||
|| ProcessInfo.hostOperatingSystem == .windows | ||
|| (buildSystem == .swiftbuild && .macOS == ProcessInfo.hostOperatingSystem && tcdata.testRunner == .SwiftTesting) | ||
} | ||
} | ||
|
||
|
@@ -995,8 +993,6 @@ struct TestCommandTests { | |
} | ||
|
||
@Test( | ||
.SWBINTTODO("Fails to find test executable"), | ||
.issue("https://github.com/swiftlang/swift-package-manager/pull/8722", relationship: .fixedBy), | ||
arguments: SupportedBuildSystemOnAllPlatforms, BuildConfiguration.allCases, | ||
) | ||
func basicSwiftTestingIntegration( | ||
|
@@ -1017,7 +1013,7 @@ struct TestCommandTests { | |
) | ||
} | ||
} when: { | ||
buildSystem == .swiftbuild | ||
buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem != .macOS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (possibly blocking): Do we know why this test failed on Linux and Windows? Could we add an issue trait to the test to track it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This patch fixed it on macOS, linux/windows now hit a different underlying issue which needs further investigation |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Do we have a GitHub issue tracking this
FIXME
? If so, can we add it as a code comment?