@@ -3071,36 +3071,35 @@ class ConvertActionTests: XCTestCase {
3071
3071
3072
3072
// Tests that when converting a catalog with no technology root a warning is raised (r93371988)
3073
3073
func testConvertWithNoTechnologyRoot( ) throws {
3074
- func convert( _ bundle: Folder ) throws -> ConvertAction {
3075
- return try ConvertAction (
3076
- documentationBundleURL: bundle. absoluteURL,
3074
+ func problemsFromConverting( _ catalogContent: [ File ] ) throws -> [ Problem ] {
3075
+ let catalog = Folder ( name: " unit-test.docc " , content: catalogContent)
3076
+ let testDataProvider = try TestFileSystem ( folders: [ catalog, Folder . emptyHTMLTemplateDirectory] )
3077
+ let engine = DiagnosticEngine ( )
3078
+ var action = try ConvertAction (
3079
+ documentationBundleURL: catalog. absoluteURL,
3077
3080
outOfProcessResolver: nil ,
3078
- analyze: true ,
3079
- targetDirectory: targetDirectory ,
3081
+ analyze: false ,
3082
+ targetDirectory: URL ( fileURLWithPath : " /output " ) ,
3080
3083
htmlTemplateDirectory: Folder . emptyHTMLTemplateDirectory. absoluteURL,
3081
3084
emitDigest: false ,
3082
3085
currentPlatforms: nil ,
3083
3086
dataProvider: testDataProvider,
3084
3087
fileManager: testDataProvider,
3085
- temporaryDirectory: createTemporaryDirectory ( ) ,
3088
+ temporaryDirectory: URL ( fileURLWithPath : " /tmp " ) ,
3086
3089
diagnosticEngine: engine
3087
3090
)
3091
+ _ = try action. perform ( logHandle: . none)
3092
+ return engine. problems
3088
3093
}
3089
- var bundle = Folder ( name: " unit-test.docc " , content: [
3094
+
3095
+
3096
+ let TutorialArticleWithNoContentProblems = try problemsFromConverting ( [
3090
3097
InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " ) ,
3091
- TextFile ( name: " Documentation.md " , utf8Content: " " )
3098
+ TextFile ( name: " Article.tutorial " , utf8Content: " " )
3092
3099
] )
3093
- var testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
3094
- var targetDirectory = URL ( fileURLWithPath: testDataProvider. currentDirectoryPath)
3095
- . appendingPathComponent ( " target " , isDirectory: true )
3096
- var engine = DiagnosticEngine ( )
3097
- var action = try convert ( bundle)
3098
- let _ = try action. perform ( logHandle: . standardOutput)
3099
- XCTAssertEqual ( engine. problems. count, 1 )
3100
- XCTAssertEqual ( engine. problems. map { $0. diagnostic. identifier } , [ " org.swift.docc.MissingTechnologyRoot " ] )
3101
- XCTAssert ( engine. problems. contains ( where: { $0. diagnostic. severity == . warning } ) )
3100
+ XCTAssert ( TutorialArticleWithNoContentProblems . contains ( where: { $0. diagnostic. identifier == " org.swift.docc.MissingTechnologyRoot " } ) )
3102
3101
3103
- bundle = Folder ( name : " unit-test.docc " , content : [
3102
+ let onlyTutorialArticleProblems = try problemsFromConverting ( [
3104
3103
InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " ) ,
3105
3104
TextFile ( name: " Article.tutorial " , utf8Content: """
3106
3105
@Article(time: 20) {
@@ -3111,31 +3110,17 @@ class ConvertActionTests: XCTestCase {
3111
3110
"""
3112
3111
) ,
3113
3112
] )
3114
- testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
3115
- targetDirectory = URL ( fileURLWithPath: testDataProvider. currentDirectoryPath)
3116
- . appendingPathComponent ( " target " , isDirectory: true )
3117
- engine = DiagnosticEngine ( )
3118
- action = try convert ( bundle)
3119
- _ = try action. perform ( logHandle: . standardOutput)
3120
- XCTAssert ( engine. problems. contains ( where: { $0. diagnostic. identifier == " org.swift.docc.MissingTechnologyRoot " } ) )
3113
+ XCTAssert ( onlyTutorialArticleProblems. contains ( where: { $0. diagnostic. identifier == " org.swift.docc.MissingTechnologyRoot " } ) )
3121
3114
3122
- bundle = Folder ( name : " unit-test.docc " , content : [
3115
+ let tutorialTableOfContentProblem = try problemsFromConverting ( [
3123
3116
InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " ) ,
3124
3117
TextFile ( name: " table-of-contents.tutorial " , utf8Content: """
3125
3118
@Tutorials(name: " Tutorial " ) {
3126
- @Intro(title: " Tutorial Introduction " ) {
3127
- }
3128
3119
}
3129
3120
"""
3130
3121
) ,
3131
3122
] )
3132
- testDataProvider = try TestFileSystem ( folders: [ bundle, Folder . emptyHTMLTemplateDirectory] )
3133
- targetDirectory = URL ( fileURLWithPath: testDataProvider. currentDirectoryPath)
3134
- . appendingPathComponent ( " target " , isDirectory: true )
3135
- engine = DiagnosticEngine ( )
3136
- action = try convert ( bundle)
3137
- _ = try action. perform ( logHandle: . standardOutput)
3138
- XCTAssertFalse ( engine. problems. contains ( where: { $0. diagnostic. identifier == " org.swift.docc.MissingTechnologyRoot " } ) )
3123
+ XCTAssert ( tutorialTableOfContentProblem. contains ( where: { $0. diagnostic. identifier == " org.swift.docc.MissingTechnologyRoot " } ) )
3139
3124
}
3140
3125
3141
3126
func testWrittenDiagnosticsAfterConvert( ) throws {
0 commit comments