Skip to content

Commit 1dec9d4

Browse files
[Caching] Add test coverage for new APIs
Exercise new CAS APIs from libSwiftScan and SwiftDriver.
1 parent 575e1ef commit 1dec9d4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Tests/SwiftDriverTests/CachingBuildTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ private func checkCASForResults(jobs: [Job], cas: SwiftScanCAS, fs: FileSystem)
119119
XCTAssertTrue(output.isMaterialized, "Cached output not founded in CAS")
120120
let success = try await output.load()
121121
XCTAssertTrue(success, "Cached output not founded in CAS")
122+
123+
// Try async download. Download should succeed even on a local CAS.
124+
let casID = try output.getCASID()
125+
let downloaded = try await cas.download(with: casID)
126+
XCTAssertTrue(downloaded, "Cached output cannot be downloaded")
127+
}
128+
// Execise the uploading path.
129+
try await compilation.makeGlobal()
130+
// Execise call back uploading method.
131+
compilation.makeGlobal { error in
132+
XCTAssertTrue(error == nil, "Upload Error")
122133
}
123134
compilations.append(compilation)
124135
} else {
@@ -562,6 +573,9 @@ final class CachingBuildTests: XCTestCase {
562573
try fooBuildDriver.run(jobs: fooJobs)
563574
XCTAssertFalse(fooBuildDriver.diagnosticEngine.hasErrors)
564575

576+
let cas = try dependencyOracle.createCAS(pluginPath: nil, onDiskPath: casPath, pluginOptions: [])
577+
try checkCASForResults(jobs: fooJobs, cas: cas, fs: fooBuildDriver.fileSystem)
578+
565579
var driver = try Driver(args: ["swiftc",
566580
"-I", FooInstallPath.nativePathString(escaped: true),
567581
"-explicit-module-build", "-emit-module", "-emit-module-path",

0 commit comments

Comments
 (0)