@@ -2,6 +2,47 @@ import class Foundation.Bundle
22import XCTest
33
44final class GenerateSubcommandTests : XCTestCase {
5+ func testCommonMark( ) throws {
6+ let command = Bundle . productsDirectory. appendingPathComponent ( " swift-doc " )
7+ let outputDirectory = try temporaryDirectory ( )
8+
9+ defer { try ? FileManager . default. removeItem ( at: outputDirectory) }
10+ try Process . run ( command: command,
11+ arguments: [
12+ " generate " ,
13+ " --module-name " , " SwiftDoc " ,
14+ " --format " , " commonmark " ,
15+ " --output " , outputDirectory. path,
16+ " Sources "
17+ ]
18+ ) { result in
19+ XCTAssertEqual ( result. terminationStatus, EXIT_SUCCESS)
20+ XCTAssertEqual ( result. output, " " )
21+ XCTAssertEqual ( result. error, " " )
22+
23+ do {
24+ let commonmark = try String ( contentsOf: outputDirectory. appendingPathComponent ( " Home.md " ) )
25+ XCTAssertTrue ( commonmark. contains ( " # Types " ) )
26+ }
27+
28+ do {
29+ let commonmark = try String ( contentsOf: outputDirectory. appendingPathComponent ( " _Sidebar.md " ) )
30+ XCTAssertTrue ( commonmark. contains ( " <summary>Types</summary> " ) )
31+ }
32+
33+ do {
34+ let commonmark = try String ( contentsOf: outputDirectory. appendingPathComponent ( " _Footer.md " ) )
35+ XCTAssertTrue ( commonmark. contains ( " [swift-doc](https://github.com/SwiftDocOrg/swift-doc) " ) )
36+ }
37+
38+ do {
39+ let contents = try FileManager . default. contentsOfDirectory ( at: outputDirectory, includingPropertiesForKeys: [ . isDirectoryKey] , options: [ . skipsHiddenFiles] )
40+ let subdirectories = contents. filter { $0. hasDirectoryPath }
41+ XCTAssertEqual ( subdirectories. count, 0 , " output should not contain any subdirectories " )
42+ }
43+ }
44+ }
45+
546 func testHTML( ) throws {
647 let command = Bundle . productsDirectory. appendingPathComponent ( " swift-doc " )
748 let outputDirectory = try temporaryDirectory ( )
0 commit comments