@@ -36,42 +36,6 @@ class ConvertActionTests: XCTestCase {
36
36
forResource: " TestBundle " , withExtension: " docc " , subdirectory: " Test Bundles " ) !
37
37
. appendingPathComponent ( " project.zip " )
38
38
39
- /// A symbol graph file that has missing symbols.
40
- let incompleteSymbolGraphFile = TextFile ( name: " TechnologyX.symbols.json " , utf8Content: """
41
- {
42
- " metadata " : {
43
- " formatVersion " : {
44
- " major " : 1
45
- },
46
- " generator " : " app/1.0 "
47
- },
48
- " module " : {
49
- " name " : " MyKit " ,
50
- " platform " : {
51
- " architecture " : " x86_64 " ,
52
- " vendor " : " apple " ,
53
- " operatingSystem " : {
54
- " name " : " ios " ,
55
- " minimumVersion " : {
56
- " major " : 13,
57
- " minor " : 0,
58
- " patch " : 0
59
- }
60
- }
61
- }
62
- },
63
- " symbols " : [],
64
- " relationships " : [
65
- {
66
- " source " : " s:5MyKit0A5ProtocolP " ,
67
- " target " : " s:5Foundation0A5EarhartP " ,
68
- " kind " : " conformsTo "
69
- }
70
- ]
71
- }
72
- """
73
- )
74
-
75
39
func testCopyingImageAssets( ) throws {
76
40
XCTAssert ( FileManager . default. fileExists ( atPath: imageFile. path) )
77
41
let testImageName = " TestImage.png "
@@ -667,7 +631,6 @@ class ConvertActionTests: XCTestCase {
667
631
expectedOutput. assertExist ( at: result. outputs [ 0 ] , fileManager: testDataProvider)
668
632
}
669
633
670
- /// Ensures that we always generate diagnosticJSON when there are errors. (rdar://72345373)
671
634
func testOutputFolderContainsDiagnosticJSONWhenThereAreErrorsAndNoTemplate( ) throws {
672
635
// Documentation bundle that contains an image
673
636
let bundle = Folder ( name: " unit-test.docc " , content: [
@@ -809,7 +772,6 @@ class ConvertActionTests: XCTestCase {
809
772
expectedOutput. assertExist ( at: result. outputs [ 0 ] , fileManager: testDataProvider)
810
773
}
811
774
812
- /// Ensures we never delete an existing build folder if conversion fails (rdar://72339050)
813
775
func testOutputFolderIsNotRemovedWhenThereAreErrors( ) throws {
814
776
let tutorialsFile = TextFile ( name: " TechnologyX.tutorial " , utf8Content: """
815
777
@Tutorials(name: " Technology Z " ) {
@@ -847,11 +809,6 @@ class ConvertActionTests: XCTestCase {
847
809
bundleInfoPlist,
848
810
] )
849
811
850
- let badBundle = Folder ( name: " unit-test.docc " , content: [
851
- incompleteSymbolGraphFile,
852
- bundleInfoPlist,
853
- ] )
854
-
855
812
let testDataProvider = try TestFileSystem ( folders: [ goodBundle, Folder . emptyHTMLTemplateDirectory] )
856
813
let targetDirectory = URL ( fileURLWithPath: testDataProvider. currentDirectoryPath)
857
814
. appendingPathComponent ( " target " , isDirectory: true )
@@ -883,76 +840,6 @@ class ConvertActionTests: XCTestCase {
883
840
] )
884
841
expectedOutput. assertExist ( at: targetDirectory, fileManager: testDataProvider)
885
842
}
886
-
887
- try testDataProvider. updateDocumentationBundles ( withFolders: [ badBundle] )
888
-
889
- do {
890
- var action = try ConvertAction (
891
- documentationBundleURL: badBundle. absoluteURL,
892
- outOfProcessResolver: nil ,
893
- analyze: false ,
894
- targetDirectory: targetDirectory,
895
- htmlTemplateDirectory: Folder . emptyHTMLTemplateDirectory. absoluteURL,
896
- emitDigest: false ,
897
- currentPlatforms: nil ,
898
- dataProvider: testDataProvider,
899
- fileManager: testDataProvider,
900
- temporaryDirectory: testDataProvider. uniqueTemporaryDirectory ( ) )
901
- let result = try action. perform ( logHandle: . none)
902
-
903
- XCTAssert (
904
- result. didEncounterError,
905
- " We expect errors to occur during during conversion of the bad test bundle. "
906
- )
907
-
908
- // Verify that the build output folder from the former successful conversion
909
- // still exists after this failure.
910
- let expectedOutput = Folder ( name: " .docc-build " , content: [
911
- Folder ( name: " data " , content: [
912
- ] ) ,
913
- ] )
914
- expectedOutput. assertExist ( at: targetDirectory, fileManager: testDataProvider)
915
- }
916
- }
917
-
918
- func testOutputFolderContainsDiagnosticJSONWhenThereAreErrors( ) throws {
919
- // Documentation bundle that contains an image
920
- let bundle = Folder ( name: " unit-test.docc " , content: [
921
- incompleteSymbolGraphFile,
922
- InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " ) ,
923
- ] )
924
-
925
- let testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
926
- let targetDirectory = URL ( fileURLWithPath: testDataProvider. currentDirectoryPath)
927
- . appendingPathComponent ( " target " , isDirectory: true )
928
-
929
- var action = try ConvertAction (
930
- documentationBundleURL: bundle. absoluteURL,
931
- outOfProcessResolver: nil ,
932
- analyze: false ,
933
- targetDirectory: targetDirectory,
934
- htmlTemplateDirectory: Folder . emptyHTMLTemplateDirectory. absoluteURL,
935
- emitDigest: true ,
936
- currentPlatforms: nil ,
937
- dataProvider: testDataProvider,
938
- fileManager: testDataProvider,
939
- temporaryDirectory: testDataProvider. uniqueTemporaryDirectory ( ) )
940
- let result = try action. perform ( logHandle: . none)
941
-
942
- // Verify that the following files and folder exist at the output location
943
- let expectedOutput = Folder ( name: " .docc-build " , content: [
944
- JSONFile ( name: " diagnostics.json " , content: [
945
- Digest . Diagnostic (
946
- start: nil ,
947
- source: nil ,
948
- severity: . error,
949
- summary: " Symbol with identifier 's:5MyKit0A5ProtocolP' couldn't be found " ,
950
- explanation: nil ,
951
- notes: [ ]
952
- ) ,
953
- ] ) ,
954
- ] )
955
- expectedOutput. assertExist ( at: result. outputs [ 0 ] , fileManager: testDataProvider)
956
843
}
957
844
958
845
/// Verifies that digest is correctly emitted for API documentation topics
@@ -1274,7 +1161,7 @@ class ConvertActionTests: XCTestCase {
1274
1161
] )
1275
1162
}
1276
1163
1277
- func testDownloadMetadataIsWritenToOutputFolder ( ) throws {
1164
+ func testDownloadMetadataIsWrittenToOutputFolder ( ) throws {
1278
1165
let bundle = Folder ( name: " unit-test.docc " , content: [
1279
1166
CopyOfFile ( original: projectZipFile) ,
1280
1167
CopyOfFile ( original: imageFile, newName: " referenced-tutorials-image.png " ) ,
@@ -2387,7 +2274,6 @@ class ConvertActionTests: XCTestCase {
2387
2274
This article has a malformed title and can't be analyzed, so it
2388
2275
produces one warning.
2389
2276
""" ) ,
2390
- incompleteSymbolGraphFile,
2391
2277
] )
2392
2278
2393
2279
let testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
@@ -2411,8 +2297,8 @@ class ConvertActionTests: XCTestCase {
2411
2297
)
2412
2298
let result = try action. perform ( logHandle: . none)
2413
2299
2414
- XCTAssertEqual ( engine. problems. count, 1 , " \( ConvertAction . self) didn't filter out diagnostics above the 'error' level. " )
2415
- XCTAssert ( result. didEncounterError)
2300
+ XCTAssertEqual ( engine. problems. count, 0 , " \( ConvertAction . self) didn't filter out diagnostics at-or- above the 'error' level. " )
2301
+ XCTAssertFalse ( result. didEncounterError, " The issues with this test bundle are not severe enough to fail the build. " )
2416
2302
}
2417
2303
2418
2304
func testDiagnosticLevelIgnoredWhenAnalyzeIsPresent( ) throws {
@@ -2425,7 +2311,6 @@ class ConvertActionTests: XCTestCase {
2425
2311
This article has a malformed title and can't be analyzed, so it
2426
2312
produces one warning.
2427
2313
""" ) ,
2428
- incompleteSymbolGraphFile,
2429
2314
] )
2430
2315
2431
2316
let testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
@@ -2449,9 +2334,9 @@ class ConvertActionTests: XCTestCase {
2449
2334
)
2450
2335
let result = try action. perform ( logHandle: . none)
2451
2336
2452
- XCTAssertEqual ( engine. problems. count, 2 , " \( ConvertAction . self) shouldn't filter out diagnostics when the '--analyze' flag is passed " )
2453
- XCTAssertEqual ( engine. problems. map { $0. diagnostic. identifier } , [ " org.swift.docc.Article.Title.NotFound " , " org.swift.docc.SymbolNodeNotFound " ] )
2454
- XCTAssert ( result. didEncounterError)
2337
+ XCTAssertEqual ( engine. problems. count, 1 , " \( ConvertAction . self) shouldn't filter out diagnostics when the '--analyze' flag is passed " )
2338
+ XCTAssertEqual ( engine. problems. map { $0. diagnostic. identifier } , [ " org.swift.docc.Article.Title.NotFound " ] )
2339
+ XCTAssertFalse ( result. didEncounterError, " The issues with this test bundle are not severe enough to fail the build. " )
2455
2340
XCTAssert ( engine. problems. contains ( where: { $0. diagnostic. severity == . warning } ) )
2456
2341
}
2457
2342
@@ -2465,7 +2350,6 @@ class ConvertActionTests: XCTestCase {
2465
2350
This article has a malformed title and can't be analyzed, so it
2466
2351
produces one warning.
2467
2352
""" ) ,
2468
- incompleteSymbolGraphFile,
2469
2353
] )
2470
2354
2471
2355
let testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
@@ -2485,9 +2369,7 @@ class ConvertActionTests: XCTestCase {
2485
2369
temporaryDirectory: testDataProvider. uniqueTemporaryDirectory ( ) ,
2486
2370
diagnosticLevel: " error "
2487
2371
)
2488
- XCTAssertThrowsError ( try action. performAndHandleResult ( logHandle: . none) ) { error in
2489
- XCTAssert ( error is ErrorsEncountered , " Unexpected error type thrown by \( ConvertAction . self) " )
2490
- }
2372
+ XCTAssertNoThrow ( try action. performAndHandleResult ( logHandle: . none) )
2491
2373
}
2492
2374
2493
2375
func testWritesDiagnosticFileWhenThrowingError( ) throws {
@@ -2500,7 +2382,6 @@ class ConvertActionTests: XCTestCase {
2500
2382
This article has a malformed title and can't be analyzed, so it
2501
2383
produces one warning.
2502
2384
""" ) ,
2503
- incompleteSymbolGraphFile,
2504
2385
] )
2505
2386
2506
2387
let testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
@@ -2527,9 +2408,7 @@ class ConvertActionTests: XCTestCase {
2527
2408
2528
2409
// TODO: Support TestFileSystem in DiagnosticFileWriter
2529
2410
XCTAssertFalse ( FileManager . default. fileExists ( atPath: diagnosticFile. path) , " Diagnostic file doesn't exist before " )
2530
- XCTAssertThrowsError ( try action. performAndHandleResult ( logHandle: . none) ) { error in
2531
- XCTAssert ( error is ErrorsEncountered , " Unexpected error type thrown by \( ConvertAction . self) " )
2532
- }
2411
+ XCTAssertNoThrow ( try action. performAndHandleResult ( logHandle: . none) )
2533
2412
XCTAssertTrue ( FileManager . default. fileExists ( atPath: diagnosticFile. path) , " Diagnostic file exist after " )
2534
2413
}
2535
2414
@@ -2580,7 +2459,6 @@ class ConvertActionTests: XCTestCase {
2580
2459
let bundle = Folder ( name: " unit-test.docc " , content: [
2581
2460
InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " ) ,
2582
2461
CopyOfFile ( original: symbolGraphFile, newName: " MyKit.symbols.json " ) ,
2583
- incompleteSymbolGraphFile,
2584
2462
] )
2585
2463
2586
2464
let testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
@@ -2602,13 +2480,12 @@ class ConvertActionTests: XCTestCase {
2602
2480
temporaryDirectory: testDataProvider. uniqueTemporaryDirectory ( )
2603
2481
)
2604
2482
2605
- XCTAssertThrowsError ( try action. performAndHandleResult ( logHandle: . none) , " The test bundle should have thrown an error about an incomplete symbol graph file " )
2606
- XCTAssert ( testDataProvider. fileExists ( atPath: digestFileURL. path) , " The digest file should have been written even though compilation errors occurred " )
2483
+ XCTAssertNoThrow ( try action. performAndHandleResult ( logHandle: . none) )
2484
+ XCTAssert ( testDataProvider. fileExists ( atPath: digestFileURL. path) )
2607
2485
2608
2486
let data = try testDataProvider. contentsOfURL ( digestFileURL)
2609
2487
let diagnostics = try RenderJSONDecoder . makeDecoder ( ) . decode ( [ Digest . Diagnostic ] . self, from: data)
2610
- XCTAssertEqual ( diagnostics. count, 1 )
2611
-
2488
+ XCTAssertEqual ( diagnostics. count, 0 )
2612
2489
}
2613
2490
2614
2491
func testRenderIndexJSONGeneration( ) throws {
0 commit comments