@@ -2323,6 +2323,47 @@ class ConvertActionTests: XCTestCase {
2323
2323
XCTAssert ( error is ErrorsEncountered , " Unexpected error type thrown by \( ConvertAction . self) " )
2324
2324
}
2325
2325
}
2326
+
2327
+ func testWritesDiagnosticFileWhenThrowingError( ) throws {
2328
+ let bundle = Folder ( name: " unit-test.docc " , content: [
2329
+ InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " ) ,
2330
+ CopyOfFile ( original: symbolGraphFile, newName: " MyKit.symbols.json " ) ,
2331
+ TextFile ( name: " Article.md " , utf8Content: """
2332
+ Bad title
2333
+
2334
+ This article has a malformed title and can't be analyzed, so it
2335
+ produces one warning.
2336
+ """ ) ,
2337
+ incompleteSymbolGraphFile,
2338
+ ] )
2339
+
2340
+ let testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
2341
+ let targetDirectory = URL ( fileURLWithPath: testDataProvider. currentDirectoryPath)
2342
+ . appendingPathComponent ( " target " , isDirectory: true )
2343
+
2344
+ let diagnosticFile = try createTemporaryDirectory ( ) . appendingPathComponent ( " test-diagnostics.json " )
2345
+
2346
+ var action = try ConvertAction (
2347
+ documentationBundleURL: bundle. absoluteURL,
2348
+ outOfProcessResolver: nil ,
2349
+ analyze: true ,
2350
+ targetDirectory: targetDirectory,
2351
+ htmlTemplateDirectory: Folder . emptyHTMLTemplateDirectory. absoluteURL,
2352
+ emitDigest: false ,
2353
+ currentPlatforms: nil ,
2354
+ dataProvider: testDataProvider,
2355
+ fileManager: testDataProvider,
2356
+ temporaryDirectory: createTemporaryDirectory ( ) ,
2357
+ diagnosticLevel: " error " ,
2358
+ diagnosticFilePath: diagnosticFile
2359
+ )
2360
+
2361
+ XCTAssertFalse ( FileManager . default. fileExists ( atPath: diagnosticFile. path) , " Diagnostic file doesn't exist before " )
2362
+ XCTAssertThrowsError ( try action. performAndHandleResult ( ) ) { error in
2363
+ XCTAssert ( error is ErrorsEncountered , " Unexpected error type thrown by \( ConvertAction . self) " )
2364
+ }
2365
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: diagnosticFile. path) , " Diagnostic file exist after " )
2366
+ }
2326
2367
2327
2368
// Verifies setting convert inherit docs flag
2328
2369
func testConvertInheritDocsOption( ) throws {
0 commit comments