Skip to content

Commit dc198e1

Browse files
committed
Generate entrypoints for test bundles on macOS
1 parent d7465ef commit dc198e1

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ extension PackagePIFProjectBuilder {
430430
on: moduleDependencyGUID,
431431
platformFilters: packageConditions
432432
.toPlatformFilter(toolsVersion: package.manifest.toolsVersion),
433-
linkProduct: true
433+
// Only link the testable version of executables which use Swift, as we do not currently support renaming entrypoints written in other languages.
434+
linkProduct: moduleDependency.usesSwift
434435
)
435436
log(.debug, indent: 1, "Added linked dependency on target '\(moduleDependencyGUID)'")
436437
}

Sources/SwiftBuildSupport/SwiftBuildSystem.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
521521
case .taskComplete(let info):
522522
let startedInfo = try buildState.completed(task: info)
523523
if info.result != .success {
524-
self.observabilityScope.emit(severity: .error, message: "\(startedInfo.ruleInfo) failed with a nonzero exit code")
524+
self.observabilityScope.emit(severity: .error, message: "\(startedInfo.ruleInfo) failed with a nonzero exit code. Command line: \(startedInfo.commandLineDisplayString ?? "<no command line>")")
525525
}
526526
let targetInfo = try buildState.target(for: startedInfo)
527527
self.delegate?.buildSystem(self, didFinishCommand: BuildSystemCommand(startedInfo, targetInfo: targetInfo))
@@ -705,6 +705,11 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
705705
settings["ARCHS"] = architectures.joined(separator: " ")
706706
}
707707

708+
// When building with the CLI for macOS, test bundles should generate entrypoints for compatibility with swiftpm-testing-helper.
709+
if buildParameters.triple.isMacOSX {
710+
settings["GENERATE_TEST_ENTRYPOINTS_FOR_BUNDLES"] = "YES"
711+
}
712+
708713
func reportConflict(_ a: String, _ b: String) throws -> String {
709714
throw StringError("Build parameters constructed conflicting settings overrides '\(a)' and '\(b)'")
710715
}

Tests/CommandsTests/TestCommandTests.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ struct TestCommandTests {
221221
}
222222

223223
@Test(
224-
.issue("https://github.com/swiftlang/swift-package-manager/issues/8955", relationship: .defect),
225224
arguments: SupportedBuildSystemOnAllPlatforms, BuildConfiguration.allCases,
226225
)
227226
func enableDisableTestabilityDefaultShouldRunWithTestability(
@@ -274,7 +273,7 @@ struct TestCommandTests {
274273
}
275274

276275
#expect(
277-
stderr.contains("was not compiled for testing"),
276+
stderr.contains("was not compiled for testing") || stderr.contains("ignore swiftmodule built without '-enable-testing'"),
278277
"got stdout: \(stdout), stderr: \(stderr)",
279278
)
280279
}
@@ -668,7 +667,6 @@ struct TestCommandTests {
668667
} when: {
669668
(buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem)
670669
|| ProcessInfo.hostOperatingSystem == .windows
671-
|| (buildSystem == .swiftbuild && .macOS == ProcessInfo.hostOperatingSystem && tcdata.testRunner == .SwiftTesting)
672670
}
673671
}
674672

@@ -995,8 +993,6 @@ struct TestCommandTests {
995993
}
996994

997995
@Test(
998-
.SWBINTTODO("Fails to find test executable"),
999-
.issue("https://github.com/swiftlang/swift-package-manager/pull/8722", relationship: .fixedBy),
1000996
arguments: SupportedBuildSystemOnAllPlatforms, BuildConfiguration.allCases,
1001997
)
1002998
func basicSwiftTestingIntegration(
@@ -1017,7 +1013,7 @@ struct TestCommandTests {
10171013
)
10181014
}
10191015
} when: {
1020-
buildSystem == .swiftbuild
1016+
buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem != .macOS
10211017
}
10221018
}
10231019

0 commit comments

Comments
 (0)