Skip to content

Commit 8d500a0

Browse files
[Caching] Add test coverage for new APIs
Exercise new CAS APIs from libSwiftScan and SwiftDriver.
1 parent dd84527 commit 8d500a0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Tests/SwiftDriverTests/CachingBuildTests.swift

+15
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ 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+
let uploaded = try await compilation.makeGlobal()
130+
XCTAssertTrue(uploaded, "Cached output cannot be uploaded")
131+
// Execise call back uploading method.
132+
compilation.makeGlobal { error in
133+
XCTAssertTrue(error == nil, "Upload Error")
122134
}
123135
compilations.append(compilation)
124136
} else {
@@ -562,6 +574,9 @@ final class CachingBuildTests: XCTestCase {
562574
try fooBuildDriver.run(jobs: fooJobs)
563575
XCTAssertFalse(fooBuildDriver.diagnosticEngine.hasErrors)
564576

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

0 commit comments

Comments
 (0)