Skip to content

Commit 934c663

Browse files
committed
Tests: Add automated tests to verify dead code strip
Add an automated tests that validates SwiftBuild build system sets the dead code stip setting accordingly. Fixes: #9326 Issue: rdar://163962003
1 parent a10f663 commit 934c663

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

Tests/SwiftBuildSupportTests/SwiftBuildSystemTests.swift

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func withInstantiatedSwiftBuildSystem(
4646
let observabilitySystem: TestingObservability = ObservabilitySystem.makeForTesting()
4747
let toolchain = try UserToolchain.default
4848
let workspace = try Workspace(
49-
fileSystem: Basics.localFileSystem,
49+
fileSystem: fileSystem,
5050
forRootPackage: fixturePath,
5151
customManifestLoader: ManifestLoader(toolchain: toolchain),
5252
)
@@ -178,24 +178,18 @@ struct SwiftBuildSystemTests {
178178
),
179179
) { swiftBuild, session, observabilityScope, buildParameters in
180180

181-
#expect(false, "purposely failing")
182181
let buildSettings = try await swiftBuild.makeBuildParameters(
183182
session: session,
184183
symbolGraphOptions: nil,
184+
setToolchainSetting: false, // Set this to false as SwiftBuild checks the toolchain path
185185
)
186186

187-
let expectedValue: String? = switch linkerDeadStripUT {
188-
case true:
189-
"YES"
190-
case false:
191-
nil
192-
}
193-
194187
let synthesizedArgs = try #require(buildSettings.overrides.synthesized)
195-
let actual = try #require(synthesizedArgs.table["DEAD_CODE_STRIPPING"], "Code stripping value should not be nil")
196-
print("dead strip: \(linkerDeadStripUT) >>> Actual: '\(actual)' expected: '\(expectedValue)'")
197-
#expect(actual == expectedValue)
198-
#expect(false, "purposely failing")
188+
let actual = synthesizedArgs.table["DEAD_CODE_STRIPPING"]
189+
#expect(
190+
actual == expectedValue,
191+
"dead strip: \(linkerDeadStripUT) >>> Actual: '\(actual)' expected: '\(String(describing: expectedValue))'",
192+
)
199193
}
200194
}
201195
}

0 commit comments

Comments
 (0)