Skip to content

Commit e05a2b8

Browse files
authored
Fix the PluginInvocationTests.testCompilationDiagnostics() test so that it doesn't throw if there are no diagnostics at all reported (#6080)
This is a supplemental fix for #6076 to avoid the XCTUnwrap() that causes the test to still fail.
1 parent 7981b85 commit e05a2b8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Tests/SPMBuildCoreTests/PluginInvocationTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,11 @@ class PluginInvocationTests: XCTestCase {
418418
let diaFileContents = try localFileSystem.readFileContents(result.diagnosticsFile)
419419
let diagnosticsSet = try SerializedDiagnostics(bytes: diaFileContents)
420420
let hasExpectedDiagnosticsCount = diagnosticsSet.diagnostics.count == 1
421-
let warningDiagnostic = try XCTUnwrap(diagnosticsSet.diagnostics.first)
422-
let hasExpectedWarningText = warningDiagnostic.text.hasPrefix("variable \'unused\' was never used")
421+
let warningDiagnosticText = diagnosticsSet.diagnostics.first?.text ?? ""
422+
let hasExpectedWarningText = warningDiagnosticText.hasPrefix("variable \'unused\' was never used")
423423
if hasExpectedDiagnosticsCount && hasExpectedWarningText {
424424
XCTAssertTrue(hasExpectedDiagnosticsCount, "unexpected diagnostics count in \(diagnosticsSet.diagnostics) from \(result.diagnosticsFile.pathString)")
425-
XCTAssertTrue(hasExpectedWarningText, "\(warningDiagnostic)")
425+
XCTAssertTrue(hasExpectedWarningText, "\(warningDiagnosticText)")
426426
} else {
427427
print("bytes of serialized diagnostics file `\(result.diagnosticsFile.pathString)`: \(diaFileContents.contents)")
428428
try XCTSkipIf(true, "skipping because of unknown serialized diagnostics issue")

0 commit comments

Comments
 (0)