@@ -173,34 +173,28 @@ class DocumentationContext_RootPageTests: XCTestCase {
173
173
//Multiple Root Warnings Tests
174
174
175
175
func testMultipleSymbolGraphModulesWarning( ) throws {
176
- //created a test bundle with two symbol graph files for different modules
177
176
let tempURL = try createTemporaryDirectory ( )
178
177
let bundleURL = tempURL. appendingPathComponent ( " test.docc " )
179
178
try FileManager . default. createDirectory ( at: bundleURL, withIntermediateDirectories: true )
180
179
181
- //created two symbol graph files for different modules
182
180
let module1GraphURL = bundleURL. appendingPathComponent ( " Module1.symbols.json " )
183
181
let module2GraphURL = bundleURL. appendingPathComponent ( " Module2.symbols.json " )
184
182
185
- // Symbol graph content for Module1
186
183
let module1Graph = makeSymbolGraph (
187
184
moduleName: " Module1 " ,
188
185
symbols: [ ] ,
189
186
relationships: [ ]
190
187
)
191
188
192
- //symbol graph content for Module2
193
189
let module2Graph = makeSymbolGraph (
194
190
moduleName: " Module2 " ,
195
191
symbols: [ ] ,
196
192
relationships: [ ]
197
193
)
198
194
199
- //symbol graphs to files
200
195
try JSONEncoder ( ) . encode ( module1Graph) . write ( to: module1GraphURL)
201
196
try JSONEncoder ( ) . encode ( module2Graph) . write ( to: module2GraphURL)
202
197
203
- //created the Info.plist file
204
198
let infoPlistURL = bundleURL. appendingPathComponent ( " Info.plist " )
205
199
let infoPlist = """
206
200
<?xml version= " 1.0 " encoding= " UTF-8 " ?>
@@ -218,17 +212,19 @@ class DocumentationContext_RootPageTests: XCTestCase {
218
212
"""
219
213
try infoPlist. write ( to: infoPlistURL, atomically: true , encoding: . utf8)
220
214
221
- //bundle
222
215
let ( _, _, context) = try loadBundle ( from: bundleURL)
223
216
224
- //checks for the warning about multiple symbol graph modules
225
217
let multipleModuleWarning = context. problems. first {
226
- $0. diagnostic. identifier == " org.swift.docc.MultipleSymbolGraphRoots "
218
+ $0. diagnostic. identifier == " org.swift.docc.MultipleRootModules "
227
219
}
228
220
XCTAssertNotNil ( multipleModuleWarning, " Should emit warning about multiple symbol graph modules " )
229
- XCTAssertEqual ( multipleModuleWarning? . diagnostic. summary, " Documentation has multiple symbol graph modules as root pages " )
230
- XCTAssertTrue ( multipleModuleWarning? . diagnostic. explanation? . contains ( " Module1 " ) ?? false )
231
- XCTAssertTrue ( multipleModuleWarning? . diagnostic. explanation? . contains ( " Module2 " ) ?? false )
221
+
222
+ // Check that both module names are present in the warning message, regardless of order
223
+ let warningMessage = multipleModuleWarning? . diagnostic. summary ?? " "
224
+ XCTAssertTrue ( warningMessage. contains ( " Module1 " ) && warningMessage. contains ( " Module2 " ) ,
225
+ " Warning should mention both modules " )
226
+ XCTAssertTrue ( warningMessage. contains ( " Documentation contains symbol graphs for multiple main modules " ) ,
227
+ " Warning should have correct summary " )
232
228
}
233
229
234
230
func testMixedRootTypesWarning( ) throws {
@@ -362,7 +358,6 @@ class DocumentationContext_RootPageTests: XCTestCase {
362
358
func testMultipleRootPagesWarning( ) throws {
363
359
let ( _, context) = try loadBundle ( catalog:
364
360
Folder ( name: " test.docc " , content: [
365
- // First root page
366
361
TextFile ( name: " FirstRoot.md " , utf8Content: """
367
362
# First Root
368
363
@Metadata {
@@ -371,7 +366,6 @@ class DocumentationContext_RootPageTests: XCTestCase {
371
366
First root page.
372
367
""" ) ,
373
368
374
- // Second root page
375
369
TextFile ( name: " SecondRoot.md " , utf8Content: """
376
370
# Second Root
377
371
@Metadata {
@@ -380,7 +374,6 @@ class DocumentationContext_RootPageTests: XCTestCase {
380
374
Second root page.
381
375
""" ) ,
382
376
383
- // Third root page
384
377
TextFile ( name: " ThirdRoot.md " , utf8Content: """
385
378
# Third Root
386
379
@Metadata {
@@ -419,29 +412,24 @@ class DocumentationContext_RootPageTests: XCTestCase {
419
412
let bundleURL = tempURL. appendingPathComponent ( " test.docc " )
420
413
try FileManager . default. createDirectory ( at: bundleURL, withIntermediateDirectories: true )
421
414
422
- // Create two symbol graph files for different modules
423
415
let module1GraphURL = bundleURL. appendingPathComponent ( " Module1.symbols.json " )
424
416
let module2GraphURL = bundleURL. appendingPathComponent ( " Module2.symbols.json " )
425
417
426
- // Symbol graph content for Module1
427
418
let module1Graph = makeSymbolGraph (
428
419
moduleName: " Module1 " ,
429
420
symbols: [ ] ,
430
421
relationships: [ ]
431
422
)
432
423
433
- // Symbol graph content for Module2
434
424
let module2Graph = makeSymbolGraph (
435
425
moduleName: " Module2 " ,
436
426
symbols: [ ] ,
437
427
relationships: [ ]
438
428
)
439
429
440
- // Write symbol graphs to files
441
430
try JSONEncoder ( ) . encode ( module1Graph) . write ( to: module1GraphURL)
442
431
try JSONEncoder ( ) . encode ( module2Graph) . write ( to: module2GraphURL)
443
432
444
- // Create the Info.plist file
445
433
let infoPlistURL = bundleURL. appendingPathComponent ( " Info.plist " )
446
434
let infoPlist = """
447
435
<?xml version= " 1.0 " encoding= " UTF-8 " ?>
@@ -459,16 +447,19 @@ class DocumentationContext_RootPageTests: XCTestCase {
459
447
"""
460
448
try infoPlist. write ( to: infoPlistURL, atomically: true , encoding: . utf8)
461
449
462
- // Load the bundle
463
450
let ( _, _, context) = try loadBundle ( from: bundleURL)
464
451
465
- // Check for the warning about multiple root modules
466
452
let multipleRootModulesWarnings = context. problems. filter {
467
453
$0. diagnostic. identifier == " org.swift.docc.MultipleRootModules "
468
454
}
469
455
470
456
XCTAssertEqual ( multipleRootModulesWarnings. count, 1 )
471
- XCTAssertEqual ( multipleRootModulesWarnings [ 0 ] . diagnostic. summary, " Documentation contains symbol graphs for multiple main modules: Module1, Module2 " )
457
+ // Check that both module names are present in the warning message, regardless of order
458
+ let warningMessage = multipleRootModulesWarnings [ 0 ] . diagnostic. summary
459
+ XCTAssertTrue ( warningMessage. contains ( " Module1 " ) && warningMessage. contains ( " Module2 " ) ,
460
+ " Warning should mention both modules " )
461
+ XCTAssertTrue ( warningMessage. contains ( " Documentation contains symbol graphs for multiple main modules " ) ,
462
+ " Warning should have correct summary prefix " )
472
463
XCTAssertEqual ( multipleRootModulesWarnings [ 0 ] . diagnostic. explanation, " Having multiple root modules may lead to unexpected behavior when using DocC. " )
473
464
}
474
465
}
0 commit comments