Skip to content

[Test Only] Make CachingBuildTests.testDependencyScanning be adaptable to scanner diagnostic revisions #1658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions Tests/SwiftDriverTests/CachingBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -829,15 +829,27 @@ final class CachingBuildTests: XCTestCase {
"-cas-path", casPath2.nativePathString(escaped: true),
]
var scanDiagnostics: [ScannerDiagnosticPayload] = []
XCTAssertThrowsError(try dependencyOracle.getDependencies(workingDirectory: path,
commandLine: command,
diagnostics: &scanDiagnostics)) {
XCTAssertTrue($0 is DependencyScanningError)
}
let diags = try XCTUnwrap(dependencyOracle.getScannerDiagnostics())
XCTAssertEqual(diags.count, 1)
XCTAssertEqual(diags[0].severity, .error)
XCTAssertEqual(diags[0].message, "CAS error encountered: conflicting CAS options used in scanning service")
do {
let _ = try dependencyOracle.getDependencies(workingDirectory: path,
commandLine: command,
diagnostics: &scanDiagnostics)
} catch let error {
XCTAssertTrue(error is DependencyScanningError)
}

let testDiagnostics: [ScannerDiagnosticPayload]
if try dependencyOracle.supportsPerScanDiagnostics(),
!scanDiagnostics.isEmpty {
testDiagnostics = scanDiagnostics
print("Using Per-Scan diagnostics")
} else {
testDiagnostics = try XCTUnwrap(dependencyOracle.getScannerDiagnostics())
print("Using Scanner-Global diagnostics")
}

XCTAssertEqual(testDiagnostics.count, 1)
XCTAssertEqual(testDiagnostics[0].severity, .error)
XCTAssertEqual(testDiagnostics[0].message, "CAS error encountered: conflicting CAS options used in scanning service")
}
}

Expand Down