Skip to content

Commit 719b686

Browse files
committed
Remove TaskConstructionTester default run destination argument
This makes it more obvious that a task construction 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 e2c28f5 commit 719b686

File tree

60 files changed

+791
-788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+791
-788
lines changed

Sources/SWBTestSupport/PlatformFilter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ extension CoreBasedTests {
126126

127127
let filtersString = platformFilters.sorted().map { $0.platform + ($0.environment.nilIfEmpty.map { "-\($0)"} ?? "") }.joined(separator: ", ") // Just for test logging.
128128

129-
try await TaskConstructionTester(core, testWorkspace).checkBuild(BuildParameters(configuration: "Debug", activeRunDestination: runDestination), userPreferences: UserPreferences.defaultForTesting.with(enableDebugActivityLogs: true)) { results in
129+
try await TaskConstructionTester(core, testWorkspace).checkBuild(BuildParameters(configuration: "Debug"), runDestination: runDestination, userPreferences: UserPreferences.defaultForTesting.with(enableDebugActivityLogs: true)) { results in
130130
results.consumeTasksMatchingRuleTypes(["CreateBuildDirectory", "CreateUniversalBinary", "Gate", "GenerateDSYMFile", "Ld", "MkDir", "ProcessInfoPlistFile", "RegisterExecutionPolicyException", "RegisterWithLaunchServices", "SymLink", "Touch", "WriteAuxiliaryFile", "Validate"])
131131

132132
// We should always build this

Sources/SWBTestSupport/TaskConstructionTester.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,16 @@ package final class TaskConstructionTester {
766766
let parameters = parameters ?? BuildParameters(configuration: "Debug")
767767

768768
// If the build parameters don't specify a run destination, but we were passed one, then use the one we were passed. (checkBuild() defaults this to .macOS.)
769-
let runDestination = parameters.activeRunDestination ?? runDestination
769+
let activeRunDestination: RunDestinationInfo? = switch (parameters.activeRunDestination, runDestination) {
770+
case let (.some(lhs), (.some(rhs))):
771+
preconditionFailure("Specified run destinations from both explicit build parameters and default destination: \(lhs), \(rhs)")
772+
case let (.some(destination), nil):
773+
destination
774+
case let (nil, .some(destination)):
775+
destination
776+
case (nil, nil):
777+
nil
778+
}
770779

771780
// Define a default set of overrides.
772781
var overrides = [
@@ -781,14 +790,14 @@ package final class TaskConstructionTester {
781790

782791
// If we have a run destination, then we default ONLY_ACTIVE_ARCH to YES. This means when they build with a non-generic run destination, that run destination's architecture will be used rather than building universal.
783792
// If we don't have a run destination, then defaulting ONLY_ACTIVE_ARCH is probably the wrong thing to do.
784-
if runDestination != nil {
793+
if activeRunDestination != nil {
785794
overrides["ONLY_ACTIVE_ARCH"] = "YES"
786795
}
787796
// Add overrides from the parameters we were passed, which will supersede the default overrides above.
788797
overrides.addContents(of: parameters.overrides)
789798

790799
// Create and return the effective parameters.
791-
return BuildParameters(action: parameters.action, configuration: parameters.configuration, activeRunDestination: runDestination, activeArchitecture: parameters.activeArchitecture, overrides: overrides, commandLineOverrides: parameters.commandLineOverrides, commandLineConfigOverridesPath: parameters.commandLineConfigOverridesPath, commandLineConfigOverrides: parameters.commandLineConfigOverrides, environmentConfigOverridesPath: parameters.environmentConfigOverridesPath, environmentConfigOverrides: parameters.environmentConfigOverrides, arena: parameters.arena)
800+
return BuildParameters(action: parameters.action, configuration: parameters.configuration, activeRunDestination: activeRunDestination, activeArchitecture: parameters.activeArchitecture, overrides: overrides, commandLineOverrides: parameters.commandLineOverrides, commandLineConfigOverridesPath: parameters.commandLineConfigOverridesPath, commandLineConfigOverrides: parameters.commandLineConfigOverrides, environmentConfigOverridesPath: parameters.environmentConfigOverridesPath, environmentConfigOverrides: parameters.environmentConfigOverrides, arena: parameters.arena)
792801
}
793802

794803
/// Returns the effective build request to use for the build.
@@ -819,7 +828,7 @@ package final class TaskConstructionTester {
819828
/// Construct the tasks for the given build parameters, and test the result.
820829
/// - parameter runDestination: If the run destination in `parameter` is nil, then the value passed here will be used instead. Due to the defined default value, this means that tests build for macOS unless they specify otherwise.
821830
/// - parameter checkTaskGraphIntegrity: If `true` (the default), then the task graph's integrity will be checked, and test errors will be emitted for scenarios such as missing producers for nodes, and multiple producers for nodes. A test may wish to pass `false` for this if it is deliberately constructing a bad task graph in order to examine the resulting errors.
822-
package func checkBuild(_ inputParameters: BuildParameters? = nil, runDestination: SWBProtocol.RunDestinationInfo? = .macOS, targetName: String? = nil, buildRequest inputBuildRequest: BuildRequest? = nil, provisioningOverrides: ProvisioningTaskInputs? = nil, processEnvironment: [String: String] = [:], fs: any FSProxy = PseudoFS(), userPreferences: UserPreferences? = nil, clientDelegate: (any TaskPlanningClientDelegate)? = nil, checkTaskGraphIntegrity: Bool = true, useDefaultToolChainOverride: Bool = true, systemInfo: SystemInfo? = nil, sourceLocation: SourceLocation = #_sourceLocation, body: (PlanningResults) async throws -> Void) async rethrows {
831+
package func checkBuild(_ inputParameters: BuildParameters? = nil, runDestination: SWBProtocol.RunDestinationInfo?, targetName: String? = nil, buildRequest inputBuildRequest: BuildRequest? = nil, provisioningOverrides: ProvisioningTaskInputs? = nil, processEnvironment: [String: String] = [:], fs: any FSProxy = PseudoFS(), userPreferences: UserPreferences? = nil, clientDelegate: (any TaskPlanningClientDelegate)? = nil, checkTaskGraphIntegrity: Bool = true, useDefaultToolChainOverride: Bool = true, systemInfo: SystemInfo? = nil, sourceLocation: SourceLocation = #_sourceLocation, body: (PlanningResults) async throws -> Void) async rethrows {
823832
// For test stability we modify the build parameters we were passed.
824833
let parameters = effectiveBuildParameters(inputParameters ?? inputBuildRequest?.parameters, runDestination: runDestination, useDefaultToolChainOverride: useDefaultToolChainOverride)
825834

@@ -1009,7 +1018,7 @@ extension TaskConstructionTester {
10091018
runDestination: runDestination,
10101019
sourceLocation: sourceLocation
10111020
)
1012-
return try await checkBuild(buildRequest: buildRequest, systemInfo: systemInfo, sourceLocation: sourceLocation, body: body)
1021+
return try await checkBuild(runDestination: runDestination, buildRequest: buildRequest, systemInfo: systemInfo, sourceLocation: sourceLocation, body: body)
10131022
}
10141023
}
10151024

Tests/SWBCoreTests/ProductTypesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fileprivate struct ProductTypesTests: CoreBasedTests {
7171
let fs = PseudoFS()
7272

7373
let tester = try TaskConstructionTester(core, testWorkspace)
74-
await tester.checkBuild(BuildParameters(action: .install, configuration: "Release"), fs: fs) { results in
74+
await tester.checkBuild(BuildParameters(action: .install, configuration: "Release"), runDestination: .macOS, fs: fs) { results in
7575
results.consumeTasksMatchingRuleTypes(["CreateBuildDirectory", "WriteAuxiliaryFile", "Gate", "RegisterExecutionPolicyException", "SetOwnerAndGroup", "SetMode", "ProcessInfoPlistFile", "ProcessProductPackaging", "ProcessProductPackagingDER", "ProcessInfoPlist"])
7676

7777
results.checkTarget("aFramework") { target in

Tests/SWBCoreTests/SettingsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4191,7 +4191,7 @@ import SWBMacro
41914191
let buildRequestContext = BuildRequestContext(workspaceContext: context)
41924192
let tester = try await TaskConstructionTester(getCore(), testWorkspace)
41934193

4194-
await tester.checkBuild() { results in
4194+
await tester.checkBuild(runDestination: .macOS) { results in
41954195
results.checkNoDiagnostics()
41964196
results.checkNote("A script phase disables sandboxing, forcing `EAGER_COMPILATION_ALLOW_SCRIPTS` to off (in target \'A\' from project \'aProject\')")
41974197

Tests/SWBTaskConstructionPerfTests/TaskConstructionPerfTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fileprivate struct TaskConstructionPerfTests: CoreBasedTests, PerfTests {
5252
)
5353
let tester = try await TaskConstructionTester(self.getCore(), testWorkspace)
5454
await measure {
55-
await tester.checkBuild(checkTaskGraphIntegrity: false) { tester in
55+
await tester.checkBuild(runDestination: .macOS, checkTaskGraphIntegrity: false) { tester in
5656
tester.checkTasks(.matchRuleType("CreateBuildDirectory")) { tasks in
5757
#expect(tasks.count == 1503)
5858
}

Tests/SWBTaskConstructionTests/AppClipTaskConstructionTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fileprivate struct AppClipTaskConstructionTests: CoreBasedTests {
2525
let fs = PseudoFS()
2626
let tester = try await TaskConstructionTester(getCore(), TestProject.appClip(sourceRoot: tmpDir, fs: fs))
2727

28-
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug", activeRunDestination: .iOS), fs: fs) { results in
28+
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug"), runDestination: .iOS, fs: fs) { results in
2929
results.checkNoDiagnostics()
3030
for variant in ["thinned", "unthinned"] {
3131
results.checkTask(.matchTargetName("Foo"), .matchRuleType("CompileAssetCatalogVariant"), .matchRuleItem(variant)) { task in
@@ -40,14 +40,14 @@ fileprivate struct AppClipTaskConstructionTests: CoreBasedTests {
4040
}
4141
}
4242

43-
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug", activeRunDestination: .iOSSimulator), fs: fs) { results in
43+
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug"), runDestination: .iOSSimulator, fs: fs) { results in
4444
results.checkNoDiagnostics()
4545
results.checkTask(.matchTargetName("Foo"), .matchRuleType("ValidateEmbeddedBinary")) { task in
4646
task.checkCommandLine(["embeddedBinaryValidationUtility", "\(tmpDir.str)/build/Debug-iphonesimulator/Foo.app/AppClips/BarClip.app", "-info-plist-path", "\(tmpDir.str)/build/Debug-iphonesimulator/Foo.app/Info.plist"])
4747
}
4848
}
4949

50-
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug", activeRunDestination: .macCatalyst), fs: fs) { results in
50+
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug"), runDestination: .macCatalyst, fs: fs) { results in
5151
results.checkNoDiagnostics()
5252
results.checkTask(.matchTargetName("Foo"), .matchRuleType("Ld")) { task in
5353
task.checkCommandLineLastArgumentEqual("\(tmpDir.str)/build/Debug\(MacCatalystInfo.publicSDKBuiltProductsDirSuffix)/Foo.app/Contents/MacOS/Foo")

Tests/SWBTaskConstructionTests/AppExtensionTaskConstructionTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ fileprivate struct AppExtensionTaskConstructionTests: CoreBasedTests {
7272
])
7373
let tester = try await TaskConstructionTester(getCore(), testProject)
7474

75-
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug", activeRunDestination: .macOS)) { results in
75+
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug"), runDestination: .macOS) { results in
7676
results.checkNoDiagnostics()
7777
results.checkTask(.matchTargetName("Foo"), .matchRule(["Copy", "/tmp/Test/aProject/build/Debug/Foo.app/Contents/Extensions/Modern.appex", "/tmp/Test/aProject/build/Debug/Modern.appex"])) { task in }
7878
results.checkTask(.matchTargetName("Foo"), .matchRule(["Copy", "/tmp/Test/aProject/build/Debug/Foo.app/Contents/PlugIns/Legacy.appex", "/tmp/Test/aProject/build/Debug/Legacy.appex"])) { task in }
7979
}
8080

81-
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug", activeRunDestination: .iOS)) { results in
81+
await tester.checkBuild(BuildParameters(action: .build, configuration: "Debug"), runDestination: .iOS) { results in
8282
results.checkNoDiagnostics()
8383
results.checkTask(.matchTargetName("Foo"), .matchRule(["Copy", "/tmp/Test/aProject/build/Debug-iphoneos/Foo.app/Extensions/Modern.appex", "/tmp/Test/aProject/build/Debug-iphoneos/Modern.appex"])) { task in }
8484
results.checkTask(.matchTargetName("Foo"), .matchRule(["Copy", "/tmp/Test/aProject/build/Debug-iphoneos/Foo.app/PlugIns/Legacy.appex", "/tmp/Test/aProject/build/Debug-iphoneos/Legacy.appex"])) { task in }

0 commit comments

Comments
 (0)