Skip to content

Commit ccb4847

Browse files
committed
Use a different file name for the test product's entry point main function.
1 parent 718e69a commit ccb4847

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

Sources/Build/BuildManifest/LLBuildManifestBuilder.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,9 @@ extension LLBuildManifestBuilder {
266266

267267
let outputs = testEntryPointTarget.target.sources.paths
268268

269-
guard let mainOutput = (outputs.first { $0.basename == TestEntryPointTool.mainFileName }) else {
270-
throw InternalError("main output (\(TestEntryPointTool.mainFileName)) not found")
269+
let mainFileName = TestEntryPointTool.mainFileName(for: buildParameters.testingParameters.library)
270+
guard let mainOutput = (outputs.first { $0.basename == mainFileName }) else {
271+
throw InternalError("main output (\(mainFileName)) not found")
271272
}
272273
let cmdName = mainOutput.pathString
273274
self.manifest.addTestEntryPointCmd(

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,22 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
200200
}
201201
}
202202

203+
extension TestEntryPointTool {
204+
public static func mainFileName(for library: BuildParameters.Testing.Library) -> String {
205+
"runner-\(library).swift"
206+
}
207+
}
208+
203209
final class TestEntryPointCommand: CustomLLBuildCommand, TestBuildCommand {
204210
private func execute(fileSystem: Basics.FileSystem, tool: TestEntryPointTool) throws {
205211
let outputs = tool.outputs.compactMap { try? AbsolutePath(validating: $0.name) }
206212

207213
// Find the main output file
214+
let mainFileName = TestEntryPointTool.mainFileName(for: self.context.buildParameters.testingParameters.library)
208215
guard let mainFile = outputs.first(where: { path in
209-
path.basename == TestEntryPointTool.mainFileName
216+
path.basename == mainFileName
210217
}) else {
211-
throw InternalError("main file output (\(TestEntryPointTool.mainFileName)) not found")
218+
throw InternalError("main file output (\(mainFileName)) not found")
212219
}
213220

214221
// Write the main file.

Sources/Build/BuildPlan/BuildPlan+Test.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ extension BuildPlan {
106106
/// point API and leverages the test discovery target to reference which tests to run.
107107
func generateSynthesizedEntryPointTarget(discoveryTarget: SwiftTarget, discoveryResolvedTarget: ResolvedTarget) throws -> SwiftTargetBuildDescription {
108108
let entryPointDerivedDir = buildParameters.buildPath.appending(components: "\(testProduct.name).derived")
109-
let entryPointMainFile = entryPointDerivedDir.appending(component: TestEntryPointTool.mainFileName)
109+
let entryPointMainFileName = TestEntryPointTool.mainFileName(for: buildParameters.testingParameters.library)
110+
let entryPointMainFile = entryPointDerivedDir.appending(component: entryPointMainFileName)
110111
let entryPointSources = Sources(paths: [entryPointMainFile], root: entryPointDerivedDir)
111112

112113
let entryPointTarget = SwiftTarget(

Sources/LLBuildManifest/Tools.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public struct TestDiscoveryTool: ToolProtocol {
6363

6464
public struct TestEntryPointTool: ToolProtocol {
6565
public static let name: String = "test-entry-point-tool"
66-
public static let mainFileName: String = "runner.swift"
6766

6867
public var inputs: [Node]
6968
public var outputs: [Node]

0 commit comments

Comments
 (0)