Skip to content

Commit

Permalink
Fix the PluginInvocationTests.testCompilationDiagnostics() test so th…
Browse files Browse the repository at this point in the history
…at 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.
  • Loading branch information
abertelrud authored Jan 27, 2023
1 parent 7981b85 commit e05a2b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Tests/SPMBuildCoreTests/PluginInvocationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,11 @@ class PluginInvocationTests: XCTestCase {
let diaFileContents = try localFileSystem.readFileContents(result.diagnosticsFile)
let diagnosticsSet = try SerializedDiagnostics(bytes: diaFileContents)
let hasExpectedDiagnosticsCount = diagnosticsSet.diagnostics.count == 1
let warningDiagnostic = try XCTUnwrap(diagnosticsSet.diagnostics.first)
let hasExpectedWarningText = warningDiagnostic.text.hasPrefix("variable \'unused\' was never used")
let warningDiagnosticText = diagnosticsSet.diagnostics.first?.text ?? ""
let hasExpectedWarningText = warningDiagnosticText.hasPrefix("variable \'unused\' was never used")
if hasExpectedDiagnosticsCount && hasExpectedWarningText {
XCTAssertTrue(hasExpectedDiagnosticsCount, "unexpected diagnostics count in \(diagnosticsSet.diagnostics) from \(result.diagnosticsFile.pathString)")
XCTAssertTrue(hasExpectedWarningText, "\(warningDiagnostic)")
XCTAssertTrue(hasExpectedWarningText, "\(warningDiagnosticText)")
} else {
print("bytes of serialized diagnostics file `\(result.diagnosticsFile.pathString)`: \(diaFileContents.contents)")
try XCTSkipIf(true, "skipping because of unknown serialized diagnostics issue")
Expand Down

0 comments on commit e05a2b8

Please sign in to comment.