diff --git a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift index 90d47bd2830..2006678add8 100644 --- a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift +++ b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift @@ -430,7 +430,8 @@ extension PackagePIFProjectBuilder { on: moduleDependencyGUID, platformFilters: packageConditions .toPlatformFilter(toolsVersion: package.manifest.toolsVersion), - linkProduct: true + // Only link the testable version of executables which use Swift, as we do not currently support renaming entrypoints written in other languages. + linkProduct: moduleDependency.usesSwift ) log(.debug, indent: 1, "Added linked dependency on target '\(moduleDependencyGUID)'") } diff --git a/Sources/SwiftBuildSupport/SwiftBuildSystem.swift b/Sources/SwiftBuildSupport/SwiftBuildSystem.swift index c9bbdd09f0b..9ba6bfe61c3 100644 --- a/Sources/SwiftBuildSupport/SwiftBuildSystem.swift +++ b/Sources/SwiftBuildSupport/SwiftBuildSystem.swift @@ -695,6 +695,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 { + 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)'") } diff --git a/Tests/CommandsTests/TestCommandTests.swift b/Tests/CommandsTests/TestCommandTests.swift index dadf7dc3282..dfd796c6e20 100644 --- a/Tests/CommandsTests/TestCommandTests.swift +++ b/Tests/CommandsTests/TestCommandTests.swift @@ -159,6 +159,7 @@ struct TestCommandTests { } } when: { (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .windows) + || (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .macOS) || (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSmokeTestPipeline) || (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline) // error: SwiftCompile normal x86_64 /tmp/Miscellaneous_EchoExecutable.sxkNTX/Miscellaneous_EchoExecutable/.build/x86_64-unknown-linux-gnu/Intermediates.noindex/EchoExecutable.build/Debug-linux/TestSuite-test-runner.build/DerivedSources/test_entry_point.swift failed with a nonzero exit code } @@ -220,7 +221,6 @@ struct TestCommandTests { } @Test( - .issue("https://github.com/swiftlang/swift-package-manager/issues/8955", relationship: .defect), arguments: SupportedBuildSystemOnAllPlatforms, BuildConfiguration.allCases, ) func enableDisableTestabilityDefaultShouldRunWithTestability( @@ -273,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)", ) } @@ -667,7 +667,6 @@ struct TestCommandTests { } when: { (buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem) || ProcessInfo.hostOperatingSystem == .windows - || (buildSystem == .swiftbuild && .macOS == ProcessInfo.hostOperatingSystem && tcdata.testRunner == .SwiftTesting) } } @@ -994,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( @@ -1016,7 +1013,7 @@ struct TestCommandTests { ) } } when: { - buildSystem == .swiftbuild + buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem != .macOS } }