Skip to content

Commit 627f0ba

Browse files
committed
Generate entrypoints for test bundles on macOS
1 parent b6a3d95 commit 627f0ba

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-38
lines changed

Sources/SwiftBuildSupport/SwiftBuildSystem.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,11 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
695695
settings["ARCHS"] = architectures.joined(separator: " ")
696696
}
697697

698+
// When building with the CLI for macOS, test bundles should generate entrypoints for compatibility with swiftpm-testing-helper.
699+
if buildParameters.triple.isMacOSX {
700+
settings["GENERATE_TEST_ENTRYPOINTS_FOR_BUNDLES"] = "YES"
701+
}
702+
698703
func reportConflict(_ a: String, _ b: String) throws -> String {
699704
throw StringError("Build parameters constructed conflicting settings overrides '\(a)' and '\(b)'")
700705
}

Tests/CommandsTests/TestCommandTests.swift

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct TestCommandTests {
115115
}
116116

117117
@Test(
118-
.SWBINTTODO("Windows: Driver threw unable to load output file map"),
118+
.SWBINTTODO("Custom runners should disable entrypoint generation when appropriate"),
119119
arguments: SupportedBuildSystemOnAllPlatforms, BuildConfiguration.allCases,
120120
)
121121
func toolsetRunner(
@@ -145,22 +145,12 @@ struct TestCommandTests {
145145
#expect(stdout.contains("\(fixturePath)"))
146146

147147
// swift-build-tool output should go to stderr.
148-
withKnownIssue {
149-
#expect(stderr.contains("Compiling"))
150-
} when: {
151-
buildSystem == .swiftbuild // && ProcessInfo.hostOperatingSystem != .macOS
152-
}
148+
#expect(stderr.contains("Compiling"))
153149

154-
withKnownIssue {
155-
#expect(stderr.contains("Linking"))
156-
} when: {
157-
buildSystem == .swiftbuild // && ProcessInfo.hostOperatingSystem != .macOS
158-
}
150+
#expect(stderr.contains("Linking"))
159151
}
160152
} when: {
161-
(buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .windows)
162-
|| (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSmokeTestPipeline)
163-
|| (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
153+
buildSystem == .swiftbuild
164154
}
165155
}
166156

@@ -242,9 +232,7 @@ struct TestCommandTests {
242232
#expect(result.stderr.contains("-enable-testing"))
243233
}
244234
} when: {
245-
(buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem)
246-
// || (buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem && CiEnvironment.runningInSelfHostedPipeline)
247-
|| (buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem )
235+
buildSystem == .swiftbuild
248236
}
249237
}
250238

@@ -278,7 +266,7 @@ struct TestCommandTests {
278266
)
279267
}
280268
} when: {
281-
buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .windows
269+
buildSystem == .swiftbuild
282270
}
283271
}
284272

@@ -300,8 +288,7 @@ struct TestCommandTests {
300288
#expect(result.stderr.contains("-enable-testing"))
301289
}
302290
} when: {
303-
(buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem)
304-
|| (buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem && CiEnvironment.runningInSelfHostedPipeline)
291+
buildSystem == .swiftbuild
305292
}
306293
}
307294

@@ -667,7 +654,6 @@ struct TestCommandTests {
667654
} when: {
668655
(buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem)
669656
|| ProcessInfo.hostOperatingSystem == .windows
670-
|| (buildSystem == .swiftbuild && .macOS == ProcessInfo.hostOperatingSystem && tcdata.testRunner == .SwiftTesting)
671657
}
672658
}
673659

@@ -994,29 +980,23 @@ struct TestCommandTests {
994980
}
995981

996982
@Test(
997-
.SWBINTTODO("Fails to find test executable"),
998-
.issue("https://github.com/swiftlang/swift-package-manager/pull/8722", relationship: .fixedBy),
999983
arguments: SupportedBuildSystemOnAllPlatforms, BuildConfiguration.allCases,
1000984
)
1001985
func basicSwiftTestingIntegration(
1002986
buildSystem: BuildSystemProvider.Kind,
1003987
configuration: BuildConfiguration,
1004988
) async throws {
1005-
try await withKnownIssue("Fails to find the test executable") {
1006-
try await fixture(name: "Miscellaneous/TestDiscovery/SwiftTesting") { fixturePath in
1007-
let (stdout, stderr) = try await execute(
1008-
["--enable-swift-testing", "--disable-xctest"],
1009-
packagePath: fixturePath,
1010-
configuration: configuration,
1011-
buildSystem: buildSystem,
1012-
)
1013-
#expect(
1014-
stdout.contains(#"Test "SOME TEST FUNCTION" started"#),
1015-
"Expectation not met. got '\(stdout)'\nstderr: '\(stderr)'"
1016-
)
1017-
}
1018-
} when: {
1019-
buildSystem == .swiftbuild
989+
try await fixture(name: "Miscellaneous/TestDiscovery/SwiftTesting") { fixturePath in
990+
let (stdout, stderr) = try await execute(
991+
["--enable-swift-testing", "--disable-xctest"],
992+
packagePath: fixturePath,
993+
configuration: configuration,
994+
buildSystem: buildSystem,
995+
)
996+
#expect(
997+
stdout.contains(#"Test "SOME TEST FUNCTION" started"#),
998+
"Expectation not met. got '\(stdout)'\nstderr: '\(stderr)'"
999+
)
10201000
}
10211001
}
10221002

0 commit comments

Comments
 (0)