Skip to content

Commit 1d84e0f

Browse files
committed
Remove default run destination argument from build description tests
This makes it more obvious that a test is targeting the macOS platform, and makes our test infrastructure slightly less Apple-centric by ceasing to encode an implicit assumption of a default platform.
1 parent f8cceac commit 1d84e0f

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

Sources/SWBTestSupport/BuildDescriptionBasedTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extension BuildDescription {
3131
/// Category for tests which need to use BuildDescription objects.
3232
extension CoreBasedTests {
3333
// This should be private, but is public to work around a compiler bug: rdar://108924001 (Unexpected missing symbol in tests (optimizer issue?))
34-
package func buildGraph(for workspaceContext: WorkspaceContext, buildRequestContext: BuildRequestContext, configuration: String = "Debug", activeRunDestination: RunDestinationInfo? = .macOS, overrides: [String: String] = [:], useImplicitDependencies: Bool = false, dependencyScope: DependencyScope = .workspace, fs: any FSProxy = PseudoFS(), includingTargets predicate: (Target) -> Bool) async -> TargetBuildGraph {
34+
package func buildGraph(for workspaceContext: WorkspaceContext, buildRequestContext: BuildRequestContext, configuration: String = "Debug", activeRunDestination: RunDestinationInfo?, overrides: [String: String] = [:], useImplicitDependencies: Bool = false, dependencyScope: DependencyScope = .workspace, fs: any FSProxy = PseudoFS(), includingTargets predicate: (Target) -> Bool) async -> TargetBuildGraph {
3535
// Create a fake build request to build all targets.
3636
let parameters = BuildParameters(configuration: configuration, activeRunDestination: activeRunDestination, overrides: overrides)
3737
let buildTargets = workspaceContext.workspace.projects.flatMap{ project in
@@ -45,7 +45,7 @@ extension CoreBasedTests {
4545
return await TargetBuildGraph(workspaceContext: workspaceContext, buildRequest: buildRequest, buildRequestContext: buildRequestContext)
4646
}
4747

48-
package func planRequest(for workspace: Workspace, configuration: String = "Debug", activeRunDestination: RunDestinationInfo? = .macOS, overrides: [String: String] = [:], fs: any FSProxy = PseudoFS(), includingTargets predicate: (Target) -> Bool) async throws -> BuildPlanRequest {
48+
package func planRequest(for workspace: Workspace, configuration: String = "Debug", activeRunDestination: RunDestinationInfo?, overrides: [String: String] = [:], fs: any FSProxy = PseudoFS(), includingTargets predicate: (Target) -> Bool) async throws -> BuildPlanRequest {
4949
// Create a workspace context.
5050
let workspaceContext = try await WorkspaceContext(core: getCore(), workspace: workspace, fs: fs, processExecutionCache: .sharedForTesting)
5151

@@ -69,12 +69,12 @@ extension CoreBasedTests {
6969
return BuildPlanRequest(workspaceContext: buildGraph.workspaceContext, buildRequest: buildGraph.buildRequest, buildRequestContext: buildRequestContext, buildGraph: buildGraph, provisioningInputs: provisioningInputs)
7070
}
7171

72-
package func buildDescription(for workspace: Workspace, configuration: String = "Debug", activeRunDestination: RunDestinationInfo? = .macOS, overrides: [String: String] = [:], fs: any FSProxy = PseudoFS(), includingTargets predicate: (Target) -> Bool = { _ in true }) async throws -> (BuildDescription, WorkspaceContext) {
72+
package func buildDescription(for workspace: Workspace, configuration: String = "Debug", activeRunDestination: RunDestinationInfo?, overrides: [String: String] = [:], fs: any FSProxy = PseudoFS(), includingTargets predicate: (Target) -> Bool = { _ in true }) async throws -> (BuildDescription, WorkspaceContext) {
7373
let tuple: (BuildDescriptionDiagnosticResults, WorkspaceContext) = try await buildDescription(for: workspace, configuration: configuration, activeRunDestination: activeRunDestination, overrides: overrides, fs: fs, includingTargets: predicate)
7474
return (tuple.0.buildDescription, tuple.1)
7575
}
7676

77-
@_disfavoredOverload package func buildDescription(for workspace: Workspace, configuration: String = "Debug", activeRunDestination: RunDestinationInfo? = .macOS, overrides: [String: String] = [:], fs: any FSProxy = PseudoFS(), includingTargets predicate: (Target) -> Bool = { _ in true }) async throws -> (BuildDescriptionDiagnosticResults, WorkspaceContext) {
77+
@_disfavoredOverload package func buildDescription(for workspace: Workspace, configuration: String = "Debug", activeRunDestination: RunDestinationInfo?, overrides: [String: String] = [:], fs: any FSProxy = PseudoFS(), includingTargets predicate: (Target) -> Bool = { _ in true }) async throws -> (BuildDescriptionDiagnosticResults, WorkspaceContext) {
7878
let planRequest = try await self.planRequest(for: workspace, configuration: configuration, activeRunDestination: activeRunDestination, overrides: overrides, fs: fs, includingTargets: predicate)
7979
let delegate = MockTestBuildDescriptionConstructionDelegate()
8080
guard let results = try await BuildDescriptionManager.constructBuildDescription(planRequest, signature: "", inDirectory: .root, fs: fs, bypassActualTasks: true, clientDelegate: MockTestTaskPlanningClientDelegate(), constructionDelegate: delegate).map({ BuildDescriptionDiagnosticResults(buildDescription: $0, workspace: workspace) }) ?? nil else {

Tests/SWBTaskExecutionTests/BuildDescriptionTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
110110
let taskActionRegistry = try await TaskActionRegistry(pluginManager: core.pluginManager)
111111

112112
let fs1 = PseudoFS()
113-
let (description1, _) = try await buildDescription(for: workspace1, fs: fs1)
113+
let (description1, _) = try await buildDescription(for: workspace1, activeRunDestination: .macOS, fs: fs1)
114114
let manifest1Contents = try fs1.read(description1.manifestPath).bytes
115115
let serialized1 = { () -> ByteString in
116116
let serializer = MsgPackSerializer(delegate: BuildDescriptionSerializerDelegate(taskActionRegistry: taskActionRegistry))
@@ -122,7 +122,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
122122
for _ in 0 ..< 10 {
123123
let workspace2 = try await testWorkspace.load(getCore())
124124
let fs2 = PseudoFS()
125-
let (description2, _) = try await buildDescription(for: workspace2, fs: fs2)
125+
let (description2, _) = try await buildDescription(for: workspace2, activeRunDestination: .macOS, fs: fs2)
126126

127127
#expect(description1.targetDependencies == description2.targetDependencies)
128128

@@ -200,7 +200,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
200200
let workspace1 = try await testWorkspace.load(getCore())
201201

202202
let fs1 = PseudoFS()
203-
let (results, _) = try await buildDescription(for: workspace1, fs: fs1) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
203+
let (results, _) = try await buildDescription(for: workspace1, activeRunDestination: .macOS, fs: fs1) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
204204

205205
let interestingDiagnostics = results.errors.filter({ message -> Bool in
206206
message.hasPrefix("Multiple commands produce")
@@ -319,7 +319,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
319319
let tester = try await TaskConstructionTester(getCore(), project)
320320
let fs1 = PseudoFS()
321321
let (results, _) =
322-
try await buildDescription(for: tester.workspace, overrides: ["PACKAGE_BUILD_DYNAMICALLY": "YES"], fs: fs1)
322+
try await buildDescription(for: tester.workspace, activeRunDestination: .macOS, overrides: ["PACKAGE_BUILD_DYNAMICALLY": "YES"], fs: fs1)
323323
as (BuildDescriptionDiagnosticResults, WorkspaceContext)
324324
let interestingDiagnostics = results.errors.filter({ message -> Bool in
325325
message.hasPrefix("Multiple commands produce")
@@ -365,7 +365,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
365365
await deferrable.addBlock { await manager.waitForBuildDescriptionSerialization() }
366366

367367
func check(fs: any FSProxy, expected: [String], expectedSource: BuildDescriptionRetrievalSource) async throws {
368-
let planRequest = try await self.planRequest(for: workspace, fs: fs, includingTargets: { _ in true })
368+
let planRequest = try await self.planRequest(for: workspace, activeRunDestination: .macOS, fs: fs, includingTargets: { _ in true })
369369
let info = try await manager.getNewOrCachedBuildDescription(planRequest, clientDelegate: MockTestTaskPlanningClientDelegate())!
370370
#expect(info.source == expectedSource)
371371

@@ -434,7 +434,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
434434
let testWorkspace = TestWorkspace("aWorkspace", sourceRoot: tmpDirPath, projects: [testProject])
435435
let workspace = try await testWorkspace.load(getCore())
436436

437-
let (results, _) = try await buildDescription(for: workspace) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
437+
let (results, _) = try await buildDescription(for: workspace, activeRunDestination: .macOS) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
438438
results.checkNoDiagnostics()
439439
}
440440
}
@@ -472,7 +472,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
472472
let testWorkspace = TestWorkspace("aWorkspace", sourceRoot: tmpDirPath, projects: [testProject])
473473
let workspace = try await testWorkspace.load(getCore())
474474

475-
let (results, _) = try await buildDescription(for: workspace) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
475+
let (results, _) = try await buildDescription(for: workspace, activeRunDestination: .macOS) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
476476
results.checkNoDiagnostics()
477477
}
478478
}
@@ -510,7 +510,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
510510
let testWorkspace = TestWorkspace("aWorkspace", sourceRoot: tmpDirPath, projects: [testProject])
511511
let workspace = try await testWorkspace.load(getCore())
512512

513-
let (results, _) = try await buildDescription(for: workspace) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
513+
let (results, _) = try await buildDescription(for: workspace, activeRunDestination: .macOS) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
514514
#expect(results.errors.isEmpty, "Unexpected errors in build description: \(results.errors)")
515515
#expect(results.warnings == ["None of the architectures in ARCHS (foo) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (bar). (in target \'NoArchs\' from project 'aProject')"])
516516
}
@@ -547,7 +547,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
547547
let testWorkspace = TestWorkspace("aWorkspace", sourceRoot: tmpDirPath, projects: [testProject])
548548
let workspace = try await testWorkspace.load(getCore())
549549

550-
let (results, _) = try await buildDescription(for: workspace) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
550+
let (results, _) = try await buildDescription(for: workspace, activeRunDestination: .macOS) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
551551
#expect(results.errors.isEmpty, "Unexpected errors in build description: \(results.errors)")
552552
#expect(results.warnings == ["None of the architectures in ARCHS (foo) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (bar). (in target \'NoArchs\' from project 'aProject')"])
553553
}
@@ -585,7 +585,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
585585
let testWorkspace = TestWorkspace("aWorkspace", sourceRoot: tmpDirPath, projects: [testProject])
586586
let workspace = try await testWorkspace.load(getCore())
587587

588-
let (results, _) = try await buildDescription(for: workspace) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
588+
let (results, _) = try await buildDescription(for: workspace, activeRunDestination: .macOS) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
589589
#expect(results.errors.isEmpty, "Unexpected errors in build description: \(results.errors)")
590590
#expect(results.warnings == ["The active architecture (foo) is not valid - it is the only architecture considered because ONLY_ACTIVE_ARCH is enabled. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (bar). (in target \'NoArchs\' from project 'aProject')"])
591591
}
@@ -621,7 +621,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
621621
let testWorkspace = TestWorkspace("aWorkspace", sourceRoot: tmpDirPath, projects: [testProject])
622622
let workspace = try await testWorkspace.load(getCore())
623623

624-
let (results, _) = try await buildDescription(for: workspace) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
624+
let (results, _) = try await buildDescription(for: workspace, activeRunDestination: .macOS) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
625625
#expect(results.errors.isEmpty, "Unexpected errors in build description: \(results.errors)")
626626
#expect(results.warnings == ["There are no architectures to compile for because the VALID_ARCHS build setting is an empty list. (in target \'NoArchs\' from project 'aProject')"])
627627
}
@@ -657,7 +657,7 @@ fileprivate struct BuildDescriptionTests: CoreBasedTests {
657657
let testWorkspace = TestWorkspace("aWorkspace", sourceRoot: tmpDirPath, projects: [testProject])
658658
let workspace = try await testWorkspace.load(getCore())
659659

660-
let (results, _) = try await buildDescription(for: workspace) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
660+
let (results, _) = try await buildDescription(for: workspace, activeRunDestination: .macOS) as (BuildDescriptionDiagnosticResults, WorkspaceContext)
661661
#expect(results.errors.isEmpty, "Unexpected errors in build description: \(results.errors)")
662662
#expect(results.warnings == ["There are no architectures to compile for because the ARCHS build setting is an empty list. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (bar). (in target \'NoArchs\' from project 'aProject')"])
663663
}

Tests/SWBTaskExecutionTests/StaleFileRemovalTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fileprivate struct StaleFileRemovalTests: CoreBasedTests {
174174
for sanitizer in sanitizers {
175175
overrides[sanitizer.settingName] = "YES"
176176
}
177-
let planRequest = try await self.planRequest(for: workspace, configuration: configuration, overrides: overrides, fs: fs, includingTargets: { _ in true })
177+
let planRequest = try await self.planRequest(for: workspace, configuration: configuration, activeRunDestination: .macOS, overrides: overrides, fs: fs, includingTargets: { _ in true })
178178
let delegate = MockTestBuildDescriptionConstructionDelegate()
179179
let _ = try await manager.getNewOrCachedBuildDescription(planRequest, clientDelegate: MockTestTaskPlanningClientDelegate(), constructionDelegate: delegate)!
180180

0 commit comments

Comments
 (0)