Skip to content

Commit eb4053a

Browse files
committed
Lower severity of the diagnostic when the "source" of a symbol graph relationship is missing.
Since the solution is for the tool that created the symbol graph file to not emit that relationship, DocC can safely skip it and proceed with the build. This issue isn't severe enough to fail the build.
1 parent 4d7a293 commit eb4053a

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphRelationshipsBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct SymbolGraphRelationshipsBuilder {
1818
static func sourceNotFound(_ relationship: SymbolGraph.Relationship) -> Problem {
1919
return Problem(
2020
diagnostic: Diagnostic(
21-
source: nil, severity: .error, range: nil,identifier: "org.swift.docc.SymbolNodeNotFound",
21+
source: nil, severity: .warning, range: nil,identifier: "org.swift.docc.SymbolNodeNotFound",
2222
summary: "Source symbol \(relationship.source.singleQuoted) not found locally, from \(relationship.kind.rawValue.singleQuoted) relationship to \(relationship.target.singleQuoted)",
2323
explanation: """
2424
The "source" of a symbol graph relationship should always refer to a symbol in the same symbol graph file.

Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,7 @@ class ConvertActionTests: XCTestCase {
900900
temporaryDirectory: testDataProvider.uniqueTemporaryDirectory())
901901
let result = try action.perform(logHandle: .none)
902902

903-
XCTAssert(
904-
result.didEncounterError,
905-
"We expect errors to occur during during conversion of the bad test bundle."
906-
)
903+
XCTAssertFalse(result.didEncounterError, "The issues with this test bundle are not severe enough to fail the build.")
907904

908905
// Verify that the build output folder from the former successful conversion
909906
// still exists after this failure.
@@ -945,7 +942,7 @@ class ConvertActionTests: XCTestCase {
945942
Digest.Diagnostic(
946943
start: nil,
947944
source: nil,
948-
severity: .error,
945+
severity: .warning,
949946
summary: "Source symbol 's:5MyKit0A5ProtocolP' not found locally, from 'conformsTo' relationship to 's:5Foundation0A5EarhartP'",
950947
explanation: """
951948
The "source" of a symbol graph relationship should always refer to a symbol in the same symbol graph file.
@@ -2421,8 +2418,8 @@ class ConvertActionTests: XCTestCase {
24212418
)
24222419
let result = try action.perform(logHandle: .none)
24232420

2424-
XCTAssertEqual(engine.problems.count, 1, "\(ConvertAction.self) didn't filter out diagnostics above the 'error' level.")
2425-
XCTAssert(result.didEncounterError)
2421+
XCTAssertEqual(engine.problems.count, 0, "\(ConvertAction.self) didn't filter out diagnostics at-or-above the 'error' level.")
2422+
XCTAssertFalse(result.didEncounterError, "The issues with this test bundle are not severe enough to fail the build.")
24262423
}
24272424

24282425
func testDiagnosticLevelIgnoredWhenAnalyzeIsPresent() throws {
@@ -2461,7 +2458,7 @@ class ConvertActionTests: XCTestCase {
24612458

24622459
XCTAssertEqual(engine.problems.count, 2, "\(ConvertAction.self) shouldn't filter out diagnostics when the '--analyze' flag is passed")
24632460
XCTAssertEqual(engine.problems.map { $0.diagnostic.identifier }, ["org.swift.docc.Article.Title.NotFound", "org.swift.docc.SymbolNodeNotFound"])
2464-
XCTAssert(result.didEncounterError)
2461+
XCTAssertFalse(result.didEncounterError, "The issues with this test bundle are not severe enough to fail the build.")
24652462
XCTAssert(engine.problems.contains(where: { $0.diagnostic.severity == .warning }))
24662463
}
24672464

@@ -2495,9 +2492,7 @@ class ConvertActionTests: XCTestCase {
24952492
temporaryDirectory: testDataProvider.uniqueTemporaryDirectory(),
24962493
diagnosticLevel: "error"
24972494
)
2498-
XCTAssertThrowsError(try action.performAndHandleResult(logHandle: .none)) { error in
2499-
XCTAssert(error is ErrorsEncountered, "Unexpected error type thrown by \(ConvertAction.self)")
2500-
}
2495+
XCTAssertNoThrow(try action.performAndHandleResult(logHandle: .none))
25012496
}
25022497

25032498
func testWritesDiagnosticFileWhenThrowingError() throws {
@@ -2537,9 +2532,7 @@ class ConvertActionTests: XCTestCase {
25372532

25382533
// TODO: Support TestFileSystem in DiagnosticFileWriter
25392534
XCTAssertFalse(FileManager.default.fileExists(atPath: diagnosticFile.path), "Diagnostic file doesn't exist before")
2540-
XCTAssertThrowsError(try action.performAndHandleResult(logHandle: .none)) { error in
2541-
XCTAssert(error is ErrorsEncountered, "Unexpected error type thrown by \(ConvertAction.self)")
2542-
}
2535+
XCTAssertNoThrow(try action.performAndHandleResult(logHandle: .none))
25432536
XCTAssertTrue(FileManager.default.fileExists(atPath: diagnosticFile.path), "Diagnostic file exist after")
25442537
}
25452538

@@ -2612,7 +2605,7 @@ class ConvertActionTests: XCTestCase {
26122605
temporaryDirectory: testDataProvider.uniqueTemporaryDirectory()
26132606
)
26142607

2615-
XCTAssertThrowsError(try action.performAndHandleResult(logHandle: .none), "The test bundle should have thrown an error about an incomplete symbol graph file")
2608+
XCTAssertNoThrow(try action.performAndHandleResult(logHandle: .none))
26162609
XCTAssert(testDataProvider.fileExists(atPath: digestFileURL.path), "The digest file should have been written even though compilation errors occurred")
26172610

26182611
let data = try testDataProvider.contentsOfURL(digestFileURL)

0 commit comments

Comments
 (0)