Skip to content

Commit f409f06

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

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
@@ -268,8 +268,9 @@ extension LLBuildManifestBuilder {
268268

269269
let outputs = testEntryPointTarget.target.sources.paths
270270

271-
guard let mainOutput = (outputs.first { $0.basename == TestEntryPointTool.mainFileName }) else {
272-
throw InternalError("main output (\(TestEntryPointTool.mainFileName)) not found")
271+
let mainFileName = TestEntryPointTool.mainFileName(for: buildParameters.testingParameters.library)
272+
guard let mainOutput = (outputs.first { $0.basename == mainFileName }) else {
273+
throw InternalError("main output (\(mainFileName)) not found")
273274
}
274275
let cmdName = mainOutput.pathString
275276
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
@@ -109,7 +109,8 @@ extension BuildPlan {
109109
resolvedTargetDependencies: [ResolvedTarget.Dependency]
110110
) throws -> SwiftTargetBuildDescription {
111111
let entryPointDerivedDir = buildParameters.buildPath.appending(components: "\(testProduct.name).derived")
112-
let entryPointMainFile = entryPointDerivedDir.appending(component: TestEntryPointTool.mainFileName)
112+
let entryPointMainFileName = TestEntryPointTool.mainFileName(for: buildParameters.testingParameters.library)
113+
let entryPointMainFile = entryPointDerivedDir.appending(component: entryPointMainFileName)
113114
let entryPointSources = Sources(paths: [entryPointMainFile], root: entryPointDerivedDir)
114115

115116
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)