Skip to content

Commit 8786365

Browse files
[TEST-ONLY] Update compilation caching tests for latest compilers
Update compilation caching tests to work with latest compiler. This involves relaxing some tests to check for both old and new command-line and also encoding less compiler implementation details in the build system tests.
1 parent 127a156 commit 8786365

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Tests/SWBBuildSystemTests/ClangCompilationCachingTests.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,10 +1576,10 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
15761576
XCTAssertMatch(output.stringValue, .contains(#"-isysroot /\^sdk"#))
15771577
XCTAssertMatch(output.stringValue, .contains(#"-resource-dir /\^toolchain/usr/lib/clang/"#))
15781578
}
1579-
func checkModuleCommandLine(task: Task, results: BuildOperationTester.BuildResults, name: String) {
1579+
func checkModuleCommandLine(task: Task, results: BuildOperationTester.BuildResults, name: String) throws {
15801580
// The final command-line is only known to the dynamic task, but it's printed to output so we can check that.
1581-
results.checkTaskOutput(task) { output in
1582-
XCTAssertMatch(output.stringValue, .contains(#"\#(name)\=/\^mod"#))
1581+
try results.checkTaskOutput(task) { output in
1582+
XCTAssertMatch(output.stringValue, .or(.contains(#"\#(name)\=/\^mod"#), .contains(#"\#(name) /\^mod"#)))
15831583
checkCommandLineCommon(output: output)
15841584
}
15851585
}
@@ -1596,7 +1596,7 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
15961596
results.checkCompileCacheMiss(moduleTask)
15971597
results.checkCompileCacheMiss(tuTask)
15981598
results.checkNoDiagnostics()
1599-
checkModuleCommandLine(task: moduleTask, results: results, name: "Mod1")
1599+
try checkModuleCommandLine(task: moduleTask, results: results, name: "Mod1")
16001600
checkTUCommandLine(task: tuTask, results: results)
16011601
}
16021602

@@ -1607,7 +1607,7 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
16071607
results.checkCompileCacheHit(moduleTask)
16081608
results.checkCompileCacheHit(tuTask)
16091609
results.checkNoDiagnostics()
1610-
checkModuleCommandLine(task: moduleTask, results: results, name: "Mod2")
1610+
try checkModuleCommandLine(task: moduleTask, results: results, name: "Mod2")
16111611
checkTUCommandLine(task: tuTask, results: results)
16121612
}
16131613
}
@@ -1842,6 +1842,7 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
18421842
"CLANG_ENABLE_COMPILE_CACHE": enableCaching ? "YES" : "NO",
18431843
"CLANG_ENABLE_MODULES": "NO",
18441844
"COMPILATION_CACHE_CAS_PATH": casPath.str,
1845+
"DSTROOT": tmpDirPath.join("dstroot").str,
18451846
]
18461847
if usePlugin {
18471848
buildSettings["COMPILATION_CACHE_ENABLE_PLUGIN"] = "YES"
@@ -1966,7 +1967,11 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
19661967
// Ignore output for plugin CAS since it may not yet support validation.
19671968
try await checkBuild("validated successfully\n")
19681969
// Create an error and trigger revalidation by messing with the validation data.
1969-
try tester.fs.move(casPath.join("builtin/v1.1/v8.data"), to: casPath.join("builtin/v1.1/v8.data.moved"))
1970+
let dataDir = casPath.join("builtin").join("v1.1")
1971+
let dataFile = try #require(tester.fs.listdir(dataDir).first {
1972+
$0.hasSuffix(".data") && $0.hasPrefix("v")
1973+
})
1974+
try tester.fs.move(dataDir.join(dataFile), to: dataDir.join("moved"))
19701975
try await tester.fs.writeFileContents(casPath.join("builtin/v1.validation")) { stream in
19711976
stream <<< "0"
19721977
}

0 commit comments

Comments
 (0)