Skip to content

Commit f67ead1

Browse files
authored
Fix a bunch of tests accidentally reliant on in-memory caches (swiftlang#368)
These tests could occasionally fail if an in-memory build description was evicted at the right time. Ensure they can fallback to the individual temp directories' on disk caches
1 parent 25648e8 commit f67ead1

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

Tests/SWBBuildSystemTests/BuildBacktraceTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fileprivate struct BuildBacktraceTests: CoreBasedTests {
9898
}
9999
}
100100

101-
try await tester.checkNullBuild(runDestination: .macOS, buildRequest: buildRequest)
101+
try await tester.checkNullBuild(runDestination: .macOS, buildRequest: buildRequest, persistent: true)
102102

103103
try await tester.fs.writeFileContents(SRCROOT.join("Sources/foo.c")) { file in
104104
file <<<
@@ -441,7 +441,7 @@ fileprivate struct BuildBacktraceTests: CoreBasedTests {
441441
results.checkNoDiagnostics()
442442
}
443443

444-
try await tester.checkNullBuild(runDestination: .macOS, buildRequest: buildRequest, signableTargets: Set(provisioningInputs.keys), signableTargetInputs: provisioningInputs)
444+
try await tester.checkNullBuild(runDestination: .macOS, buildRequest: buildRequest, persistent: true, signableTargets: Set(provisioningInputs.keys), signableTargetInputs: provisioningInputs)
445445

446446
try await tester.fs.writeFileContents(SRCROOT.join("Sources/foo.c")) { file in
447447
file <<<

Tests/SWBBuildSystemTests/BuildOperationTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3066,7 +3066,7 @@ That command depends on command in Target 'agg2' (project \'aProject\'): script
30663066
let buildTargets = tester.workspace.projects[0].targets.map { BuildRequest.BuildTargetInfo(parameters: parameters, target: $0) }
30673067
let buildRequest = BuildRequest(parameters: parameters, buildTargets: buildTargets, dependencyScope: .workspace, continueBuildingAfterErrors: false, useParallelTargets: true, useImplicitDependencies: false, useDryRun: false, buildCommand: .build(style: .buildOnly, skipDependencies: false), schemeCommand: .launch)
30683068

3069-
try await tester.checkBuild(parameters: parameters, runDestination: runDestination, buildRequest: buildRequest, signableTargets: signableTargets) { results in
3069+
try await tester.checkBuild(parameters: parameters, runDestination: runDestination, buildRequest: buildRequest, persistent: true, signableTargets: signableTargets) { results in
30703070
results.checkNoDiagnostics()
30713071
results.consumeTasksMatchingRuleTypes()
30723072

@@ -3436,7 +3436,7 @@ That command depends on command in Target 'agg2' (project \'aProject\'): script
34363436

34373437
// Perform the first (clean) build and expect to see a compile task.
34383438
try await confirmation("First archive should succeed.") { firstBuildSucceed in
3439-
try await tester.checkBuild(parameters: parameters, runDestination: .macOS) { results in
3439+
try await tester.checkBuild(parameters: parameters, runDestination: .macOS, persistent: true) { results in
34403440
results.checkTask(.matchRuleItem("CompileC"), body: { _ in })
34413441
results.checkTasks { tasks in
34423442
#expect(tasks.count > 0)
@@ -3448,7 +3448,7 @@ That command depends on command in Target 'agg2' (project \'aProject\'): script
34483448

34493449
// Perform the second (incremental) build, and expect to see no tasks run because we didn't change anything.
34503450
try await confirmation("Second archive should succeed.") { secondBuildSucceed in
3451-
try await tester.checkBuild(parameters: parameters, runDestination: .macOS) { results in
3451+
try await tester.checkBuild(parameters: parameters, runDestination: .macOS, persistent: true) { results in
34523452
results.checkTasks(.matchRuleType("ClangStatCache")) { _ in }
34533453
if tester.userPreferences.enableBuildSystemCaching {
34543454
results.checkNoTask()

Tests/SWBBuildSystemTests/ClangExplicitModulesTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ fileprivate struct ClangExplicitModulesTests: CoreBasedTests {
18361836
"""
18371837
}
18381838

1839-
try await tester.checkBuild(runDestination: .macOS) { results in
1839+
try await tester.checkBuild(runDestination: .macOS, persistent: true) { results in
18401840
// There be 2 scanning actions.
18411841
results.checkTasks(.matchRuleType("ScanDependencies")) { scanTasks in
18421842
#expect(scanTasks.count == 2)
@@ -1856,7 +1856,7 @@ fileprivate struct ClangExplicitModulesTests: CoreBasedTests {
18561856
"""
18571857
}
18581858

1859-
try await tester.checkBuild(runDestination: .macOS) { results in
1859+
try await tester.checkBuild(runDestination: .macOS, persistent: true) { results in
18601860
// There should 2 scanning actions.
18611861
// Both files will recompile.
18621862
results.checkTasks(.matchRuleType("ScanDependencies")) { compileTasks in
@@ -1892,7 +1892,7 @@ fileprivate struct ClangExplicitModulesTests: CoreBasedTests {
18921892
"""
18931893
}
18941894

1895-
try await tester.checkBuild(runDestination: .macOS) { results in
1895+
try await tester.checkBuild(runDestination: .macOS, persistent: true) { results in
18961896
// There should 2 scanning actions.
18971897
// Both files will recompile.
18981898
results.checkTasks(.matchRuleType("ScanDependencies")) { compileTasks in

Tests/SWBBuildSystemTests/InstallAPIBuildOperationTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fileprivate struct InstallAPIBuildOperationTests: CoreBasedTests {
7676
results.checkNoDiagnostics()
7777
}
7878

79-
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS)
79+
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS, persistent: true)
8080

8181
// Update a public header.
8282
try await tester.fs.writeFileContents(testWorkspace.sourceRoot.join("aProject/Public.h"), body: { $0 <<< "void f(void); // prototype" })
@@ -86,7 +86,7 @@ fileprivate struct InstallAPIBuildOperationTests: CoreBasedTests {
8686
results.checkNoDiagnostics()
8787
}
8888

89-
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS)
89+
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS, persistent: true)
9090

9191
// Update a private header.
9292
try await tester.fs.writeFileContents(testWorkspace.sourceRoot.join("aProject/Private.h"), body: { $0 <<< "void g(void); // prototype" })
@@ -96,7 +96,7 @@ fileprivate struct InstallAPIBuildOperationTests: CoreBasedTests {
9696
results.checkNoDiagnostics()
9797
}
9898

99-
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS)
99+
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS, persistent: true)
100100
try await tester.checkBuild(parameters: parameters, runDestination: .macOS, buildCommand: .cleanBuildFolder(style: .regular)) { _ in }
101101
}
102102
}
@@ -161,7 +161,7 @@ fileprivate struct InstallAPIBuildOperationTests: CoreBasedTests {
161161
results.checkNoDiagnostics()
162162
}
163163

164-
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS)
164+
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS, persistent: true)
165165

166166
// Update a private header.
167167
try await tester.fs.writeFileContents(testWorkspace.sourceRoot.join("aProject/Private.h"), body: { $0 <<< "void g(void); // prototype" })
@@ -171,7 +171,7 @@ fileprivate struct InstallAPIBuildOperationTests: CoreBasedTests {
171171
results.checkNoDiagnostics()
172172
}
173173

174-
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS)
174+
try await tester.checkNullBuild(parameters: parameters, runDestination: .macOS, persistent: true)
175175
try await tester.checkBuild(parameters: parameters, runDestination: .macOS, buildCommand: .cleanBuildFolder(style: .regular)) { _ in }
176176
}
177177
}
@@ -253,7 +253,7 @@ fileprivate struct InstallAPIBuildOperationTests: CoreBasedTests {
253253
results.checkNoDiagnostics()
254254
}
255255

256-
try await tester.checkNullBuild(parameters: parameters(excludePublicHeader: true, excludePrivateHeader: false), runDestination: .macOS)
256+
try await tester.checkNullBuild(parameters: parameters(excludePublicHeader: true, excludePrivateHeader: false), runDestination: .macOS, persistent: true)
257257

258258
try await tester.checkBuild(parameters: parameters(excludePublicHeader: true, excludePrivateHeader: true), runDestination: .macOS, persistent: true) { results in
259259
try results.checkTask(.matchRuleType("GenerateTAPI")) { tapiTask in
@@ -265,7 +265,7 @@ fileprivate struct InstallAPIBuildOperationTests: CoreBasedTests {
265265
results.checkNoDiagnostics()
266266
}
267267

268-
try await tester.checkNullBuild(parameters: parameters(excludePublicHeader: true, excludePrivateHeader: true), runDestination: .macOS)
268+
try await tester.checkNullBuild(parameters: parameters(excludePublicHeader: true, excludePrivateHeader: true), runDestination: .macOS, persistent: true)
269269
try await tester.checkBuild(parameters: parameters(excludePublicHeader: true, excludePrivateHeader: true), runDestination: .macOS, buildCommand: .cleanBuildFolder(style: .regular)) { _ in }
270270
}
271271
}

0 commit comments

Comments
 (0)