@@ -12,6 +12,7 @@ import XCTest
12
12
import Foundation
13
13
@testable import SwiftDocC
14
14
@testable import SwiftDocCUtilities
15
+ import SymbolKit
15
16
import Markdown
16
17
import SwiftDocCTestUtilities
17
18
@@ -2361,7 +2362,75 @@ class ConvertActionTests: XCTestCase {
2361
2362
var action = try ConvertAction ( fromConvertCommand: convertCommand)
2362
2363
_ = try action. perform ( logHandle: . none)
2363
2364
}
2365
+
2366
+ func emitEmptySymbolGraph( moduleName: String , destination: URL ) throws {
2367
+ let symbolGraph = SymbolGraph (
2368
+ metadata: . init(
2369
+ formatVersion: . init( major: 0 , minor: 0 , patch: 1 ) ,
2370
+ generator: " unit-test "
2371
+ ) ,
2372
+ module: . init(
2373
+ name: moduleName,
2374
+ platform: . init( )
2375
+ ) ,
2376
+ symbols: [ ] ,
2377
+ relationships: [ ]
2378
+ )
2379
+
2380
+ // Create a unique subfolder to place the symbol graph in
2381
+ // in case we're emitting multiple symbol graphs with the same filename.
2382
+ let uniqueSubfolder = destination. appendingPathComponent (
2383
+ ProcessInfo . processInfo. globallyUniqueString
2384
+ )
2385
+ try FileManager . default. createDirectory (
2386
+ at: uniqueSubfolder,
2387
+ withIntermediateDirectories: false
2388
+ )
2389
+
2390
+ try JSONEncoder ( ) . encode ( symbolGraph) . write (
2391
+ to: uniqueSubfolder
2392
+ . appendingPathComponent ( moduleName, isDirectory: false )
2393
+ . appendingPathExtension ( " symbols.json " )
2394
+ )
2395
+ }
2364
2396
2397
+ // Tests that when `docc convert` is given input that produces multiple pages at the same path
2398
+ // on disk it does not throw an error when attempting to transform it for static hosting. (94311195)
2399
+ func testConvertDocCCatalogThatProducesMultipleDocumentationPagesAtTheSamePathDoesNotThrowError( ) throws {
2400
+ let temporaryDirectory = try createTemporaryDirectory ( )
2401
+
2402
+ let catalogURL = try Folder (
2403
+ name: " unit-test.docc " ,
2404
+ content: [
2405
+ InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " ) ,
2406
+ ]
2407
+ ) . write ( inside: temporaryDirectory)
2408
+ try emitEmptySymbolGraph ( moduleName: " docc " , destination: catalogURL)
2409
+ try emitEmptySymbolGraph ( moduleName: " DocC " , destination: catalogURL)
2410
+
2411
+ let htmlTemplateDirectory = try Folder . emptyHTMLTemplateDirectory. write (
2412
+ inside: temporaryDirectory
2413
+ )
2414
+
2415
+ let targetDirectory = temporaryDirectory. appendingPathComponent ( " target.doccarchive " , isDirectory: true )
2416
+ let dataProvider = try LocalFileSystemDataProvider ( rootURL: catalogURL)
2417
+
2418
+ var action = try ConvertAction (
2419
+ documentationBundleURL: catalogURL,
2420
+ outOfProcessResolver: nil ,
2421
+ analyze: false ,
2422
+ targetDirectory: targetDirectory,
2423
+ htmlTemplateDirectory: htmlTemplateDirectory,
2424
+ emitDigest: false ,
2425
+ currentPlatforms: nil ,
2426
+ dataProvider: dataProvider,
2427
+ fileManager: FileManager . default,
2428
+ temporaryDirectory: createTemporaryDirectory ( ) ,
2429
+ transformForStaticHosting: true
2430
+ )
2431
+
2432
+ XCTAssertNoThrow ( try action. performAndHandleResult ( ) )
2433
+ }
2365
2434
func testConvertWithCustomTemplates( ) throws {
2366
2435
let info = InfoPlist ( displayName: " TestConvertWithCustomTemplates " , identifier: " com.test.example " )
2367
2436
let index = TextFile ( name: " index.html " , utf8Content: """
0 commit comments