From 5aa2c451d22639dc818889db3b8c632f799a2f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Thu, 5 Dec 2024 10:43:32 +0100 Subject: [PATCH] Discourage using unrealistic catalog inputs in tests (#1106) * Discourage future use of the "TestBundle" by renaming it. This example catalog contains significant handcrafted data that doesn't reflect realistic inputs. * Update tests that don't need a catalog input to use an empty context. * Update `SymbolGraphRelationshipsBuilderTests` to not load any catalog * Update name of test specifically about the unrealistic test catalog * Create minimal catalog for final remaining `ChoiceTests` test case * Create minimal catalog for final remaining `VolumeTests` test case * Avoid referencing an input catalog for image size test * Create minimal catalog for `NonInclusiveLanguageCheckerTests` * Create minimal catalog for `DiagnosticTests` * Create minimal catalogs for some `DocumentationContextTests` * Update more tests that don't need a catalog input to use an empty context. * Create minimal catalogs for more `DocumentationContextTests` * Create minimal catalogs for some `VideoMediaTests` * Create minimal catalogs for two `SemaToRenderNodeTests` * Create minimal catalogs for a few more `DocumentationContextTests` * Load test catalogs from in-memory file system in many more tests * Rename legacy test bundle again * Resolve some warnings in tests about using `var` for unmutated action --- .../Benchmark/ExternalTopicsHashTests.swift | 8 +- .../Benchmark/TopicGraphHashTests.swift | 6 +- .../NonInclusiveLanguageCheckerTests.swift | 23 +- .../DocumentationContextConverterTests.swift | 6 +- .../Converter/RenderContextTests.swift | 2 +- .../TopicRenderReferenceEncoderTests.swift | 4 +- ...icConsoleWriterDefaultFormattingTest.swift | 4 +- .../Diagnostics/DiagnosticTests.swift | 7 +- .../ConvertService/ConvertServiceTests.swift | 10 +- .../Indexing/IndexingTests.swift | 8 +- .../Indexing/NavigatorIndexTests.swift | 21 +- .../Indexing/RenderIndexTests.swift | 2 +- .../AutoCapitalizationTests.swift | 24 +- .../AutomaticCurationTests.swift | 24 +- .../Infrastructure/BundleDiscoveryTests.swift | 4 +- .../DataAssetManagerTests.swift | 6 +- .../DocumentationBundleInfoTests.swift | 2 +- .../DocumentationBundleTests.swift | 2 +- .../DocumentationContextTests.swift | 619 +++++++++--------- .../DocumentationCuratorTests.swift | 10 +- .../ExternalReferenceResolverTests.swift | 50 +- .../InheritIntroducedAvailabilityTests.swift | 2 +- .../Infrastructure/PathHierarchyTests.swift | 49 +- .../PresentationURLGeneratorTests.swift | 2 +- .../ReferenceResolverTests.swift | 26 +- .../AbsoluteSymbolLinkTests.swift | 2 +- .../SymbolGraph/SymbolGraphLoaderTests.swift | 6 +- ...SymbolGraphRelationshipsBuilderTests.swift | 36 +- .../LinkDestinationSummaryTests.swift | 4 +- .../ParametersAndReturnValidatorTests.swift | 49 +- .../Model/RenderContentMetadataTests.swift | 14 +- .../RenderHierarchyTranslatorTests.swift | 4 +- .../Model/RenderNodeDiffingBundleTests.swift | 2 +- .../Model/RenderNodeSerializationTests.swift | 8 +- .../Model/SemaToRenderNodeTests.swift | 175 ++--- .../Rendering/AutomaticSeeAlsoTests.swift | 10 +- .../AvailabilityRenderOrderTests.swift | 2 +- .../ConstraintsRenderSectionTests.swift | 16 +- .../DeclarationsRenderSectionTests.swift | 30 +- .../Rendering/DefaultAvailabilityTests.swift | 8 +- .../DefaultCodeListingSyntaxTests.swift | 2 +- .../Rendering/DeprecationSummaryTests.swift | 4 +- .../Rendering/ExternalLinkTitleTests.swift | 2 +- .../Rendering/HeadingAnchorTests.swift | 6 +- .../Rendering/LinkTitleResolverTests.swift | 2 +- ...ropertyListDetailsRenderSectionTests.swift | 8 +- .../Rendering/RESTSymbolsTests.swift | 4 +- .../RenderContentCompilerTests.swift | 4 +- .../Rendering/RenderMetadataTests.swift | 6 +- ...derNodeTranslatorSymbolVariantsTests.swift | 4 +- .../Rendering/RenderNodeTranslatorTests.swift | 32 +- .../SwiftDocCTests/Rendering/RoleTests.swift | 6 +- .../Rendering/TermListTests.swift | 13 +- .../Semantics/ArticleTests.swift | 16 +- .../Semantics/AssessmentsTests.swift | 2 +- .../Semantics/ChapterTests.swift | 8 +- .../Semantics/ChoiceTests.swift | 20 +- .../SwiftDocCTests/Semantics/CodeTests.swift | 2 +- .../Semantics/ContentAndMediaTests.swift | 10 +- .../Semantics/DisplayNameTests.swift | 16 +- .../DocumentationExtensionTests.swift | 16 +- .../Semantics/DoxygenTests.swift | 5 +- .../HasAtLeastOneTests.swift | 8 +- .../HasAtMostOneTests.swift | 8 +- .../HasContentTests.swift | 4 +- .../HasExactlyOneTests.swift | 8 +- .../HasOnlyKnownArgumentsTests.swift | 8 +- .../HasOnlyKnownDirectivesTests.swift | 10 +- .../HasOnlySequentialHeadingsTests.swift | 8 +- .../Semantics/ImageMediaTests.swift | 12 +- .../SwiftDocCTests/Semantics/IntroTests.swift | 6 +- .../Semantics/JustificationTests.swift | 4 +- .../MarkupReferenceResolverTests.swift | 2 +- .../Semantics/MetadataTests.swift | 32 +- .../Semantics/MultipleChoiceTests.swift | 12 +- .../Semantics/RedirectedTests.swift | 28 +- .../Semantics/Reference/LinksTests.swift | 2 +- .../Semantics/ResourcesTests.swift | 6 +- .../Semantics/SectionTests.swift | 2 +- .../SwiftDocCTests/Semantics/StackTests.swift | 6 +- .../SwiftDocCTests/Semantics/StepTests.swift | 6 +- .../Semantics/SymbolTests.swift | 8 +- .../Semantics/TechnologyTests.swift | 2 +- .../SwiftDocCTests/Semantics/TileTests.swift | 14 +- .../Semantics/TutorialArticleTests.swift | 20 +- .../Semantics/TutorialReferenceTests.swift | 6 +- .../Semantics/TutorialTests.swift | 14 +- .../Semantics/VideoMediaTests.swift | 40 +- .../Semantics/VolumeTests.swift | 26 +- .../Semantics/XcodeRequirementTests.swift | 4 +- .../DocumentationSchemeHandlerTests.swift | 2 +- .../Servers/FileServerTests.swift | 10 +- .../Default Code Listing Syntax.md | 0 .../FillIntroduced.symbols.json | 0 .../Info.plist | 0 .../MyKit@SideKit.symbols.json | 0 .../TestOverview.tutorial | 0 .../TestTutorial.tutorial | 0 .../TestTutorial2.tutorial | 0 .../TestTutorialArticle.tutorial | 0 .../TutorialMediaWithSpaces.tutorial | 0 .../article.md | 0 .../article2.md | 0 .../article3.md | 0 .../documentation/myclass.md | 0 .../documentation/mykit.md | 0 .../documentation/myprotocol.md | 0 .../documentation/sideclass-init.md | 0 .../documentation/sidekit.md | 0 .../figure1.png | Bin .../figure1~dark.png | Bin .../helloworld.swift | 0 .../helloworld1.swift | 0 .../helloworld2.swift | 0 .../helloworld3.swift | 0 .../helloworld4.swift | 0 .../images/figure1.jpg | Bin .../intro.png | Bin .../introposter.png | Bin .../introposter2.png | Bin .../introvideo.mp4 | Bin .../introvideo~dark.mp4 | Bin .../mykit-iOS.symbols.json | 0 .../project.zip | Bin .../sidekit.symbols.json | 0 .../something@2x.png | Bin .../step.png | Bin .../titled2up.png | Bin .../titled2upCapital.PNG | Bin .../with spaces.mp4 | Bin .../with spaces.png | Bin .../with spaces@2x.png | Bin .../Utility/XCTestCase+MentionedIn.swift | 5 +- .../XCTestCase+LoadingTestData.swift | 36 +- ...nvertSubcommandSourceRepositoryTests.swift | 2 +- .../ConvertSubcommandTests.swift | 2 +- .../PreviewSubcommandTests.swift | 2 +- .../ConvertActionIndexerTests.swift | 2 +- .../ConvertActionStaticHostableTests.swift | 2 +- .../ConvertActionTests.swift | 38 +- .../IndexActionTests.swift | 2 +- .../PreviewActionIntegrationTests.swift | 2 +- .../StaticHostableTransformerTests.swift | 4 +- .../Default Code Listing Syntax.md | 0 .../FillIntroduced.symbols.json | 0 .../Info.plist | 0 .../MyKit@SideKit.symbols.json | 0 .../TestOverview.tutorial | 0 .../TestTutorial.tutorial | 0 .../TestTutorial2.tutorial | 0 .../TestTutorialArticle.tutorial | 0 .../TutorialMediaWithSpaces.tutorial | 0 .../article.md | 0 .../article2.md | 0 .../article3.md | 0 .../documentation/myclass.md | 0 .../documentation/mykit.md | 0 .../documentation/myprotocol.md | 0 .../documentation/sideclass-init.md | 0 .../documentation/sidekit.md | 0 .../figure1.png | Bin .../figure1~dark.png | Bin .../helloworld.swift | 0 .../helloworld1.swift | 0 .../helloworld2.swift | 0 .../helloworld3.swift | 0 .../helloworld4.swift | 0 .../intro.png | Bin .../introposter.png | Bin .../introposter2.png | Bin .../introvideo.mp4 | Bin .../introvideo~dark.mp4 | Bin .../mykit-iOS.symbols.json | 0 .../project.zip | Bin .../sidekit.symbols.json | 0 .../something@2x.png | Bin .../step.png | Bin .../titled2up.png | Bin .../titled2upCapital.PNG | Bin .../with spaces.mp4 | Bin .../with spaces.png | Bin .../with spaces@2x.png | Bin ...TransformForStaticHostingActionTests.swift | 4 +- .../Utility/FileTests.swift | 2 +- 184 files changed, 971 insertions(+), 925 deletions(-) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/Default Code Listing Syntax.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/FillIntroduced.symbols.json (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/Info.plist (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/MyKit@SideKit.symbols.json (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TestOverview.tutorial (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TestTutorial.tutorial (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TestTutorial2.tutorial (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TestTutorialArticle.tutorial (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TutorialMediaWithSpaces.tutorial (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/article.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/article2.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/article3.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/myclass.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/mykit.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/myprotocol.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/sideclass-init.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/sidekit.md (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/figure1.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/figure1~dark.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld.swift (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld1.swift (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld2.swift (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld3.swift (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld4.swift (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/images/figure1.jpg (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/intro.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/introposter.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/introposter2.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/introvideo.mp4 (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/introvideo~dark.mp4 (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/mykit-iOS.symbols.json (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/project.zip (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/sidekit.symbols.json (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/something@2x.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/step.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/titled2up.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/titled2upCapital.PNG (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/with spaces.mp4 (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/with spaces.png (100%) rename Tests/SwiftDocCTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/with spaces@2x.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/Default Code Listing Syntax.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/FillIntroduced.symbols.json (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/Info.plist (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/MyKit@SideKit.symbols.json (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TestOverview.tutorial (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TestTutorial.tutorial (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TestTutorial2.tutorial (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TestTutorialArticle.tutorial (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/TutorialMediaWithSpaces.tutorial (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/article.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/article2.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/article3.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/myclass.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/mykit.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/myprotocol.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/sideclass-init.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/documentation/sidekit.md (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/figure1.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/figure1~dark.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld.swift (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld1.swift (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld2.swift (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld3.swift (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/helloworld4.swift (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/intro.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/introposter.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/introposter2.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/introvideo.mp4 (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/introvideo~dark.mp4 (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/mykit-iOS.symbols.json (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/project.zip (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/sidekit.symbols.json (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/something@2x.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/step.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/titled2up.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/titled2upCapital.PNG (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/with spaces.mp4 (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/with spaces.png (100%) rename Tests/SwiftDocCUtilitiesTests/Test Bundles/{TestBundle.docc => LegacyBundle_DoNotUseInNewTests.docc}/with spaces@2x.png (100%) diff --git a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift index baf4a1aac5..20c36ce3f7 100644 --- a/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/ExternalTopicsHashTests.swift @@ -39,7 +39,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { func testNoMetricAddedIfNoExternalTopicsAreResolved() throws { // Load bundle without using external resolvers - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") XCTAssertTrue(context.externallyResolvedLinks.isEmpty) // Try adding external topics metrics @@ -55,7 +55,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { // Add external links and verify the checksum is always the same let hashes: [String] = try (0...10).map { _ -> MetricValue? in - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -93,7 +93,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { // Add external links and verify the checksum is always the same let hashes: [String] = try (0...10).map { _ -> MetricValue? in - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver], externalSymbolResolver: externalSymbolResolver) { url in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [externalResolver.bundleID: externalResolver], externalSymbolResolver: externalSymbolResolver) { url in try """ # ``SideKit/SideClass`` @@ -131,7 +131,7 @@ class ExternalTopicsGraphHashTests: XCTestCase { let externalResolver = self.externalResolver // Load a bundle with external links - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # ``SideKit/SideClass`` diff --git a/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift b/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift index 52fc62ee32..d4b5ecbc50 100644 --- a/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift +++ b/Tests/SwiftDocCTests/Benchmark/TopicGraphHashTests.swift @@ -14,7 +14,7 @@ import XCTest class TopicGraphHashTests: XCTestCase { func testTopicGraphSameHash() throws { let hashes: [String] = try (0...10).map { _ -> MetricValue? in - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let testBenchmark = Benchmark() benchmark(add: Benchmark.TopicGraphHash(context: context), benchmarkLog: testBenchmark) return testBenchmark.metrics[0].result @@ -32,7 +32,7 @@ class TopicGraphHashTests: XCTestCase { func testTopicGraphChangedHash() throws { // Verify that the hash changes if we change the topic graph let initialHash: String - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") do { let testBenchmark = Benchmark() @@ -88,7 +88,7 @@ class TopicGraphHashTests: XCTestCase { "/externally/resolved/path/to/article2": .success(.init(referencePath: "/externally/resolved/path/to/article2")), ] - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [ + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [ "com.external.testbundle" : resolver ]) { url in // Add external links to the MyKit Topics. diff --git a/Tests/SwiftDocCTests/Checker/Checkers/NonInclusiveLanguageCheckerTests.swift b/Tests/SwiftDocCTests/Checker/Checkers/NonInclusiveLanguageCheckerTests.swift index 0edc5eab9c..d57d9e7688 100644 --- a/Tests/SwiftDocCTests/Checker/Checkers/NonInclusiveLanguageCheckerTests.swift +++ b/Tests/SwiftDocCTests/Checker/Checkers/NonInclusiveLanguageCheckerTests.swift @@ -11,6 +11,7 @@ import XCTest import Markdown @testable import SwiftDocC +import SwiftDocCTestUtilities class NonInclusiveLanguageCheckerTests: XCTestCase { @@ -167,9 +168,9 @@ func aBlackListedFunc() { } private let nonInclusiveContent = """ - # ``SideKit`` + # Some root page - SideKit module root symbol. And here is a ~~whitelist~~: + Some custom root page. And here is a ~~whitelist~~: - item one - item two @@ -178,11 +179,12 @@ func aBlackListedFunc() { func testDisabledByDefault() throws { // Create a test bundle with some non-inclusive content. - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", diagnosticEngine: .init(filterLevel: .error)) { url in - try self.nonInclusiveContent.write(to: url.appendingPathComponent("documentation").appendingPathComponent("sidekit.md"), atomically: true, encoding: .utf8) - } + let catalog = Folder(name: "unit-test.docc", content: [ + TextFile(name: "Root.md", utf8Content: nonInclusiveContent) + ]) + let (_, context) = try loadBundle(catalog: catalog) - XCTAssertEqual(context.problems.count, 0) + XCTAssertEqual(context.problems.count, 0) // Non-inclusive content is an info-level diagnostic, so it's filtered out. } func testEnablingTheChecker() throws { @@ -196,9 +198,12 @@ func aBlackListedFunc() { ] for (severity, enabled) in expectations { - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", diagnosticEngine: .init(filterLevel: severity)) { url in - try self.nonInclusiveContent.write(to: url.appendingPathComponent("documentation").appendingPathComponent("sidekit.md"), atomically: true, encoding: .utf8) - } + let catalog = Folder(name: "unit-test.docc", content: [ + TextFile(name: "Root.md", utf8Content: nonInclusiveContent) + ]) + var configuration = DocumentationContext.Configuration() + configuration.externalMetadata.diagnosticLevel = severity + let (_, context) = try loadBundle(catalog: catalog, diagnosticEngine: .init(filterLevel: severity), configuration: configuration) // Verify that checker diagnostics were emitted or not, depending on the diagnostic level set. XCTAssertEqual(context.problems.contains(where: { $0.diagnostic.identifier == "org.swift.docc.NonInclusiveLanguage" }), enabled) diff --git a/Tests/SwiftDocCTests/Converter/DocumentationContextConverterTests.swift b/Tests/SwiftDocCTests/Converter/DocumentationContextConverterTests.swift index 55927f1044..f5200edd8e 100644 --- a/Tests/SwiftDocCTests/Converter/DocumentationContextConverterTests.swift +++ b/Tests/SwiftDocCTests/Converter/DocumentationContextConverterTests.swift @@ -14,7 +14,7 @@ import XCTest class DocumentationContextConverterTests: XCTestCase { func testRenderNodesAreIdentical() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // We'll use this to convert nodes ad-hoc let perNodeConverter = DocumentationNodeConverter(bundle: bundle, context: context) @@ -41,7 +41,7 @@ class DocumentationContextConverterTests: XCTestCase { } func testSymbolLocationsAreOnlyIncludedWhenRequested() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let renderContext = RenderContext(documentationContext: context, bundle: bundle) let fillIntroducedSymbolNode = try XCTUnwrap( @@ -71,7 +71,7 @@ class DocumentationContextConverterTests: XCTestCase { } func testSymbolAccessLevelsAreOnlyIncludedWhenRequested() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let renderContext = RenderContext(documentationContext: context, bundle: bundle) let fillIntroducedSymbolNode = try XCTUnwrap( diff --git a/Tests/SwiftDocCTests/Converter/RenderContextTests.swift b/Tests/SwiftDocCTests/Converter/RenderContextTests.swift index 7235bb37e2..786b321da4 100644 --- a/Tests/SwiftDocCTests/Converter/RenderContextTests.swift +++ b/Tests/SwiftDocCTests/Converter/RenderContextTests.swift @@ -14,7 +14,7 @@ import XCTest class RenderContextTests: XCTestCase { func testCreatesRenderReferences() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let renderContext = RenderContext(documentationContext: context, bundle: bundle) diff --git a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift index 8085c4be9e..37948fdd19 100644 --- a/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift +++ b/Tests/SwiftDocCTests/Converter/TopicRenderReferenceEncoderTests.swift @@ -158,7 +158,7 @@ class TopicRenderReferenceEncoderTests: XCTestCase { /// Verifies that when JSON encoder should sort keys, the custom render reference cache /// respects that setting and prints the referencs in alphabetical order. func testSortedReferences() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let converter = DocumentationNodeConverter(bundle: bundle, context: context) // Create a JSON encoder @@ -218,7 +218,7 @@ class TopicRenderReferenceEncoderTests: XCTestCase { // Verifies that there is no extra comma at the end of the references list. func testRemovesLastReferencesListDelimiter() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let converter = DocumentationNodeConverter(bundle: bundle, context: context) // Create a JSON encoder diff --git a/Tests/SwiftDocCTests/Diagnostics/DiagnosticConsoleWriterDefaultFormattingTest.swift b/Tests/SwiftDocCTests/Diagnostics/DiagnosticConsoleWriterDefaultFormattingTest.swift index 04f811b2ee..6943f58bc6 100644 --- a/Tests/SwiftDocCTests/Diagnostics/DiagnosticConsoleWriterDefaultFormattingTest.swift +++ b/Tests/SwiftDocCTests/Diagnostics/DiagnosticConsoleWriterDefaultFormattingTest.swift @@ -229,7 +229,7 @@ class DiagnosticConsoleWriterDefaultFormattingTest: XCTestCase { let summary = "Test diagnostic summary" let explanation = "Test diagnostic explanation." let baseURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let source = baseURL.appendingPathComponent("TestTutorial.tutorial") let range = SourceLocation(line: 44, column: 59, source: source)..() @@ -471,7 +471,7 @@ Root // ├────────────┐│ // ▼ ▼▼ // first() ◀──▶ second() - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ InfoPlist(identifier: testBundleIdentifier), JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( @@ -586,8 +586,7 @@ Root """), ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) let renderContext = RenderContext(documentationContext: context, bundle: bundle) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) @@ -896,7 +895,7 @@ Root } func testNavigatorIndexUsingPageTitleGeneration() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let renderContext = RenderContext(documentationContext: context, bundle: bundle) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) var results = Set() @@ -945,7 +944,7 @@ Root } func testNavigatorIndexGenerationNoPaths() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let converter = DocumentationNodeConverter(bundle: bundle, context: context) var results = Set() @@ -1002,7 +1001,7 @@ Root } func testNavigatorIndexGenerationWithLanguageGrouping() throws { - let navigatorIndex = try generatedNavigatorIndex(for: "TestBundle", bundleIdentifier: testBundleIdentifier) + let navigatorIndex = try generatedNavigatorIndex(for: "LegacyBundle_DoNotUseInNewTests", bundleIdentifier: testBundleIdentifier) XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, .iPadOS]) XCTAssertEqual(navigatorIndex.availabilityIndex.versions(for: .iOS), Set([ @@ -1022,7 +1021,7 @@ Root func testNavigatorIndexGenerationWithCuratedFragment() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let renderContext = RenderContext(documentationContext: context, bundle: bundle) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) var results = Set() @@ -1085,7 +1084,7 @@ Root } func testNavigatorIndexAvailabilityGeneration() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let renderContext = RenderContext(documentationContext: context, bundle: bundle) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) @@ -1215,7 +1214,7 @@ Root } func testNavigatorIndexDifferentHasherGeneration() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let renderContext = RenderContext(documentationContext: context, bundle: bundle) let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext) @@ -1664,7 +1663,7 @@ Root } func testNavigatorIndexAsReadOnlyFile() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let converter = DocumentationNodeConverter(bundle: bundle, context: context) let targetURL = try createTemporaryDirectory() diff --git a/Tests/SwiftDocCTests/Indexing/RenderIndexTests.swift b/Tests/SwiftDocCTests/Indexing/RenderIndexTests.swift index 2411384aa1..5cc0df3c62 100644 --- a/Tests/SwiftDocCTests/Indexing/RenderIndexTests.swift +++ b/Tests/SwiftDocCTests/Indexing/RenderIndexTests.swift @@ -24,7 +24,7 @@ final class RenderIndexTests: XCTestCase { ) try XCTAssertEqual( - generatedRenderIndex(for: "TestBundle", with: "org.swift.docc.example"), + generatedRenderIndex(for: "LegacyBundle_DoNotUseInNewTests", with: "org.swift.docc.example"), RenderIndex.fromURL(expectedIndexURL) ) } diff --git a/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift index 9c361152c6..3eb8c06178 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutoCapitalizationTests.swift @@ -57,12 +57,10 @@ class AutoCapitalizationTests: XCTestCase { parameters: ["one", "two", "three", "four", "five"] ) - let url = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) ]) - let (_, bundle, context) = try loadBundle(from: url) + let (bundle, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.count, 0) @@ -104,12 +102,10 @@ class AutoCapitalizationTests: XCTestCase { parameters: ["one", "two", "three", "four", "five"] ) - let url = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) ]) - let (_, bundle, context) = try loadBundle(from: url) + let (bundle, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.count, 0) @@ -147,12 +143,10 @@ class AutoCapitalizationTests: XCTestCase { parameters: [] ) - let url = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) ]) - let (_, bundle, context) = try loadBundle(from: url) + let (bundle, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.count, 0) diff --git a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift index 73c9db1219..5172b4f72f 100644 --- a/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift @@ -24,7 +24,7 @@ class AutomaticCurationTests: XCTestCase { let containerID = "some-container-id" let memberID = "some-member-id" - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -37,8 +37,8 @@ class AutomaticCurationTests: XCTestCase { ] )) ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) + + let (bundle, context) = try loadBundle(catalog: catalog) try assertRenderedPage(atPath: "/documentation/ModuleName/SomeClass", containsAutomaticTopicSectionFor: kind, context: context, bundle: bundle) } @@ -53,7 +53,7 @@ class AutomaticCurationTests: XCTestCase { let nonExtensionKind = SymbolGraph.Symbol.KindIdentifier(identifier: String(kind.identifier.dropLast(".extension".count))) - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ // Add an empty main symbol graph file so that the extension symbol graph file is processed JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph(moduleName: "ModuleName")), @@ -82,8 +82,8 @@ class AutomaticCurationTests: XCTestCase { ] )), ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) + + let (bundle, context) = try loadBundle(catalog: catalog) try assertRenderedPage(atPath: "/documentation/ModuleName", containsAutomaticTopicSectionFor: .extendedModule, context: context, bundle: bundle) try assertRenderedPage(atPath: "/documentation/ModuleName/ExtendedModule", containsAutomaticTopicSectionFor: kind, context: context, bundle: bundle) @@ -117,7 +117,7 @@ class AutomaticCurationTests: XCTestCase { } func testAutomaticTopicsSkippingCustomCuratedSymbols() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], configureBundle: { url in // Curate some of members of SideClass in an API collection try """ # Some API collection @@ -172,7 +172,7 @@ class AutomaticCurationTests: XCTestCase { for curatedIndices in variationsOfChildrenToCurate { let manualCuration = curatedIndices.map { "- <\(allExpectedChildren[$0])>" }.joined(separator: "\n") - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try """ # ``SideKit/SideClass`` @@ -231,7 +231,7 @@ class AutomaticCurationTests: XCTestCase { } func testSeeAlsoSectionForAutomaticallyCuratedTopics() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in var graph = try JSONDecoder().decode(SymbolGraph.self, from: Data(contentsOf: url.appendingPathComponent("sidekit.symbols.json"))) // Copy `SideClass` a handful of times @@ -421,7 +421,7 @@ class AutomaticCurationTests: XCTestCase { forResource: "TopLevelCuration.symbols", withExtension: "json", subdirectory: "Test Resources")! // Create a test bundle copy with the symbol graph from above - let (bundleURL, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { url in + let (bundleURL, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { url in try? FileManager.default.copyItem(at: topLevelCurationSGFURL, to: url.appendingPathComponent("TopLevelCuration.symbols.json")) } defer { @@ -578,7 +578,7 @@ class AutomaticCurationTests: XCTestCase { let whatsitSymbols = Bundle.module.url( forResource: "Whatsit-Objective-C.symbols", withExtension: "json", subdirectory: "Test Resources")! - let (bundleURL, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (bundleURL, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try? FileManager.default.copyItem(at: whatsitSymbols, to: url.appendingPathComponent("Whatsit-Objective-C.symbols.json")) } defer { @@ -639,7 +639,7 @@ class AutomaticCurationTests: XCTestCase { let symbolURL = Bundle.module.url( forResource: "TypeSubscript.symbols", withExtension: "json", subdirectory: "Test Resources")! - let (bundleURL, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (bundleURL, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try? FileManager.default.copyItem(at: symbolURL, to: url.appendingPathComponent("TypeSubscript.symbols.json")) } defer { diff --git a/Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift b/Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift index c866d0131f..5885f6748e 100644 --- a/Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift @@ -14,9 +14,9 @@ import SwiftDocCTestUtilities class BundleDiscoveryTests: XCTestCase { - private let testBundleLocation = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + private let testBundleLocation = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! private func flatListOfFiles() throws -> [URL] { - let testBundleLocation = try testCatalogURL(named: "TestBundle") + let testBundleLocation = try testCatalogURL(named: "LegacyBundle_DoNotUseInNewTests") let enumerator = try XCTUnwrap(FileManager.default.enumerator(at: testBundleLocation, includingPropertiesForKeys: [.isDirectoryKey], options: .skipsHiddenFiles)) var files: [URL] = [] diff --git a/Tests/SwiftDocCTests/Infrastructure/DataAssetManagerTests.swift b/Tests/SwiftDocCTests/Infrastructure/DataAssetManagerTests.swift index c18c24ab7f..850d96a436 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DataAssetManagerTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DataAssetManagerTests.swift @@ -115,15 +115,13 @@ class DataAssetManagerTests: XCTestCase { // Under the default settings this test will use `NSImage` under macOS func testImageSize() throws { - let imageFile = Bundle.module.url( + let imageFileURL = Bundle.module.url( forResource: "image", withExtension: "png", subdirectory: "Test Resources")! - XCTAssertTrue(FileManager.default.fileExists(atPath: imageFile.path)) + XCTAssertTrue(FileManager.default.fileExists(atPath: imageFileURL.path)) var manager = DataAssetManager() // Register an image asset - let catalogURL = try testCatalogURL(named: "TestBundle") - let imageFileURL = catalogURL.appendingPathComponent("figure1.png") try manager.register(data: [imageFileURL]) // Check the asset is registered diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift index 36acf8c0ad..65c54072f9 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleInfoTests.swift @@ -15,7 +15,7 @@ class DocumentationBundleInfoTests: XCTestCase { // Test whether the bundle correctly loads the test bundle Info.plist file. func testLoadTestBundleInfoPlist() throws { let infoPlistURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("Info.plist") let infoPlistData = try Data(contentsOf: infoPlistURL) diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleTests.swift index df55ad8f7c..8d03e4f305 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationBundleTests.swift @@ -14,6 +14,6 @@ import XCTest class DocumentationBundleTests: XCTestCase { // Test whether the bundle correctly loads a documentation source folder. func testBundleInitWithRootURL() throws { - XCTAssertNoThrow(try testBundleFromRootURL(named: "TestBundle")) + XCTAssertNoThrow(try testBundleFromRootURL(named: "LegacyBundle_DoNotUseInNewTests")) } } diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift index 0cc3a99385..609bcab8ed 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift @@ -42,7 +42,7 @@ class DocumentationContextTests: XCTestCase { func testResolve() throws { let workspace = DocumentationWorkspace() let context = try DocumentationContext(dataProvider: workspace) - let bundle = try testBundle(named: "TestBundle") + let bundle = try testBundle(named: "LegacyBundle_DoNotUseInNewTests") let dataProvider = PrebuiltLocalFileSystemDataProvider(bundles: [bundle]) try workspace.registerProvider(dataProvider) @@ -83,7 +83,7 @@ class DocumentationContextTests: XCTestCase { } func testLoadEntity() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let identifier = ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift) @@ -422,7 +422,9 @@ class DocumentationContextTests: XCTestCase { } func testThrowsErrorForQualifiedImagePaths() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try loadBundle(catalog: Folder(name: "unit-test.docc", content: [ + DataFile(name: "figure1.jpg", data: Data()) + ])) let id = bundle.id let figure = ResourceReference(bundleID: id, path: "figure1.jpg") @@ -433,7 +435,10 @@ class DocumentationContextTests: XCTestCase { } func testResourceExists() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try loadBundle(catalog: Folder(name: "unit-test.docc", content: [ + DataFile(name: "figure1.jpg", data: Data()), + DataFile(name: "introposter.jpg", data: Data()), + ])) let existingImageReference = ResourceReference( bundleID: bundle.id, @@ -514,7 +519,20 @@ class DocumentationContextTests: XCTestCase { } func testRegisteredImages() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try loadBundle(catalog: Folder(name: "unit-test.docc", content: [ + DataFile(name: "figure1.jpg", data: Data()), + DataFile(name: "figure1.png", data: Data()), + DataFile(name: "figure1~dark.png", data: Data()), + DataFile(name: "intro.png", data: Data()), + DataFile(name: "introposter.png", data: Data()), + DataFile(name: "introposter2.png", data: Data()), + DataFile(name: "something@2x.png", data: Data()), + DataFile(name: "step.png", data: Data()), + DataFile(name: "titled2up.png", data: Data()), + DataFile(name: "titled2upCapital.PNG", data: Data()), + DataFile(name: "with spaces.png", data: Data()), + DataFile(name: "with spaces@2x.png", data: Data()), + ])) let imagesRegistered = context .registeredImageAssets(for: bundle.id) @@ -541,7 +559,7 @@ class DocumentationContextTests: XCTestCase { } func testExternalAssets() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() let image = context.resolveAsset(named: "https://example.com/figure.png", in: bundle.rootReference) XCTAssertNotNil(image) @@ -559,8 +577,39 @@ class DocumentationContextTests: XCTestCase { } func testDownloadAssets() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") - + let (bundle, context) = try loadBundle(catalog: Folder(name: "unit-test.docc", content: [ + DataFile(name: "intro.png", data: Data()), + DataFile(name: "project.zip", data: Data()), + + TextFile(name: "TableOfContents.tutorial", utf8Content: """ + @Tutorials(name: "Something") { + @Intro(title: "Test Intro") { + Add one or more paragraphs that introduce your tutorial. + } + @Chapter(name: "Chapter Name") { + @Image(source: "intro.png", alt: "Some accessible description of the image") + + @TutorialReference(tutorial: "doc:Something") + } + } + """), + + TextFile(name: "Something.tutorial", utf8Content: """ + @Tutorial(time: 20, projectFiles: project.zip) { + @Intro(title: "Test Intro") + @Section(title: "Test Section") { + @ContentAndMedia { + Some tutorial content + } + } + @Assessments { + } + } + """), + + + ])) + let downloadsBefore = context.registeredDownloadsAssets(for: bundle.id) XCTAssertEqual(downloadsBefore.count, 1) XCTAssertEqual(downloadsBefore.first?.variants.values.first?.lastPathComponent, "project.zip") @@ -607,7 +656,7 @@ class DocumentationContextTests: XCTestCase { @available(*, deprecated, message: "This deprecated API will be removed after 6.2 is released") func testCreatesCorrectIdentifiers() throws { let testBundleLocation = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let workspaceContent = Folder(name: "TestWorkspace", content: [ CopyOfFolder(original: testBundleLocation), @@ -665,7 +714,7 @@ class DocumentationContextTests: XCTestCase { let symbols: [SymbolGraph.Symbol] = [someSymbol, anotherSymbol] // Create a catalog with doc extension files with the same filename for each symbol. - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -701,9 +750,8 @@ class DocumentationContextTests: XCTestCase { """ ) ]) - ]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) // Since documentation extensions' filenames have no impact on the URL of pages, we should not see warnings enforcing unique filenames for them. let problemWithDuplicateReference = context.problems.filter { $0.diagnostic.identifier == "org.swift.docc.DuplicateReference" } @@ -726,7 +774,13 @@ class DocumentationContextTests: XCTestCase { [Problem(diagnostic: Diagnostic(source: reference.url, severity: DiagnosticSeverity.error, range: nil, identifier: "com.tests.testGraphChecks", summary: "test error"), possibleSolutions: [])] } ) - let (_, _, context) = try testBundleAndContext(named: "TestBundle", configuration: configuration) + + let catalog = Folder(name: "unit-test.docc", content: [ + TextFile(name: "Root.md", utf8Content: """ + # Some root page + """) + ]) + let (_, context) = try loadBundle(catalog: catalog, configuration: configuration) /// Checks if the custom check added problems to the context. let testProblems = context.problems.filter({ (problem) -> Bool in @@ -770,13 +824,13 @@ class DocumentationContextTests: XCTestCase { InfoPlist(displayName: "TestIgnoresUnknownMarkupFiles", identifier: "com.example.documentation"), Folder(name: "Resources", content: [ CopyOfFile(original: Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("documentation") .appendingPathComponent("myprotocol.md")), ]), Folder(name: "Symbols", content: [ CopyOfFile(original: Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json")), ]) ]) @@ -1005,7 +1059,7 @@ class DocumentationContextTests: XCTestCase { func testMergesMultipleSymbolDeclarations() throws { let graphContentiOS = try String(contentsOf: Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json")) let graphContentmacOS = graphContentiOS @@ -1042,7 +1096,7 @@ class DocumentationContextTests: XCTestCase { func testMergedMultipleSymbolDeclarationsIncludesPlatformSpecificSymbols() throws { let iOSGraphURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json") let graphContentiOS = try String(contentsOf: iOSGraphURL) @@ -1101,10 +1155,10 @@ class DocumentationContextTests: XCTestCase { ]), Folder(name: "Symbols", content: [ CopyOfFile(original: Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json")), CopyOfFile(original: Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("sidekit.symbols.json")), ]) ]) @@ -1126,7 +1180,7 @@ class DocumentationContextTests: XCTestCase { func testLoadsDeclarationWithNoOS() throws { var graphContentiOS = try String(contentsOf: Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json")) // "remove" the operating system information @@ -1154,39 +1208,36 @@ class DocumentationContextTests: XCTestCase { } func testDetectsDuplicateSymbolArticles() throws { - let documentationURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! - .appendingPathComponent("documentation") - - let myKitURL = documentationURL.appendingPathComponent("mykit.md") - - let testCatalog = Folder(name: "TestDetectsDuplicateSymbolArticles.docc", content: [ - InfoPlist(displayName: "TestDetectsDuplicateSymbolArticles", identifier: "com.example.documentation"), - Folder(name: "Resources", content: [ - CopyOfFile(original: myKitURL, newName: "mykit.md"), - CopyOfFile(original: myKitURL, newName: "mykit-duplicate.md"), - CopyOfFile(original: myKitURL, newName: "myprotocol.md"), - CopyOfFile(original: myKitURL, newName: "myprotocol-duplicateddm"), - ]), - Folder(name: "Symbols", content: [ - CopyOfFile(original: Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! - .appendingPathComponent("mykit-iOS.symbols.json")), - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph(moduleName: "ModuleName", symbols: [ + makeSymbol(id: "some-symbol-id", kind: .class, pathComponents: ["SomeClass"]) + ])), + + TextFile(name: "first.md", utf8Content: """ + # ``SomeClass`` + + The first documentation extension for this class + """), + + TextFile(name: "second.md", utf8Content: """ + # ``/ModuleName/SomeClass`` + + The second documentation extension for this class + """), ]) - let (_, context) = try loadBundle(catalog: testCatalog) + let (bundle, context) = try loadBundle(catalog: catalog) - XCTAssertNotNil(context.problems - .map { $0.diagnostic } - .filter { $0.identifier == "org.swift.docc.DuplicateMarkdownTitleSymbolReferences" - && $0.summary.contains("'/mykit'") } - ) - XCTAssertNotNil(context.problems - .map { $0.diagnostic } - .filter { $0.identifier == "org.swift.docc.DuplicateMarkdownTitleSymbolReferences" - && $0.summary.contains("'/myprotocol'") } - ) + let duplicateExtensionProblems = context.problems.filter { $0.diagnostic.identifier == "org.swift.docc.DuplicateMarkdownTitleSymbolReferences" } + let diagnostic = try XCTUnwrap(duplicateExtensionProblems.first).diagnostic + let source = try XCTUnwrap(diagnostic.source) + + // Verify that both files are mentioned in the diagnostic and its note. + let mentionedMarkupURLs = Set(diagnostic.notes.map(\.source) + [source]) + + let missingMarkupURLs = Set(bundle.markupURLs).subtracting(mentionedMarkupURLs) + + XCTAssert(missingMarkupURLs.isEmpty, "\(missingMarkupURLs.map(\.lastPathComponent).sorted()) isn't mentioned in the diagnostic.") } func testCanResolveArticleFromTutorial() throws { @@ -1195,7 +1246,7 @@ class DocumentationContextTests: XCTestCase { var symbolGraphFiles: [File] { return symbolGraphNames.map { name in - CopyOfFile(original: Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + CopyOfFile(original: Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent(name + ".symbols.json")) } } @@ -1255,7 +1306,7 @@ class DocumentationContextTests: XCTestCase { } func testCuratesSymbolsAndArticlesCorrectly() throws { - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Sort the edges for each node to get consistent results, no matter the order that the symbols were processed. for (source, targets) in context.topicGraph.edges { @@ -1334,7 +1385,7 @@ let expected = """ } func createNode(in context: DocumentationContext, bundle: DocumentationBundle, parent: ResolvedTopicReference, name: String) throws -> (DocumentationNode, TopicGraph.Node) { - let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/\(name)", sourceLanguage: .swift) + let reference = parent.appendingPath(name) let node = DocumentationNode(reference: reference, kind: .article, sourceLanguage: .swift, name: .conceptual(title: name), markup: Document(parsing: "# \(name)"), semantic: nil) let tgNode = TopicGraph.Node(reference: reference, kind: .article, source: .external, title: name) @@ -1347,99 +1398,102 @@ let expected = """ } func testSortingBreadcrumbsOfEqualDistanceToRoot() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") - - let mykit = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName")) + ]) + let (bundle, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) /// /// Create nodes in alphabetical order /// /// Create /documentation/MyKit/AAA & /documentation/MyKit/BBB - let (aaaNode, _) = try createNode(in: context, bundle: bundle, parent: mykit, name: "AAA") - let (_, bbbTgNode) = try createNode(in: context, bundle: bundle, parent: mykit, name: "BBB") + let (aaaNode, _) = try createNode(in: context, bundle: bundle, parent: moduleReference, name: "AAA") + let (_, bbbTgNode) = try createNode(in: context, bundle: bundle, parent: moduleReference, name: "BBB") /// Create /documentation/MyKit/AAA/CCC, curate also under BBB let (cccNode, cccTgNode) = try createNode(in: context, bundle: bundle, parent: aaaNode.reference, name: "CCC") context.topicGraph.addEdge(from: bbbTgNode, to: cccTgNode) let canonicalPathCCC = try XCTUnwrap(context.shortestFinitePath(to: cccNode.reference)) - XCTAssertEqual(["/documentation/MyKit", "/documentation/MyKit/AAA"], canonicalPathCCC.map({ $0.path })) + XCTAssertEqual(["/documentation/SomeModuleName", "/documentation/SomeModuleName/AAA"], canonicalPathCCC.map({ $0.path })) /// /// Create nodes in non-alphabetical order /// /// Create /documentation/MyKit/DDD & /documentation/MyKit/EEE - let (_, dddTgNode) = try createNode(in: context, bundle: bundle, parent: mykit, name: "DDD") - let (eeeNode, _) = try createNode(in: context, bundle: bundle, parent: mykit, name: "EEE") + let (_, dddTgNode) = try createNode(in: context, bundle: bundle, parent: moduleReference, name: "DDD") + let (eeeNode, _) = try createNode(in: context, bundle: bundle, parent: moduleReference, name: "EEE") /// Create /documentation/MyKit/DDD/FFF, curate also under EEE let (fffNode, fffTgNode) = try createNode(in: context, bundle: bundle, parent: eeeNode.reference, name: "FFF") context.topicGraph.addEdge(from: dddTgNode, to: fffTgNode) let canonicalPathFFF = try XCTUnwrap(context.shortestFinitePath(to: fffNode.reference)) - XCTAssertEqual(["/documentation/MyKit", "/documentation/MyKit/DDD"], canonicalPathFFF.map({ $0.path })) + XCTAssertEqual(["/documentation/SomeModuleName", "/documentation/SomeModuleName/DDD"], canonicalPathFFF.map({ $0.path })) } func testSortingBreadcrumbsOfDifferentDistancesToRoot() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") - - let mykit = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) - let tgMykitNode = try XCTUnwrap(context.topicGraph.nodeWithReference(mykit)) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName")) + ]) + let (bundle, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) + let moduleTopicNode = try XCTUnwrap(context.topicGraph.nodeWithReference(moduleReference)) /// /// Create nodes in order /// /// Create /documentation/MyKit/AAA & /documentation/MyKit/BBB - let (aaaNode, aaaTgNode) = try createNode(in: context, bundle: bundle, parent: mykit, name: "AAA") - let (_, bbbTgNode) = try createNode(in: context, bundle: bundle, parent: mykit, name: "BBB") + let (aaaNode, aaaTgNode) = try createNode(in: context, bundle: bundle, parent: moduleReference, name: "AAA") + let (_, bbbTgNode) = try createNode(in: context, bundle: bundle, parent: moduleReference, name: "BBB") /// Create /documentation/MyKit/AAA/CCC and also curate under /documentation/MyKit let (cccNode, cccTgNode) = try createNode(in: context, bundle: bundle, parent: aaaNode.reference, name: "CCC") - context.topicGraph.addEdge(from: tgMykitNode, to: cccTgNode) + context.topicGraph.addEdge(from: moduleTopicNode, to: cccTgNode) context.topicGraph.addEdge(from: aaaTgNode, to: cccTgNode) context.topicGraph.addEdge(from: bbbTgNode, to: cccTgNode) let canonicalPathCCC = try XCTUnwrap(context.shortestFinitePath(to: cccNode.reference)) - XCTAssertEqual(["/documentation/MyKit"], canonicalPathCCC.map({ $0.path })) + XCTAssertEqual(["/documentation/SomeModuleName"], canonicalPathCCC.map({ $0.path })) /// /// Create nodes not in order /// /// Create /documentation/MyKit/DDD & /documentation/MyKit/EEE - let (_, dddTgNode) = try createNode(in: context, bundle: bundle, parent: mykit, name: "DDD") - let (eeeNode, eeeTgNode) = try createNode(in: context, bundle: bundle, parent: mykit, name: "EEE") + let (_, dddTgNode) = try createNode(in: context, bundle: bundle, parent: moduleReference, name: "DDD") + let (eeeNode, eeeTgNode) = try createNode(in: context, bundle: bundle, parent: moduleReference, name: "EEE") /// Create /documentation/MyKit/DDD/FFF, curate also under /documentation/MyKit let (fffNode, fffTgNode) = try createNode(in: context, bundle: bundle, parent: eeeNode.reference, name: "FFF") context.topicGraph.addEdge(from: eeeTgNode, to: fffTgNode) context.topicGraph.addEdge(from: dddTgNode, to: fffTgNode) - context.topicGraph.addEdge(from: tgMykitNode, to: fffTgNode) + context.topicGraph.addEdge(from: moduleTopicNode, to: fffTgNode) let canonicalPathFFF = try XCTUnwrap(context.shortestFinitePath(to: fffNode.reference)) - XCTAssertEqual(["/documentation/MyKit"], canonicalPathFFF.map({ $0.path })) + XCTAssertEqual(["/documentation/SomeModuleName"], canonicalPathFFF.map({ $0.path })) } // Verify that a symbol that has no parents in the symbol graph is automatically curated under the module node. func testRootSymbolsAreCuratedInModule() throws { - let (url, bundle, context) = try testBundleAndContext(copying: "TestBundle") - - // Verify that SideClass doesn't have a memberOf relationship at all. - let graphData = try Data(contentsOf: url.appendingPathComponent("sidekit.symbols.json")) - let graph = try JSONDecoder().decode(SymbolGraph.self, from: graphData) - XCTAssertNil(graph.relationships.first { (relationship) -> Bool in - return relationship.kind == .memberOf && relationship.source == "5SideKit0A5SideClassC" - }) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName", symbols: [ + makeSymbol(id: "some-class-id", kind: .class, pathComponents: ["SomeClass"]), + ])), + ]) + let (_, context) = try loadBundle(catalog: catalog) // Verify the node is a child of the module node when the graph is loaded. - let sideClassReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass", sourceLanguage: .swift) - let parents = context.parents(of: sideClassReference) - XCTAssertEqual(parents.map {$0.path}, ["/documentation/SideKit"]) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) + let classReference = moduleReference.appendingPath("SomeClass") + let parents = context.parents(of: classReference) + XCTAssertEqual(parents, [moduleReference]) } /// Tests whether tutorial curated multiple times gets the correct breadcrumbs and hierarchy. func testCurateTutorialMultipleTimes() throws { // Curate "TestTutorial" under MyKit as well as TechnologyX. - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in let myKitURL = root.appendingPathComponent("documentation/mykit.md") let text = try String(contentsOf: myKitURL).replacingOccurrences(of: "## Topics", with: """ ## Topics @@ -1466,7 +1520,7 @@ let expected = """ func testNonOverloadPaths() throws { // Add some symbol collisions to graph - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in let sideKitURL = root.appendingPathComponent("sidekit.symbols.json") let text = try String(contentsOf: sideKitURL).replacingOccurrences(of: "\"symbols\" : [", with: """ "symbols" : [ @@ -1518,55 +1572,10 @@ let expected = """ } func testModuleLanguageFallsBackToSwiftIfItHasNoSymbols() throws { - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { root in - // Delete all the symbol graph files. - let symbolGraphFiles = try XCTUnwrap( - FileManager.default.enumerator( - at: root, - includingPropertiesForKeys: [.isRegularFileKey], - options: [] - )?.compactMap { item in - item as? URL - }.filter { url in - url.absoluteString.hasSuffix(".symbols.json") - } - ) - - for symbolGraphFile in symbolGraphFiles { - try FileManager.default.removeItem(at: symbolGraphFile) - } - - // Add a symbol graph file with no symbols. - try """ - { - "metadata": { - "formatVersion": { - "major": 0, - "minor": 5, - "patch": 0 - }, - "generator": "MyGenerator" - }, - "module" : { - "name" : "MyKit", - "platform" : { - "architecture" : "x86_64", - "vendor" : "apple", - "operatingSystem" : { - "name" : "ios", - "minimumVersion" : { - "major" : 13, - "minor" : 0, - "patch" : 0 - } - } - } - }, - "relationships": [], - "symbols": [] - } - """.write(to: root.appendingPathComponent("MyKit.symbols.json"), atomically: true, encoding: .utf8) - } + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName")), + ]) + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual( context.soleRootModuleReference.map { context.sourceLanguages(for: $0) }, @@ -1577,7 +1586,7 @@ let expected = """ func testOverloadPlusNonOverloadCollisionPaths() throws { // Add some symbol collisions to graph - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in let sideKitURL = root.appendingPathComponent("sidekit.symbols.json") let text = try String(contentsOf: sideKitURL).replacingOccurrences(of: "\"symbols\" : [", with: """ "symbols" : [ @@ -1648,15 +1657,17 @@ let expected = """ } func testUnknownSymbolKind() throws { - // Change the symbol kind to an unknown and load the symbol graph - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { root in - let myKitURL = root.appendingPathComponent("mykit-iOS.symbols.json") - let text = try String(contentsOf: myKitURL).replacingOccurrences(of: "\"identifier\" : \"swift.method\"", with: "\"identifier\" : \"blip-blop\"") - try text.write(to: myKitURL, atomically: true, encoding: .utf8) - } + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName", symbols: [ + makeSymbol(id: "some-symbol-id", kind: .init(identifier: "blip-blop"), pathComponents: ["SomeUnknownSymbol"]), + ])), + ]) + + let (_, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) - // Get a function node, verify its kind is unknown - let node = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) + // Get the node, verify its kind is unknown + let node = try context.entity(with: moduleReference.appendingPath("SomeUnknownSymbol")) XCTAssertEqual(node.kind, .unknown) } @@ -1735,7 +1746,7 @@ let expected = """ } func testFileNamesWithDifferentPunctuation() throws { - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ TextFile(name: "Hello-world.md", utf8Content: """ # Dash @@ -1767,8 +1778,8 @@ let expected = """ The punctuation is not removed from the reference, so this has a unique reference. """), ]) - ]) - let (_, _, context) = try loadBundle(from: tempURL) + + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.map(\.diagnostic.summary), ["Redeclaration of 'Hello world.md'; this file will be skipped"]) @@ -1782,10 +1793,17 @@ let expected = """ } func testSpecialCharactersInLinks() throws { - let originalSymbolGraph = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")!.appendingPathComponent("mykit-iOS.symbols.json") - - let testBundle = Folder(name: "special-characters.docc", content: [ - try TextFile(name: "mykit.symbols.json", utf8Content: String(contentsOf: originalSymbolGraph).replacingOccurrences(of: "myFunction", with: "myFunc🙂")), + let catalog = Folder(name: "special-characters.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph( + moduleName: "SomeModuleName", + symbols: [ + makeSymbol(id: "some-class-id", kind: .class, pathComponents: ["SomeClass"]), + makeSymbol(id: "some-function-id", kind: .func, pathComponents: ["SomeClass", "someFunction🙂()"]), + ], + relationships: [ + .init(source: "some-function-id", target: "some-class-id", kind: .memberOf, targetFallback: nil) + ]) + ), TextFile(name: "article-with-emoji-in-heading.md", utf8Content: """ # Article with emoji in heading @@ -1811,12 +1829,12 @@ let expected = """ ### Hello world """), - TextFile(name: "MyKit.md", utf8Content: """ - # ``MyKit`` + TextFile(name: "SomeModuleName.md", utf8Content: """ + # ``SomeModuleName`` Test linking to articles, symbols, and headings with special characters; - - ``MyClass/myFunc🙂()`` + - ``SomeClass/someFunction🙂()`` - - - @@ -1829,18 +1847,18 @@ let expected = """ Only curate the pages. Headings don't support curation. - - ``MyClass/myFunc🙂()`` + - ``SomeClass/someFunction🙂()`` - - """), ]) - let bundleURL = try testBundle.write(inside: createTemporaryDirectory()) + let bundleURL = try catalog.write(inside: createTemporaryDirectory()) let (_, bundle, context) = try loadBundle(from: bundleURL) let problems = context.problems XCTAssertEqual(problems.count, 0, "Unexpected problems: \(problems.map(\.diagnostic.summary).sorted())") - let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) let entity = try context.entity(with: moduleReference) let moduleSymbol = try XCTUnwrap(entity.semantic as? Symbol) @@ -1848,7 +1866,7 @@ let expected = """ // Verify that all the links in the topic section resolved XCTAssertEqual(topicSection.links.map(\.destination), [ - "doc://special-characters/documentation/MyKit/MyClass/myFunc_()", + "doc://special-characters/documentation/SomeModuleName/SomeClass/someFunction_()", "doc://special-characters/documentation/special-characters/article-with---in-filename", "doc://special-characters/documentation/special-characters/Article:-with---various!-whitespace-&-punctuation.-in,-filename", ]) @@ -1867,7 +1885,7 @@ let expected = """ // Verify that the resolved links rendered as links XCTAssertEqual(renderNode.topicSections.first?.identifiers.count, 3) XCTAssertEqual(renderNode.topicSections.first?.identifiers, [ - "doc://special-characters/documentation/MyKit/MyClass/myFunc_()", + "doc://special-characters/documentation/SomeModuleName/SomeClass/someFunction_()", "doc://special-characters/documentation/special-characters/article-with---in-filename", "doc://special-characters/documentation/special-characters/Article:-with---various!-whitespace-&-punctuation.-in,-filename", ]) @@ -1901,7 +1919,7 @@ let expected = """ // First withContentAsReference(list.items.first) { identifier, isActive, overridingTitle, overridingTitleInlineContent in - XCTAssertEqual(identifier.identifier, "doc://special-characters/documentation/MyKit/MyClass/myFunc_()") + XCTAssertEqual(identifier.identifier, "doc://special-characters/documentation/SomeModuleName/SomeClass/someFunction_()") XCTAssertEqual(isActive, true) XCTAssertEqual(overridingTitle, nil) XCTAssertEqual(overridingTitleInlineContent, nil) @@ -1939,8 +1957,8 @@ let expected = """ // Verify that the topic render references have titles with special characters when the original content contained special characters XCTAssertEqual( - (renderNode.references["doc://special-characters/documentation/MyKit/MyClass/myFunc_()"] as? TopicRenderReference)?.title, - "myFunc🙂()" + (renderNode.references["doc://special-characters/documentation/SomeModuleName/SomeClass/someFunction_()"] as? TopicRenderReference)?.title, + "someFunction🙂()" ) XCTAssertEqual( (renderNode.references["doc://special-characters/documentation/special-characters/article-with-emoji-in-heading#Hello-%F0%9F%8C%8D"] as? TopicRenderReference)?.title, @@ -1966,7 +1984,7 @@ let expected = """ func testNonOverloadCollisionFromExtension() throws { // Add some symbol collisions to graph - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: ["mykit-iOS.symbols.json"]) { root in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: ["mykit-iOS.symbols.json"]) { root in let sideKitURL = root.appendingPathComponent("something@SideKit.symbols.json") let text = """ { @@ -2029,53 +2047,49 @@ let expected = """ } func testUnresolvedSidecarDiagnostics() throws { - var unknownSymbolSidecarURL: URL! - var otherUnknownSymbolSidecarURL: URL! - - let content = """ - # ``MyKit/UnknownSymbol`` - - This symbol doesn't exist in the symbol graph. - """ - - // Add a sidecar file for a symbol that doesn't exist - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { root in - unknownSymbolSidecarURL = root.appendingPathComponent("documentation/unknownSymbol.md") - otherUnknownSymbolSidecarURL = root.appendingPathComponent("documentation/anotherSidecarFileForThisUnknownSymbol.md") + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( + moduleName: "ModuleName", + symbols: [ + makeSymbol(id: "symbol-id", kind: .class, pathComponents: ["SymbolName"]), + ] + )), - try content.write(to: unknownSymbolSidecarURL, atomically: true, encoding: .utf8) - try content.write(to: otherUnknownSymbolSidecarURL, atomically: true, encoding: .utf8) - } + TextFile(name: "Extension.md", utf8Content: """ + # ``/ModuleName/UnknownSymbol`` + + This symbol doesn't exist in the symbol graph. + """), + + TextFile(name: "SameExtension.md", utf8Content: """ + # ``/ModuleName/UnknownSymbol`` + + This symbol doesn't exist in the symbol graph. + """), + ]) + + let (bundle, context) = try loadBundle(catalog: catalog) let unmatchedSidecarProblem = try XCTUnwrap(context.problems.first(where: { $0.diagnostic.identifier == "org.swift.docc.SymbolUnmatched" })) + XCTAssertNotNil(unmatchedSidecarProblem) // Verify the diagnostics have the sidecar source URL - XCTAssertNotNil(unmatchedSidecarProblem.diagnostic.source) - let sidecarFilesForUnknownSymbol: Set = [unknownSymbolSidecarURL.standardizedFileURL, otherUnknownSymbolSidecarURL.standardizedFileURL] + let source = try XCTUnwrap(unmatchedSidecarProblem.diagnostic.source) - XCTAssertNotNil(unmatchedSidecarProblem) let unmatchedSidecarDiagnostic = unmatchedSidecarProblem.diagnostic - XCTAssertTrue(sidecarFilesForUnknownSymbol.contains(unmatchedSidecarDiagnostic.source?.standardizedFileURL), "One of the files should be the diagnostic source") - XCTAssertEqual(unmatchedSidecarDiagnostic.range, SourceLocation(line: 1, column: 3, source: unmatchedSidecarProblem.diagnostic.source).. new-article1 let myKitURL = root.appendingPathComponent("documentation").appendingPathComponent("mykit.md") try """ @@ -2416,7 +2423,7 @@ let expected = """ // Modules that are being extended should not have their own symbol in the current bundle's graph. func testNoSymbolForTertiarySymbolGraphModules() throws { // Add an article without curating it anywhere - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Create an extension only symbol graph. let tertiaryURL = root.appendingPathComponent("Tertiary@MyKit.symbols.json") try """ @@ -2450,7 +2457,7 @@ let expected = """ } func testDeclarationTokenKinds() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let myFunc = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) @@ -2491,7 +2498,7 @@ let expected = """ // Copy test Info.plist try FileManager.default.copyItem(at: Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("Info.plist"), to: targetURL.appendingPathComponent("Info.plist") ) @@ -2598,7 +2605,7 @@ let expected = """ } func testNavigatorTitle() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") func renderNodeForPath(path: String) throws -> (DocumentationNode, RenderNode) { let reference = ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguage: .swift) let node = try context.entity(with: reference) @@ -2709,7 +2716,7 @@ let expected = """ // Verify there is no pool bucket for the bundle we're about to test XCTAssertNil(ResolvedTopicReference._numberOfCachedReferences(bundleID: bundleID)) - let (_, _, _) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], configureBundle: { rootURL in + let (_, _, _) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], configureBundle: { rootURL in let infoPlistURL = rootURL.appendingPathComponent("Info.plist", isDirectory: false) try! String(contentsOf: infoPlistURL) .replacingOccurrences(of: "org.swift.docc.example", with: bundleID.rawValue) @@ -2737,7 +2744,7 @@ let expected = """ } func testAbstractAfterMetadataDirective() throws { - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Get the SideKit/SideClass/init() node and verify it has an abstract and no discussion. // We're verifying that the metadata directive between the title and the abstract didn't cause @@ -2788,7 +2795,7 @@ let expected = """ } func testTaskGroupsPersistInitialRangesFromMarkup() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Verify task group ranges are persisted for symbol docs let symbolReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) @@ -2825,7 +2832,7 @@ let expected = """ /// Tests that diagnostics raised during link resolution for symbols have the correct source URLs /// - Bug: rdar://63288817 func testDiagnosticsForSymbolsHaveCorrectSource() throws { - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in let extensionFile = """ # ``SideKit/SideClass/myFunction()`` @@ -2873,7 +2880,7 @@ let expected = """ let bundleURL = try Folder(name: "module-links.docc", content: [ InfoPlist(displayName: "Test", identifier: "com.test.docc"), CopyOfFile(original: Bundle.module.url( - forResource: "TestBundle", + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles" )!.appendingPathComponent("sidekit.symbols.json")), @@ -2921,7 +2928,7 @@ let expected = """ // Only a single article for withExplicitTechnologyRoot in [true, false] { for withPageColor in [true, false] { - let catalogURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ TextFile(name: "Root.md", utf8Content: """ # My root page @@ -2935,8 +2942,7 @@ let expected = """ - """), ]) - ]) - let (_, _, context) = try loadBundle(from: catalogURL) + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.map(\.diagnostic.summary), [ "'NotFoundSymbol' doesn't exist at '/Root'", @@ -2958,7 +2964,7 @@ let expected = """ // Article that match the bundle's name for withExplicitTechnologyRoot in [true, false] { for withPageColor in [true, false] { - let catalogURL = try createTempFolder(content: [ + let catalog = Folder(name: "CatalogName.docc", content: [ TextFile(name: "CatalogName.md", utf8Content: """ # My root page @@ -2980,8 +2986,8 @@ let expected = """ - """), ]) - ]) - let (_, _, context) = try loadBundle(from: catalogURL) + + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.map(\.diagnostic.summary), [ "'NotFoundSymbol' doesn't exist at '/CatalogName'", @@ -3001,7 +3007,7 @@ let expected = """ } // Completely synthesized root - let catalogURL = try createTempFolder(content: [ + let catalog = Folder(name: "CatalogName.docc", content: [ TextFile(name: "First.md", utf8Content: """ # One article @@ -3025,8 +3031,8 @@ let expected = """ - """), ]) - ]) - let (_, _, context) = try loadBundle(from: catalogURL) + + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.map(\.diagnostic.summary).sorted(), [ "'NotFoundArticle' doesn't exist at '/CatalogName/Second'", @@ -3986,7 +3992,7 @@ let expected = """ // Verifies if the context resolves linkable nodes. func testLinkableNodes() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try "# Article1".write(to: url.appendingPathComponent("resolvable-article.md"), atomically: true, encoding: .utf8) let myKitURL = url.appendingPathComponent("documentation").appendingPathComponent("mykit.md") try String(contentsOf: myKitURL) @@ -4008,7 +4014,7 @@ let expected = """ // Verifies if the context fails to resolve non-resolvable nodes. func testNonLinkableNodes() throws { // Create a bundle with variety absolute and relative links and symbol links to a non linkable node. - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in try """ # ``SideKit/SideClass`` Abstract. @@ -4438,25 +4444,27 @@ let expected = """ } func testDocumentationExtensionURLForReferenceReturnsURLForSymbolReference() throws { - let (bundleURL, _, context) = try testBundleAndContext(copying: "TestBundle") + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName", symbols: [ + makeSymbol(id: "some-symbol-id", kind: .class, pathComponents: ["SomeClass"]) + ])), + + TextFile(name: "Extension.md", utf8Content: """ + # ``SomeClass`` + """), + ]) + + let (bundle, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) XCTAssertEqual( - context.documentationExtensionURL( - for: ResolvedTopicReference( - bundleID: "org.swift.docc.example", - path: "/documentation/MyKit/MyClass", - fragment: nil, - sourceLanguage: .swift - ) - ), - bundleURL - .appendingPathComponent("documentation") - .appendingPathComponent("myclass.md") + context.documentationExtensionURL(for: moduleReference.appendingPath("SomeClass")), + bundle.markupURLs.first ) } func testDocumentationExtensionURLForReferenceReturnsNilForTutorialReference() throws { - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") XCTAssertNil( context.documentationExtensionURL( @@ -4540,7 +4548,7 @@ let expected = """ } func testPathsToHandlesCyclicCuration() throws { - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ Folder(name: "clang", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( @@ -4684,8 +4692,8 @@ let expected = """ - ``SomeClass`` """), ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) + + let (bundle, context) = try loadBundle(catalog: catalog) let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/SomeError/Code-swift.enum/someCase", sourceLanguage: .swift) XCTAssertEqual( @@ -4702,11 +4710,15 @@ let expected = """ } func testUnresolvedLinkWarnings() throws { - var (_, _, context) = try testBundleAndContext(copying: "TestBundle") { url in - let extensionFile = """ - # ``SideKit`` - - myFunction abstract + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName", symbols: [ + makeSymbol(id: "some-symbol-id", kind: .class, pathComponents: ["SomeClass"]) + ])), + + TextFile(name: "Extension.md", utf8Content: """ + # ``SomeClass`` + + Some class abstract ## Overview @@ -4716,15 +4728,15 @@ let expected = """ - - """ - let fileURL = url.appendingPathComponent("documentation").appendingPathComponent("myFunction.md") - try extensionFile.write(to: fileURL, atomically: true, encoding: .utf8) - } + """), + ]) + + var (_, context) = try loadBundle(catalog: catalog) var problems = context.diagnosticEngine.problems - var linkResolutionProblems = problems.filter { $0.diagnostic.source?.relativePath.hasSuffix("myFunction.md") == true } - XCTAssertEqual(linkResolutionProblems.count, 3) + var linkResolutionProblems = problems.filter { $0.diagnostic.source?.relativePath.hasSuffix("Extension.md") == true } + XCTAssertEqual(linkResolutionProblems.count, 2) var problem = try XCTUnwrap(linkResolutionProblems.last) - XCTAssertEqual(problem.diagnostic.summary, "\'NonExistingDoc\' doesn\'t exist at \'/SideKit\'") + XCTAssertEqual(problem.diagnostic.summary, "\'NonExistingDoc\' doesn\'t exist at \'/SomeModuleName/SomeClass\'") (_, _, context) = try testBundleAndContext(copying: "BookLikeContent") { url in let extensionFile = """ # My Article @@ -4762,16 +4774,15 @@ let expected = """ makeSymbol(id: "fourth-\($0.identifier)-id", kind: $0, pathComponents: ["SymbolName"]), ] } - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", symbols: symbols )) ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let (_, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) for kindID in overloadableKindIDs { var seenIndices = Set() @@ -4839,7 +4850,7 @@ let expected = """ makeSymbol(id: "fourth-\($0.identifier)-id", kind: $0, pathComponents: ["SymbolName"]), ] } - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -4857,9 +4868,8 @@ let expected = """ """.utf8)) ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let (_, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) for kindID in overloadableKindIDs { switch context.resolve(.unresolved(.init(topicURL: .init(symbolPath: "SymbolName-\(kindID.identifier)"))), in: moduleReference, fromSymbolLink: true) { @@ -4889,15 +4899,15 @@ let expected = """ makeSymbol(id: "fourth-\($0.identifier)-id", kind: $0, pathComponents: ["SymbolName"]), ] } - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", symbols: symbols )) ]) - ]) - let (_, _, context) = try loadBundle(from: tempURL) + + let (_, context) = try loadBundle(catalog: catalog) for kindID in nonOverloadableKindIDs { // Find the 4 symbols of this specific kind @@ -4914,7 +4924,7 @@ let expected = """ } func testWarnsOnUnknownPlistFeatureFlag() throws { - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ DataFile(name: "Info.plist", data: Data(""" @@ -4928,8 +4938,7 @@ let expected = """ """.utf8)) ]) - ]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let unknownFeatureFlagProblems = context.problems.filter({ $0.diagnostic.identifier == "org.swift.docc.UnknownBundleFeatureFlag" }) XCTAssertEqual(unknownFeatureFlagProblems.count, 1) @@ -4940,7 +4949,7 @@ let expected = """ } func testUnknownFeatureFlagSuggestsOtherFlags() throws { - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ DataFile(name: "Info.plist", data: Data(""" @@ -4954,8 +4963,7 @@ let expected = """ """.utf8)) ]) - ]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let unknownFeatureFlagProblems = context.problems.filter({ $0.diagnostic.identifier == "org.swift.docc.UnknownBundleFeatureFlag" }) XCTAssertEqual(unknownFeatureFlagProblems.count, 1) @@ -4972,7 +4980,7 @@ let expected = """ let symbolKind = try XCTUnwrap(SymbolGraph.Symbol.KindIdentifier.allCases.filter({ $0.isOverloadableKind }).first) - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName-macos.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -4989,9 +4997,9 @@ let expected = """ makeSymbol(id: "symbol-3", kind: symbolKind, pathComponents: ["SymbolName"]), ])), ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + + let (_, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5050,7 +5058,7 @@ let expected = """ // mixins, `symbol-1` wouldn't save its overload data, which would trip an assertion in // DocumentationContext. We need to ensure that an overload group is properly created, and // that both symbols are correctly grouped underneath it. - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName-macos.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -5066,9 +5074,9 @@ let expected = """ makeSymbol(id: "symbol-2", kind: symbolKind, pathComponents: ["SymbolName"]), ])), ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + + let (_, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5125,7 +5133,7 @@ let expected = """ let symbolKind = try XCTUnwrap(SymbolGraph.Symbol.KindIdentifier.allCases.filter({ $0.isOverloadableKind }).first) - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -5141,9 +5149,9 @@ let expected = """ makeSymbol(id: "symbol-2", kind: symbolKind, pathComponents: ["SymbolName"]), ])), ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + + let (_, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol @@ -5195,7 +5203,7 @@ let expected = """ let symbolKind = try XCTUnwrap(SymbolGraph.Symbol.KindIdentifier.allCases.filter({ $0.isOverloadableKind }).first) - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName-macos.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -5211,9 +5219,8 @@ let expected = """ makeSymbol(id: "symbol-2", kind: symbolKind, pathComponents: ["SymbolName"]), ])), ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) - let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) + let (_, context) = try loadBundle(catalog: catalog) + let moduleReference = try XCTUnwrap(context.soleRootModuleReference) let overloadGroupNode: DocumentationNode let overloadGroupSymbol: Symbol diff --git a/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift index 9c07f68b22..fea832171e 100644 --- a/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/DocumentationCuratorTests.swift @@ -28,7 +28,7 @@ class DocumentationCuratorTests: XCTestCase { } func testCrawl() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var crawler = DocumentationCurator.init(in: context, bundle: bundle) let mykit = try context.entity(with: ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", sourceLanguage: .swift)) @@ -75,7 +75,7 @@ class DocumentationCuratorTests: XCTestCase { } func testCrawlDiagnostics() throws { - let (tempCatalogURL, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (tempCatalogURL, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in let extensionFile = url.appendingPathComponent("documentation/myfunction.md") try """ @@ -278,7 +278,7 @@ class DocumentationCuratorTests: XCTestCase { } func testSymbolLinkResolving() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let crawler = DocumentationCurator.init(in: context, bundle: bundle) @@ -331,7 +331,7 @@ class DocumentationCuratorTests: XCTestCase { } func testLinkResolving() throws { - let (sourceRoot, bundle, context) = try testBundleAndContext(named: "TestBundle") + let (sourceRoot, bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var crawler = DocumentationCurator.init(in: context, bundle: bundle) @@ -386,7 +386,7 @@ class DocumentationCuratorTests: XCTestCase { } func testGroupLinkValidation() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { root in // Create a sidecar with invalid group links try! """ # ``SideKit`` diff --git a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift index 323a304c7c..4c61ba3adc 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ExternalReferenceResolverTests.swift @@ -59,7 +59,7 @@ class ExternalReferenceResolverTests: XCTestCase { func testResolveExternalReference() throws { let (_, bundle, context) = try testBundleAndContext( - copying: "TestBundle", + copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: ["com.external.testbundle" : TestExternalReferenceResolver()] ) { url in let myClassExtensionFile = url.appendingPathComponent("documentation").appendingPathComponent("myclass.md") @@ -97,7 +97,7 @@ class ExternalReferenceResolverTests: XCTestCase { externalResolver.resolvedEntityLanguage = .data let (_, bundle, context) = try testBundleAndContext( - copying: "TestBundle", + copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [externalResolver.bundleID: externalResolver] ) { url in let sideClassExtension = """ @@ -158,7 +158,7 @@ class ExternalReferenceResolverTests: XCTestCase { @available(*, deprecated, message: "This deprecated API will be removed after 6.2 is released") func testResolvesReferencesExternallyOnlyWhenFallbackResolversAreSet() throws { let workspace = DocumentationWorkspace() - let bundle = try testBundle(named: "TestBundle") + let bundle = try testBundle(named: "LegacyBundle_DoNotUseInNewTests") let dataProvider = PrebuiltLocalFileSystemDataProvider(bundles: [bundle]) try workspace.registerProvider(dataProvider) let context = try DocumentationContext(dataProvider: workspace) @@ -220,7 +220,7 @@ class ExternalReferenceResolverTests: XCTestCase { } func testLoadEntityForExternalReference() throws { - let (_, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: ["com.external.testbundle" : TestExternalReferenceResolver()]) + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests", externalResolvers: ["com.external.testbundle" : TestExternalReferenceResolver()]) let identifier = ResolvedTopicReference(bundleID: "com.external.testbundle", path: "/externally/resolved/path", sourceLanguage: .swift) XCTAssertThrowsError(try context.entity(with: ResolvedTopicReference(bundleID: "some.other.bundle", path: identifier.path, sourceLanguage: .swift))) @@ -251,7 +251,7 @@ class ExternalReferenceResolverTests: XCTestCase { externalResolver.resolvedEntityTitle = "ClassName" externalResolver.resolvedEntityKind = resolvedEntityKind - let (bundle, context) = try testBundleAndContext(named: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [externalResolver.bundleID: externalResolver]) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) @@ -293,7 +293,7 @@ class ExternalReferenceResolverTests: XCTestCase { .init(kind: .identifier, spelling: "ClassName", preciseIdentifier: nil), ]) - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -385,7 +385,7 @@ class ExternalReferenceResolverTests: XCTestCase { externalResolver.resolvedEntityTitle = "Name of Sample" externalResolver.resolvedEntityKind = .sampleCode - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [externalResolver.bundleID: externalResolver]) { url in try """ # ``SideKit/SideClass`` @@ -595,7 +595,7 @@ class ExternalReferenceResolverTests: XCTestCase { "/externally/resolved/path/to/article2": .success(.init(referencePath: "/externally/resolved/path/to/article2")), ] - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [ + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [ "com.external.testbundle" : resolver ]) { url in // Add external links to the MyKit Topics. @@ -627,7 +627,7 @@ class ExternalReferenceResolverTests: XCTestCase { // Tests that external references are resolved in tutorial content func testResolveExternalReferenceInTutorials() throws { let resolver = TestExternalReferenceResolver() - let (_, _, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: ["com.external.bundle": resolver, "com.external.testbundle": resolver], configureBundle: { (bundleURL) in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: ["com.external.bundle": resolver, "com.external.testbundle": resolver], configureBundle: { (bundleURL) in // Replace TestTutorial.tutorial with a copy that includes a bunch of external links try FileManager.default.removeItem(at: bundleURL.appendingPathComponent("TestTutorial.tutorial")) try FileManager.default.copyItem( @@ -716,7 +716,7 @@ class ExternalReferenceResolverTests: XCTestCase { // Copy the test bundle and add external links to the MyKit See Also. // We're using a See Also group, because external links aren't rendered in Topics groups. - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: ["com.external.testbundle" : resolver]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: ["com.external.testbundle" : resolver]) { url in try """ # ``MyKit`` MyKit module root symbol @@ -802,7 +802,7 @@ class ExternalReferenceResolverTests: XCTestCase { resolver.expectedFragment = "67890" // Prepare a test bundle - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: ["com.external.testbundle" : resolver], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: ["com.external.testbundle" : resolver], externalSymbolResolver: nil, configureBundle: { url in // Add external link with fragment let myClassMDURL = url.appendingPathComponent("documentation").appendingPathComponent("myclass.md") try String(contentsOf: myClassMDURL) @@ -922,7 +922,7 @@ class ExternalReferenceResolverTests: XCTestCase { } func testDeprecationSummaryWithExternalLink() throws { - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", symbols: [ @@ -961,8 +961,9 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID: resolver]) + var configuration = DocumentationContext.Configuration() + configuration.externalDocumentationConfiguration.sources = [resolver.bundleID: resolver] + let (bundle, context) = try loadBundle(catalog: catalog, configuration: configuration) XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") @@ -986,7 +987,7 @@ class ExternalReferenceResolverTests: XCTestCase { } func testExternalLinkInGeneratedSeeAlso() throws { - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ TextFile(name: "Root.md", utf8Content: """ # Root @@ -1017,8 +1018,9 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID: resolver]) + var configuration = DocumentationContext.Configuration() + configuration.externalDocumentationConfiguration.sources = [resolver.bundleID: resolver] + let (bundle, context) = try loadBundle(catalog: catalog, configuration: configuration) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") @@ -1066,7 +1068,7 @@ class ExternalReferenceResolverTests: XCTestCase { } func testExternalLinkInAuthoredSeeAlso() throws { - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ TextFile(name: "Root.md", utf8Content: """ # Root @@ -1084,8 +1086,9 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID: resolver]) + var configuration = DocumentationContext.Configuration() + configuration.externalDocumentationConfiguration.sources = [resolver.bundleID: resolver] + let (bundle, context) = try loadBundle(catalog: catalog, configuration: configuration) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") @@ -1106,7 +1109,7 @@ class ExternalReferenceResolverTests: XCTestCase { func testParametersWithExternalLink() throws { - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.swift.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", symbols: [ @@ -1169,8 +1172,9 @@ class ExternalReferenceResolverTests: XCTestCase { let resolver = TestExternalReferenceResolver() - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: [resolver.bundleID: resolver]) + var configuration = DocumentationContext.Configuration() + configuration.externalDocumentationConfiguration.sources = [resolver.bundleID: resolver] + let (bundle, context) = try loadBundle(catalog: catalog, configuration: configuration) XCTAssert(context.problems.isEmpty, "Unexpected problems:\n\(context.problems.map(\.diagnostic.summary).joined(separator: "\n"))") diff --git a/Tests/SwiftDocCTests/Infrastructure/InheritIntroducedAvailabilityTests.swift b/Tests/SwiftDocCTests/Infrastructure/InheritIntroducedAvailabilityTests.swift index 5c7e3570c8..fdf3147144 100644 --- a/Tests/SwiftDocCTests/Infrastructure/InheritIntroducedAvailabilityTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/InheritIntroducedAvailabilityTests.swift @@ -39,7 +39,7 @@ class InheritIntroducedAvailabilityTests: XCTestCase { override func setUpWithError() throws { try super.setUpWithError() - (testBundle, context) = try testBundleAndContext(named: "TestBundle") + (testBundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") } override func tearDown() { diff --git a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift index 677e698954..b982628ed6 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PathHierarchyTests.swift @@ -1106,8 +1106,8 @@ class PathHierarchyTests: XCTestCase { assertParsedPathComponents("/documentation/MixedFramework/MyEnum", [("documentation", nil), ("MixedFramework", nil), ("MyEnum", nil)]) } - func testTestBundle() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + func testUnrealisticMixedTestCatalog() throws { + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let linkResolver = try XCTUnwrap(context.linkResolver.localResolver) let tree = try XCTUnwrap(linkResolver.pathHierarchy) @@ -2410,7 +2410,7 @@ class PathHierarchyTests: XCTestCase { let containerID = "some-container-symbol-id" let memberID = "some-member-symbol-id" - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ Folder(name: "clang", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -2440,8 +2440,7 @@ class PathHierarchyTests: XCTestCase { ]) ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let tree = context.linkResolver.localResolver.pathHierarchy let paths = tree.caseInsensitiveDisambiguatedPaths() @@ -2453,7 +2452,7 @@ class PathHierarchyTests: XCTestCase { let containerID = "some-container-symbol-id" let memberID = "some-member-symbol-id" - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ Folder(name: "clang", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -2483,8 +2482,7 @@ class PathHierarchyTests: XCTestCase { ]) ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let tree = context.linkResolver.localResolver.pathHierarchy let paths = tree.caseInsensitiveDisambiguatedPaths() @@ -2496,7 +2494,7 @@ class PathHierarchyTests: XCTestCase { let containerID = "some-container-symbol-id" let memberID = "some-member-symbol-id" - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ Folder(name: "clang", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -2524,8 +2522,7 @@ class PathHierarchyTests: XCTestCase { ]) ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let tree = context.linkResolver.localResolver.pathHierarchy let paths = tree.caseInsensitiveDisambiguatedPaths() @@ -2537,7 +2534,7 @@ class PathHierarchyTests: XCTestCase { let containerID = "some-container-symbol-id" let memberID = "some-member-symbol-id" - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ Folder(name: "clang", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -2567,8 +2564,7 @@ class PathHierarchyTests: XCTestCase { ]) ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let tree = context.linkResolver.localResolver.pathHierarchy let paths = tree.caseInsensitiveDisambiguatedPaths() @@ -2581,7 +2577,7 @@ class PathHierarchyTests: XCTestCase { let otherID = "some-other-symbol-id" let memberID = "some-member-symbol-id" - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", symbols: [ @@ -2595,8 +2591,7 @@ class PathHierarchyTests: XCTestCase { )) ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let tree = context.linkResolver.localResolver.pathHierarchy let paths = tree.caseInsensitiveDisambiguatedPaths(includeDisambiguationForUnambiguousChildren: true) @@ -2606,7 +2601,7 @@ class PathHierarchyTests: XCTestCase { } func testLinkToTopicSection() throws { - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", symbols: [ @@ -2650,8 +2645,7 @@ class PathHierarchyTests: XCTestCase { """) ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let tree = context.linkResolver.localResolver.pathHierarchy let moduleID = try tree.find(path: "/ModuleName", onlyFindSymbols: true) @@ -2705,7 +2699,7 @@ class PathHierarchyTests: XCTestCase { func testModuleAndCollidingTechnologyRootHasPathsForItsSymbols() throws { let symbolID = "some-symbol-id" - let exampleDocumentation = Folder(name: "unit-test.docc", content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", symbols: [ @@ -2725,8 +2719,7 @@ class PathHierarchyTests: XCTestCase { """) ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, _, context) = try loadBundle(from: tempURL) + let (_, context) = try loadBundle(catalog: catalog) let tree = context.linkResolver.localResolver.pathHierarchy let paths = tree.caseInsensitiveDisambiguatedPaths(includeDisambiguationForUnambiguousChildren: true) @@ -2754,12 +2747,12 @@ class PathHierarchyTests: XCTestCase { )) } - let multiPlatform = Folder(name: "unit-test.docc", content: [ + let multiPlatformCatalog = Folder(name: "unit-test.docc", content: [ makeSymbolGraphFile(platformName: "PlatformOne"), makeSymbolGraphFile(platformName: "PlatformTwo"), ]) - let (_, _, context) = try loadBundle(from: createTempFolder(content: [multiPlatform])) + let (_, context) = try loadBundle(catalog: multiPlatformCatalog) let tree = context.linkResolver.localResolver.pathHierarchy let paths = tree.caseInsensitiveDisambiguatedPaths() @@ -2767,10 +2760,10 @@ class PathHierarchyTests: XCTestCase { XCTAssertEqual(paths[defaultImplementationID], "/ModuleName/SomeProtocolName/someProtocolRequirement()-3docm") // Verify that the multi platform paths are the same as the single platform paths - let singlePlatform = Folder(name: "unit-test.docc", content: [ + let singlePlatformCatalog = Folder(name: "unit-test.docc", content: [ makeSymbolGraphFile(platformName: "PlatformOne"), ]) - let (_, _, singlePlatformContext) = try loadBundle(from: createTempFolder(content: [singlePlatform])) + let (_, singlePlatformContext) = try loadBundle(catalog: singlePlatformCatalog) let singlePlatformPaths = singlePlatformContext.linkResolver.localResolver.pathHierarchy.caseInsensitiveDisambiguatedPaths() XCTAssertEqual(paths[protocolRequirementID], singlePlatformPaths[protocolRequirementID]) XCTAssertEqual(paths[defaultImplementationID], singlePlatformPaths[defaultImplementationID]) @@ -3569,7 +3562,7 @@ class PathHierarchyTests: XCTestCase { """), ]) - let (_, _, context) = try loadBundle(from: createTempFolder(content: [catalog])) + let (_, context) = try loadBundle(catalog: catalog) let tree = context.linkResolver.localResolver.pathHierarchy let rootIdentifier = try XCTUnwrap(tree.modules.first?.identifier) diff --git a/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift b/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift index 96fe55b4a3..7f36a61e9a 100644 --- a/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/PresentationURLGeneratorTests.swift @@ -14,7 +14,7 @@ import Foundation class PresentationURLGeneratorTests: XCTestCase { func testInternalURLs() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let generator = PresentationURLGenerator(context: context, baseURL: URL(string: "https://host:1024/webPrefix")!) // Test resolved tutorial reference diff --git a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift index 1cef3e3a15..ddb663ec37 100644 --- a/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/ReferenceResolverTests.swift @@ -24,7 +24,7 @@ class ReferenceResolverTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let intro = Intro(from: directive, source: nil, for: bundle, in: context, problems: &problems)! @@ -43,7 +43,7 @@ class ReferenceResolverTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let contentAndMedia = ContentAndMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems)! @@ -60,7 +60,7 @@ class ReferenceResolverTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let intro = Intro(from: directive, source: nil, for: bundle, in: context, problems: &problems)! @@ -78,7 +78,7 @@ class ReferenceResolverTests: XCTestCase { // Tests all reference syntax formats to a child symbol func testReferencesToChildFromFramework() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Article that curates `SideClass` try """ # ``SideKit`` @@ -111,7 +111,7 @@ class ReferenceResolverTests: XCTestCase { // Test relative paths to non-child symbol func testReferencesToGrandChildFromFramework() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Article that curates `SideClass` try """ # ``SideKit`` @@ -137,7 +137,7 @@ class ReferenceResolverTests: XCTestCase { // Test references to a sibling symbol func testReferencesToSiblingFromFramework() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Article that curates `SideClass` try """ # ``SideKit/SideClass/myFunction()`` @@ -163,7 +163,7 @@ class ReferenceResolverTests: XCTestCase { // Test references to symbols in root paths func testReferencesToTutorial() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Article that curates `SideClass` try """ # ``SideKit/SideClass/myFunction()`` @@ -189,7 +189,7 @@ class ReferenceResolverTests: XCTestCase { // Test references to technology pages func testReferencesToTechnologyPages() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Article that curates `SideClass` try """ # ``SideKit/SideClass/myFunction()`` @@ -214,7 +214,7 @@ class ReferenceResolverTests: XCTestCase { // Test external references func testExternalReferencesConsiderBundleIdentifier() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Article that curates `SideClass` try """ # ``SideKit/SideClass/myFunction()`` @@ -321,7 +321,7 @@ class ReferenceResolverTests: XCTestCase { """ // TestBundle has more than one module, so automatic registration and curation won't happen - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in referencingArticleURL = root.appendingPathComponent("article.md") try source.write(to: referencingArticleURL, atomically: true, encoding: .utf8) @@ -560,7 +560,7 @@ class ReferenceResolverTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let chapter = try XCTUnwrap(Chapter(from: directive, source: nil, for: bundle, in: context, problems: &problems)) @@ -580,7 +580,7 @@ class ReferenceResolverTests: XCTestCase { Discussion link to ``SideKit``. """ - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() let document = Document(parsing: source, options: [.parseBlockDirectives, .parseSymbolLinks]) let article = try XCTUnwrap(Article(markup: document, metadata: nil, redirects: nil, options: [:])) @@ -612,7 +612,7 @@ class ReferenceResolverTests: XCTestCase { } func testForwardsSymbolPropertiesThatAreUnmodifiedDuringLinkResolution() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var resolver = ReferenceResolver(context: context, bundle: bundle) diff --git a/Tests/SwiftDocCTests/Infrastructure/Symbol Link Resolution/AbsoluteSymbolLinkTests.swift b/Tests/SwiftDocCTests/Infrastructure/Symbol Link Resolution/AbsoluteSymbolLinkTests.swift index bd34e077e9..47ef5ef172 100644 --- a/Tests/SwiftDocCTests/Infrastructure/Symbol Link Resolution/AbsoluteSymbolLinkTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/Symbol Link Resolution/AbsoluteSymbolLinkTests.swift @@ -223,7 +223,7 @@ class AbsoluteSymbolLinkTests: XCTestCase { } func testCompileSymbolGraphAndValidateLinks() throws { - let (_, _, context) = try testBundleAndContext(named: "TestBundle") + let (_, _, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let expectedDescriptions = [ // doc://org.swift.docc.example/documentation/FillIntroduced: """ diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphLoaderTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphLoaderTests.swift index 481007c7e7..4a97349758 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphLoaderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphLoaderTests.swift @@ -119,7 +119,7 @@ class SymbolGraphLoaderTests: XCTestCase { let tempURL = try createTemporaryDirectory() let symbolGraphSourceURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json") var symbolGraph = try JSONDecoder().decode(SymbolGraph.self, from: try Data(contentsOf: symbolGraphSourceURL)) @@ -148,7 +148,7 @@ class SymbolGraphLoaderTests: XCTestCase { /// Tests if we detect correctly a Mac Catalyst graph func testLoadingiOSAndCatalystGraphs() throws { func testBundleCopy(iOSSymbolGraphName: String, catalystSymbolGraphName: String) throws -> (URL, DocumentationBundle, DocumentationContext) { - return try testBundleAndContext(copying: "TestBundle", configureBundle: { bundleURL in + return try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", configureBundle: { bundleURL in // Create an iOS symbol graph file let iOSGraphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") let renamediOSGraphURL = bundleURL.appendingPathComponent(iOSSymbolGraphName) @@ -214,7 +214,7 @@ class SymbolGraphLoaderTests: XCTestCase { // Tests if main and bystanders graphs are loaded func testLoadingModuleBystanderExtensions() throws { - let (_, bundle, _) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [:]) { url in + let (_, bundle, _) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [:]) { url in let bystanderSymbolGraphURL = Bundle.module.url( forResource: "MyKit@Foundation@_MyKit_Foundation.symbols", withExtension: "json", subdirectory: "Test Resources")! try FileManager.default.copyItem(at: bystanderSymbolGraphURL, to: url.appendingPathComponent("MyKit@Foundation@_MyKit_Foundation.symbols.json")) diff --git a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift index 52c1ff8c11..784c6d3199 100644 --- a/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift +++ b/Tests/SwiftDocCTests/Infrastructure/SymbolGraph/SymbolGraphRelationshipsBuilderTests.swift @@ -24,13 +24,13 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { let sourceIdentifier = SymbolGraph.Symbol.Identifier(precise: "A", interfaceLanguage: SourceLanguage.swift.id) let targetIdentifier = SymbolGraph.Symbol.Identifier(precise: "B", interfaceLanguage: SourceLanguage.swift.id) - let sourceRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/A", sourceLanguage: .swift) - let targetRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/B", sourceLanguage: .swift) + let sourceRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SomeModuleName/A", sourceLanguage: .swift) + let targetRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SomeModuleName/B", sourceLanguage: .swift) - let moduleRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let moduleRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SomeModuleName", sourceLanguage: .swift) - let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: sourceType, mixins: [:]) - let targetSymbol = SymbolGraph.Symbol(identifier: targetIdentifier, names: SymbolGraph.Symbol.Names(title: "B", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "B"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: targetType, mixins: [:]) + let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["SomeModuleName", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: sourceType, mixins: [:]) + let targetSymbol = SymbolGraph.Symbol(identifier: targetIdentifier, names: SymbolGraph.Symbol.Names(title: "B", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["SomeModuleName", "B"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: targetType, mixins: [:]) let engine = DiagnosticEngine() documentationCache.add( @@ -51,7 +51,7 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { private let swiftSelector = UnifiedSymbolGraph.Selector(interfaceLanguage: "swift", platform: nil) func testImplementsRelationship() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var documentationCache = DocumentationContext.ContentCache() let engine = DiagnosticEngine() @@ -65,7 +65,7 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { } func testConformsRelationship() throws { - let bundle = try testBundle(named: "TestBundle") + let (bundle, _) = try testBundleAndContext() var documentationCache = DocumentationContext.ContentCache() let engine = DiagnosticEngine() @@ -81,7 +81,7 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { XCTFail("Conforms to group not added") return } - XCTAssertEqual(conformsTo.destinations.first?.url?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/B") + XCTAssertEqual(conformsTo.destinations.first?.url?.absoluteString, "doc://com.example.test/documentation/SomeModuleName/B") // Test default conformance was added guard let conforming = (documentationCache["B"]!.semantic as! Symbol).relationships.groups.first(where: { group -> Bool in @@ -90,11 +90,11 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { XCTFail("Conforming types not added") return } - XCTAssertEqual(conforming.destinations.first?.url?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/A") + XCTAssertEqual(conforming.destinations.first?.url?.absoluteString, "doc://com.example.test/documentation/SomeModuleName/A") } func testInheritanceRelationship() throws { - let bundle = try testBundle(named: "TestBundle") + let (bundle, _) = try testBundleAndContext() var documentationCache = DocumentationContext.ContentCache() let engine = DiagnosticEngine() @@ -110,7 +110,7 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { XCTFail("Inherits from not added") return } - XCTAssertEqual(inherits.destinations.first?.url?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/B") + XCTAssertEqual(inherits.destinations.first?.url?.absoluteString, "doc://com.example.test/documentation/SomeModuleName/B") // Test descendants were added guard let inherited = (documentationCache["B"]!.semantic as! Symbol).relationships.groups.first(where: { group -> Bool in @@ -119,21 +119,21 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { XCTFail("Inherited by types not added") return } - XCTAssertEqual(inherited.destinations.first?.url?.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/A") + XCTAssertEqual(inherited.destinations.first?.url?.absoluteString, "doc://com.example.test/documentation/SomeModuleName/A") } func testInheritanceRelationshipFromOtherFramework() throws { - let bundle = try testBundle(named: "TestBundle") + let (bundle, _) = try testBundleAndContext() var documentationCache = DocumentationContext.ContentCache() let engine = DiagnosticEngine() let sourceIdentifier = SymbolGraph.Symbol.Identifier(precise: "A", interfaceLanguage: SourceLanguage.swift.id) let targetIdentifier = SymbolGraph.Symbol.Identifier(precise: "B", interfaceLanguage: SourceLanguage.swift.id) - let sourceRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/A", sourceLanguage: .swift) - let moduleRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift) + let sourceRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SomeModuleName/A", sourceLanguage: .swift) + let moduleRef = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SomeModuleName", sourceLanguage: .swift) - let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["MyKit", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: SymbolGraph.Symbol.Kind(parsedIdentifier: .class, displayName: "Class"), mixins: [:]) + let sourceSymbol = SymbolGraph.Symbol(identifier: sourceIdentifier, names: SymbolGraph.Symbol.Names(title: "A", navigator: nil, subHeading: nil, prose: nil), pathComponents: ["SomeModuleName", "A"], docComment: nil, accessLevel: .init(rawValue: "public"), kind: SymbolGraph.Symbol.Kind(parsedIdentifier: .class, displayName: "Class"), mixins: [:]) documentationCache.add( DocumentationNode(reference: sourceRef, symbol: sourceSymbol, platformName: "macOS", moduleReference: moduleRef, article: nil, engine: engine), @@ -160,7 +160,7 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { } func testRequirementRelationship() throws { - let bundle = try testBundle(named: "TestBundle") + let (bundle, _) = try testBundleAndContext() var documentationCache = DocumentationContext.ContentCache() let engine = DiagnosticEngine() @@ -174,7 +174,7 @@ class SymbolGraphRelationshipsBuilderTests: XCTestCase { } func testOptionalRequirementRelationship() throws { - let bundle = try testBundle(named: "TestBundle") + let (bundle, _) = try testBundleAndContext() var documentationCache = DocumentationContext.ContentCache() let engine = DiagnosticEngine() diff --git a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift index 23bf128ca1..409a160cdf 100644 --- a/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift +++ b/Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift @@ -151,7 +151,7 @@ class ExternalLinkableTests: XCTestCase { } func testSymbolSummaries() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let converter = DocumentationNodeConverter(bundle: bundle, context: context) do { let symbolReference = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) @@ -313,7 +313,7 @@ class ExternalLinkableTests: XCTestCase { } func testTopicImageReferences() throws { - let (url, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (url, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in let extensionFile = """ # ``MyKit/MyClass/myFunction()`` diff --git a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift index 69cb2b70eb..97a6b6bfad 100644 --- a/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift +++ b/Tests/SwiftDocCTests/Model/ParametersAndReturnValidatorTests.swift @@ -296,12 +296,10 @@ class ParametersAndReturnValidatorTests: XCTestCase { symbolGraph.symbols["symbol-id"]?.mixins[SymbolGraph.Symbol.FunctionSignature.mixinKey] = nil - let url = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) ]) - let (_, _, context) = try loadBundle(from: url) + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.count, 0) } @@ -313,12 +311,10 @@ class ParametersAndReturnValidatorTests: XCTestCase { No parameters section """) - let url = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) ]) - let (_, _, context) = try loadBundle(from: url) + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.count, 0) } @@ -331,12 +327,10 @@ class ParametersAndReturnValidatorTests: XCTestCase { - secondParameter: One description - thirdParameter: Another description """) - let url = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) ]) - let (_, _, context) = try loadBundle(from: url) + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.count, 2) let endOfParameterSectionLocation = SourceLocation(line: start.line + 5, column: start.character + 40, source: symbolURL) @@ -372,12 +366,10 @@ class ParametersAndReturnValidatorTests: XCTestCase { - Parameter secondParameter: One description - Parameter thirdParameter: Another description """) - let url = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "ModuleName.symbols.json", content: symbolGraph) ]) - let (_, _, context) = try loadBundle(from: url) + let (_, context) = try loadBundle(catalog: catalog) XCTAssertEqual(context.problems.count, 2) let endOfParameterSectionLocation = SourceLocation(line: start.line + 4, column: start.character + 48, source: symbolURL) @@ -407,7 +399,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { } func testFunctionWithOnlyErrorParameter() throws { - let url = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ Folder(name: "swift", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( @@ -430,8 +422,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { )) ]) ]) - ]) - let (_, bundle, context) = try loadBundle(from: url) + let (bundle, context) = try loadBundle(catalog: catalog) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") @@ -450,7 +441,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { } func testFunctionWithDifferentSignaturesOnDifferentPlatforms() throws { - let url = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ // One parameter, void return JSONFile(name: "Platform1-ModuleName.symbols.json", content: makeSymbolGraph( @@ -487,8 +478,8 @@ class ParametersAndReturnValidatorTests: XCTestCase { - Returns: Some description of the return value that is only available on platform 3. """) ]) - ]) - let (_, bundle, context) = try loadBundle(from: url) + + let (bundle, context) = try loadBundle(catalog: catalog) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") @@ -506,7 +497,7 @@ class ParametersAndReturnValidatorTests: XCTestCase { } func testFunctionWithErrorParameterButVoidType() throws { - let url = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ Folder(name: "swift", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( @@ -529,8 +520,8 @@ class ParametersAndReturnValidatorTests: XCTestCase { )) ]) ]) - ]) - let (_, bundle, context) = try loadBundle(from: url) + + let (bundle, context) = try loadBundle(catalog: catalog) XCTAssert(context.problems.isEmpty, "Unexpected problems: \(context.problems.map(\.diagnostic.summary))") diff --git a/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift b/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift index bb3e25fc22..e4d2ec5a9b 100644 --- a/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderContentMetadataTests.swift @@ -67,7 +67,7 @@ class RenderContentMetadataTests: XCTestCase { } func testRenderingTables() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ @@ -108,7 +108,7 @@ class RenderContentMetadataTests: XCTestCase { } func testRenderingTableSpans() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ @@ -161,7 +161,7 @@ class RenderContentMetadataTests: XCTestCase { } func testRenderingTableColumnAlignments() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ @@ -203,7 +203,7 @@ class RenderContentMetadataTests: XCTestCase { /// Verifies that a table with `nil` alignments and a table with all-unset alignments still compare as equal. func testRenderedTableEquality() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ @@ -229,7 +229,7 @@ class RenderContentMetadataTests: XCTestCase { /// Verifies that two tables with otherwise-identical contents but different column alignments compare as unequal. func testRenderedTableInequality() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let decodedTableWithUnsetColumns: RenderBlockContent.Table @@ -276,7 +276,7 @@ class RenderContentMetadataTests: XCTestCase { } func testStrikethrough() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ @@ -299,7 +299,7 @@ class RenderContentMetadataTests: XCTestCase { } func testHeadingAnchorShouldBeEncoded() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ diff --git a/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift b/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift index 6294e043bb..d8ec9f7792 100644 --- a/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderHierarchyTranslatorTests.swift @@ -13,7 +13,7 @@ import XCTest class RenderHierarchyTranslatorTests: XCTestCase { func test() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let technologyReference = ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift) var translator = RenderHierarchyTranslator(context: context, bundle: bundle) @@ -89,7 +89,7 @@ class RenderHierarchyTranslatorTests: XCTestCase { func testMultiplePaths() throws { // Curate "TestTutorial" under MyKit as well as TechnologyX. - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in let myKitURL = root.appendingPathComponent("documentation/mykit.md") let text = try String(contentsOf: myKitURL).replacingOccurrences(of: "## Topics", with: """ ## Topics diff --git a/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift b/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift index 34a1587405..66795478a1 100644 --- a/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderNodeDiffingBundleTests.swift @@ -12,7 +12,7 @@ import XCTest @testable import SwiftDocC class RenderNodeDiffingBundleTests: XCTestCase { - let testBundleName = "TestBundle" + let testBundleName = "LegacyBundle_DoNotUseInNewTests" let testBundleID: DocumentationBundle.Identifier = "org.swift.docc.example" func testDiffSymbolFromBundleWithDiscussionSectionRemoved() throws { diff --git a/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift b/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift index 523a02f18a..5c61beb83d 100644 --- a/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift +++ b/Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift @@ -92,7 +92,7 @@ class RenderNodeSerializationTests: XCTestCase { } func testBundleRoundTrip() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { @@ -115,7 +115,7 @@ class RenderNodeSerializationTests: XCTestCase { } func testTutorialArticleRoundTrip() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) guard let articleDirective = node.markup as? BlockDirective else { @@ -140,7 +140,7 @@ class RenderNodeSerializationTests: XCTestCase { func testAssetReferenceDictionary() throws { typealias JSONDictionary = [String: Any] - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { @@ -192,7 +192,7 @@ class RenderNodeSerializationTests: XCTestCase { } func testDiffAvailability() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) guard let articleDirective = node.markup as? BlockDirective else { diff --git a/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift b/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift index 9b7db13ff5..d02e76056a 100644 --- a/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift +++ b/Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift @@ -16,7 +16,7 @@ import SwiftDocCTestUtilities class SemaToRenderNodeTests: XCTestCase { func testCompileTutorial() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorial", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { @@ -401,7 +401,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testTutorialBackgroundComesFromImageOrVideoPoster() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") func assertTutorialWithPath(_ tutorialPath: String, hasBackground backgroundIdentifier: String) throws { let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: tutorialPath, sourceLanguage: .swift)) @@ -431,7 +431,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testCompileTutorialArticle() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TestTutorialArticle", sourceLanguage: .swift)) let article = node.semantic as! TutorialArticle @@ -492,12 +492,12 @@ class SemaToRenderNodeTests: XCTestCase { } func testCompileOverviewWithNoVolumes() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") try assertCompileOverviewWithNoVolumes(bundle: bundle, context: context) } func testCompileOverviewWithEmptyChapter() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try """ @Tutorials(name: "Technology X") { @Intro(title: "Technology X") { @@ -718,7 +718,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testCompileOverviewWithVolumes() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in let overviewURL = root.appendingPathComponent("TestOverview.tutorial") let text = """ @Tutorials(name: "Technology X") { @@ -927,7 +927,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testCompileSymbol() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in // Remove the SideClass sub heading to match the expectations of this test let graphURL = url.appendingPathComponent("sidekit.symbols.json") var graph = try JSONDecoder().decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) @@ -1224,7 +1224,7 @@ class SemaToRenderNodeTests: XCTestCase { } let testBundleURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let (_, bundle, context) = try loadBundle( from: testBundleURL, externalResolvers: ["com.test.external": TestReferenceResolver()], @@ -1325,7 +1325,7 @@ class SemaToRenderNodeTests: XCTestCase { // Check for constraints in render node - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol @@ -1378,7 +1378,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testRenderConditionalConstraintsOnConformingType() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -1400,7 +1400,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testRenderConditionalConstraintsOnProtocol() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -1422,7 +1422,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testRenderReferenceResolving() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents @@ -1487,7 +1487,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testAvailabilityMetadata() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) // Compile docs and verify contents @@ -1535,7 +1535,7 @@ class SemaToRenderNodeTests: XCTestCase { // Override with both a low and a high value for version in [SymbolGraph.SemanticVersion(major: 1, minor: 1, patch: 1), SymbolGraph.SemanticVersion(major: 99, minor: 99, patch: 99)] { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], configureBundle: { url in // Duplicate the symbol graph let myKitURL = url.appendingPathComponent("mykit-iOS.symbols.json") let myClassUSR = "s:5MyKit0A5ClassC" @@ -1587,7 +1587,7 @@ class SemaToRenderNodeTests: XCTestCase { } func testMediaReferencesWithSpaces() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/Test-Bundle/TutorialMediaWithSpaces", sourceLanguage: .swift)) guard let tutorialDirective = node.markup as? BlockDirective else { @@ -1648,7 +1648,7 @@ Document @1:1-11:19 """, markup.debugDescription(options: .printSourceLocations)) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/TestTutorial", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ @@ -1690,7 +1690,7 @@ Document """, markup.debugDescription()) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var contentTranslator = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/TestTutorial", sourceLanguage: .swift)) let renderContent = try XCTUnwrap(markup.children.reduce(into: [], { result, item in result.append(contentsOf: contentTranslator.visit(item))}) as? [RenderBlockContent]) let expectedContent: [RenderBlockContent] = [ @@ -1715,14 +1715,14 @@ Document let document = Document(parsing: markupSource, options: []) let node = DocumentationNode(reference: ResolvedTopicReference(bundleID: "org.swift.docc", path: "/blah", sourceLanguage: .swift), kind: .article, sourceLanguage: .swift, name: .conceptual(title: "Title"), markup: document, semantic: Semantic()) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) XCTAssertNotNil(translator.visit(MarkupContainer(document.children))) } func testCompileSymbolMetadata() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift)) // Compile docs and verify contents @@ -1819,11 +1819,10 @@ Document ) } - private func renderNodeForArticleInTestBundle(content: String) throws -> RenderNode { // Overwrite the article so we can test the article eyebrow for articles without task groups let sourceURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let targetURL = try createTemporaryDirectory().appendingPathComponent("test.docc") try FileManager.default.copyItem(at: sourceURL, to: targetURL) @@ -1902,13 +1901,27 @@ Document /// Verifies we emit the correct warning for external links in topic task groups. func testWarnForExternalLinksInTopicTaskGroups() throws { - let (_, context) = try testBundleAndContext(named: "TestBundle") - // Verify we warn for the external link planted in mykit.md + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName", symbols: [ + ])), + + TextFile(name: "Extension.md", utf8Content: """ + # ``SomeModuleName`` + + Abstract. + + ## Topics + + - [Some description](https://example.com/link) + """), + ]) + + let (_, context) = try loadBundle(catalog: catalog) + XCTAssertEqual(context.problems.filter({ $0.diagnostic.identifier == "org.swift.docc.InvalidDocumentationLink" }).count, 1) XCTAssertNotNil(context.problems.first(where: { problem -> Bool in - return problem.diagnostic.identifier == "org.swift.docc.InvalidDocumentationLink" - && problem.diagnostic.summary.contains("https://external.com/link") + && problem.diagnostic.summary.contains("https://example.com/link") })) } @@ -1922,7 +1935,7 @@ Document } configuration.externalMetadata.currentPlatforms = currentPlatforms - let (_, bundle, context) = try testBundleAndContext(named: "TestBundle", configuration: configuration) + let (_, bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests", configuration: configuration) let reference = ResolvedTopicReference(bundleID: bundle.id, path: referencePath, sourceLanguage: .swift) return (bundle, context, reference) @@ -2091,7 +2104,7 @@ Document } func testRendersDeprecatedViolator() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Make the referenced symbol deprecated do { @@ -2114,7 +2127,7 @@ Document } func testDoesNotRenderDeprecatedViolator() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Make the referenced symbol deprecated do { @@ -2138,7 +2151,7 @@ Document } func testRendersDeprecatedViolatorForUnconditionallyDeprecatedReference() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Make the referenced symbol deprecated do { @@ -2164,7 +2177,7 @@ Document func testRenderMetadataFragments() throws { // Check for fragments in metadata in render node - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol @@ -2184,7 +2197,7 @@ Document } func testRenderMetadataExtendedModule() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = try XCTUnwrap(node.semantic as? Symbol) @@ -2195,7 +2208,7 @@ Document } func testDefaultImplementations() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Verify that the render reference to a required symbol includes the 'required' key and the number of default implementations provided. do { @@ -2228,7 +2241,7 @@ Document } func testDefaultImplementationsNotListedInTopics() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Verify that a required symbol does not include default implementations in Topics groups do { @@ -2246,7 +2259,7 @@ Document func testNoStringMetadata() throws { // Check for fragments in metadata in render node - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol @@ -2275,7 +2288,7 @@ Document func testRenderDeclarations() throws { // Check for fragments in metadata in render node - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol @@ -2294,7 +2307,7 @@ Document func testDocumentationRenderReferenceRoles() throws { // Check for fragments in metadata in render node - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol @@ -2314,7 +2327,7 @@ Document func testTutorialsRenderReferenceRoles() throws { // Check for fragments in metadata in render node - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/tutorials/TestOverview", sourceLanguage: .swift)) let symbol = node.semantic as! TutorialTableOfContents @@ -2333,7 +2346,7 @@ Document func testRemovingTrailingNewLinesInDeclaration() throws { // Check for fragments in metadata in render node - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol @@ -2356,7 +2369,7 @@ Document func testRenderManualSeeAlsoInArticles() throws { // Check for fragments in metadata in render node - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/Test-Bundle/article", sourceLanguage: .swift)) let article = node.semantic as! Article @@ -2379,7 +2392,7 @@ Document func testSafeSectionAnchorNames() throws { // Check that heading's anchor was safe-ified - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyClass/myFunction()", sourceLanguage: .swift)) let symbol = node.semantic as! Symbol var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) @@ -2399,7 +2412,7 @@ Document } func testDuplicateNavigatorTitleIsRemoved() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) @@ -2415,7 +2428,7 @@ Document } func testNonDuplicateNavigatorTitleIsRendered() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/MyProtocol", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) @@ -2458,7 +2471,7 @@ Document ] func testBareTechnology() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try """ @Tutorials(name: "<#text#>") { @Intro(title: "<#text#>") { @@ -2513,7 +2526,7 @@ Document } func testBareTutorial() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try """ @Tutorial(time: <#number#>, projectFiles: <#.zip#>) { @Intro(title: "<#text#>") { @@ -2591,7 +2604,7 @@ Document func testRenderAsides() throws { let asidesSGFURL = Bundle.module.url( forResource: "Asides.symbols", withExtension: "json", subdirectory: "Test Resources")! - let (bundleURL, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { url in + let (bundleURL, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { url in try? FileManager.default.copyItem(at: asidesSGFURL, to: url.appendingPathComponent("Asides.symbols.json")) } defer { @@ -2619,7 +2632,7 @@ Document /// Tests parsing origin data from symbol graph. func testOriginMetadata() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let myFuncReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/Element/inherited()", sourceLanguage: .swift) let node = try context.entity(with: myFuncReference) @@ -2634,9 +2647,9 @@ Document /// Tests that we inherit docs by default from within the same module. func testDocInheritanceInsideModule() throws { let sgURL = Bundle.module.url( - forResource: "TestBundle.docc/sidekit.symbols", withExtension: "json", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests.docc/sidekit.symbols", withExtension: "json", subdirectory: "Test Bundles")! - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in // Replace the out-of-bundle origin with a symbol from the same bundle. try String(contentsOf: sgURL) .replacingOccurrences(of: #"identifier" : "s:OriginalUSR"#, with: #"identifier" : "s:5MyKit0A5MyProtocol0Afunc()"#) @@ -2660,9 +2673,9 @@ Document /// Tests that we don't inherit docs by default from within the same bundle but not module. func testDocInheritanceInsideBundleButNotModule() throws { let sgURL = Bundle.module.url( - forResource: "TestBundle.docc/sidekit.symbols", withExtension: "json", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests.docc/sidekit.symbols", withExtension: "json", subdirectory: "Test Bundles")! - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in // Replace the out-of-bundle origin with a symbol from the same bundle but // from the MyKit module. try String(contentsOf: sgURL) @@ -2685,7 +2698,7 @@ Document } /// Tests that we generated an automatic abstract and remove source docs. func testDisabledDocInheritance() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") // Verify that the inherited docs which should be ignored are not reference resolved. // Verify inherited docs are reference resolved and their problems are recorded. @@ -2716,7 +2729,7 @@ Document /// Tests doc extensions are matched to inherited symbols func testInheritedSymbolDocExtension() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in try? """ # ``SideKit/SideClass/Element/inherited()`` Doc extension abstract. @@ -2857,9 +2870,9 @@ Document ] for testData in testData { - let sgURL = Bundle.module.url(forResource: "TestBundle.docc/sidekit.symbols", withExtension: "json", subdirectory: "Test Bundles")! + let sgURL = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests.docc/sidekit.symbols", withExtension: "json", subdirectory: "Test Bundles")! - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in // Replace the out-of-bundle origin with a symbol from the same bundle but // from the MyKit module. var graph = try JSONDecoder().decode(SymbolGraph.self, from: Data(contentsOf: sgURL)) @@ -2888,7 +2901,7 @@ Document /// Tests that we inherit docs when the feature is enabled. func testEnabledDocInheritance() throws { let bundleURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! var configuration = DocumentationContext.Configuration() configuration.externalMetadata.inheritDocs = true @@ -2933,7 +2946,7 @@ Document // Verifies that undocumented symbol gets a nil abstract. func testNonDocumentedSymbolNilAbstract() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/MyKit/globalFunction(_:considering:)", sourceLanguage: .swift) let node = try context.entity(with: reference) @@ -3041,7 +3054,7 @@ Document /// Tests links to symbols that have deprecation summary in markdown appear deprecated. func testLinkToDeprecatedSymbolViaDirectiveIsDeprecated() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in try """ # ``MyKit/MyProtocol`` @DeprecationSummary { @@ -3061,7 +3074,7 @@ Document } func testCustomSymbolDisplayNames() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in try """ # ``MyKit`` @@ -3191,7 +3204,7 @@ Document } func testVisitTutorialMediaWithoutExtension() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try """ @Tutorials(name: "Technology X") { @Intro(title: "Technology X") { @@ -3238,7 +3251,7 @@ Document func testTopicsSectionWithAnonymousTopicGroup() throws { let (_, bundle, context) = try testBundleAndContext( - copying: "TestBundle", + copying: "LegacyBundle_DoNotUseInNewTests", configureBundle: { url in try """ # Article @@ -3283,26 +3296,30 @@ Document } func testTopicsSectionWithSingleAnonymousTopicGroup() throws { - let (_, bundle, context) = try testBundleAndContext( - copying: "TestBundle", - configureBundle: { url in - try """ - # Article - - Abstract. - - ## Topics - - - ``MyKit/MyProtocol`` - - ``MyKit/MyClass`` - - """.write(to: url.appendingPathComponent("article.md"), atomically: true, encoding: .utf8) - } - ) + let catalog = Folder(name: "unit-test.docc", content: [ + JSONFile(name: "SomeModuleName.symbols.json", content: makeSymbolGraph(moduleName: "SomeModuleName", symbols: [ + makeSymbol(id: "some-class-id", kind: .class, pathComponents: ["SomeClass"]), + makeSymbol(id: "some-protocol-id", kind: .protocol, pathComponents: ["SomeProtocol"]), + ])), + + TextFile(name: "Article.md", utf8Content: """ + # Article + + Abstract. + + ## Topics + + - ``/SomeModuleName/SomeProtocol`` + - ``/SomeModuleName/SomeClass`` + """), + ]) + + let (bundle, context) = try loadBundle(catalog: catalog) + let articleReference = ResolvedTopicReference( bundleID: bundle.id, - path: "/documentation/Test-Bundle/article", + path: "/documentation/unit-test/Article", sourceLanguage: .swift ) @@ -3317,8 +3334,8 @@ Document }, [ nil, - "doc://org.swift.docc.example/documentation/MyKit/MyProtocol", - "doc://org.swift.docc.example/documentation/MyKit/MyClass", + "doc://unit-test/documentation/SomeModuleName/SomeProtocol", + "doc://unit-test/documentation/SomeModuleName/SomeClass", ] ) } diff --git a/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift b/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift index 4da3267fd6..2ce82d8703 100644 --- a/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift +++ b/Tests/SwiftDocCTests/Rendering/AutomaticSeeAlsoTests.swift @@ -18,7 +18,7 @@ class AutomaticSeeAlsoTests: XCTestCase { /// Test that a symbol with no authored See Also and with no curated siblings /// does not have a See Also section. func testNoSeeAlso() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Extension that curates `SideClass` try """ # ``SideKit`` @@ -41,7 +41,7 @@ class AutomaticSeeAlsoTests: XCTestCase { /// Test that a symbol with authored See Also and with no curated siblings /// does include an authored See Also section func testAuthoredSeeAlso() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Extension that curates `SideClass` try """ # ``SideKit`` @@ -77,7 +77,7 @@ class AutomaticSeeAlsoTests: XCTestCase { /// Test that a symbol with authored See Also and with curated siblings /// does include both in See Also with authored section first func testAuthoredAndAutomaticSeeAlso() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Extension that curates `SideClass` try """ # ``SideKit`` @@ -138,7 +138,7 @@ class AutomaticSeeAlsoTests: XCTestCase { // Duplicate of the `testAuthoredAndAutomaticSeeAlso()` test above // but with automatic see also creation disabled func testAuthoredSeeAlsoWithDisabledAutomaticSeeAlso() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Article that curates `SideClass` try """ # ``SideKit`` @@ -201,7 +201,7 @@ class AutomaticSeeAlsoTests: XCTestCase { // Duplicate of the `testAuthoredAndAutomaticSeeAlso()` test above // but with automatic see also creation globally disabled func testAuthoredSeeAlsoWithGloballyDisabledAutomaticSeeAlso() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { root in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { root in /// Article that curates `SideClass` try """ # ``SideKit`` diff --git a/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift b/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift index dce36ead84..0e91aa65e3 100644 --- a/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift +++ b/Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift @@ -17,7 +17,7 @@ class AvailabilityRenderOrderTests: XCTestCase { forResource: "Availability.symbols", withExtension: "json", subdirectory: "Test Resources")! func testSortingAtRenderTime() throws { - let (bundleURL, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { url in + let (bundleURL, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { url in try? FileManager.default.copyItem(at: self.availabilitySGFURL, to: url.appendingPathComponent("Availability.symbols.json")) } defer { diff --git a/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift index 705f5d25be..f517383200 100644 --- a/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/ConstraintsRenderSectionTests.swift @@ -19,7 +19,7 @@ fileprivate let jsonEncoder = JSONEncoder() class ConstraintsRenderSectionTests: XCTestCase { func testSingleConstraint() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { bundleURL in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in // Add constraints to `MyClass` let graphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") var graph = try jsonDecoder.decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) @@ -49,7 +49,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } func testSingleRedundantConstraint() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { bundleURL in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in // Add constraints to `MyClass` let graphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") var graph = try jsonDecoder.decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) @@ -78,7 +78,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } func testSingleRedundantConstraintForLeaves() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { bundleURL in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in // Add constraints to `MyClass` let graphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") var graph = try jsonDecoder.decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) @@ -107,7 +107,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } func testPreservesNonRedundantConstraints() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { bundleURL in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in // Add constraints to `MyClass` let graphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") var graph = try jsonDecoder.decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) @@ -137,7 +137,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } func testGroups2Constraints() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { bundleURL in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in // Add constraints to `MyClass` let graphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") var graph = try jsonDecoder.decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) @@ -167,7 +167,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } func testGroups3Constraints() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { bundleURL in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in // Add constraints to `MyClass` let graphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") var graph = try jsonDecoder.decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) @@ -198,7 +198,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } func testRenderReferences() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { bundleURL in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in // Add constraints to `MyClass` let graphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") var graph = try jsonDecoder.decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) @@ -236,7 +236,7 @@ class ConstraintsRenderSectionTests: XCTestCase { } func testRenderReferencesWithNestedTypeInSelf() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { bundleURL in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { bundleURL in // Add constraints to `MyClass` let graphURL = bundleURL.appendingPathComponent("mykit-iOS.symbols.json") var graph = try jsonDecoder.decode(SymbolGraph.self, from: try Data(contentsOf: graphURL)) diff --git a/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift index ceb28b50f7..b7a887235c 100644 --- a/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DeclarationsRenderSectionTests.swift @@ -168,14 +168,12 @@ class DeclarationsRenderSectionTests: XCTestCase { subdirectory: "Test Resources" )! - let tempURL = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - InfoPlist(displayName: "FancyOverloads", identifier: "com.test.example"), - CopyOfFile(original: symbolGraphFile), - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + InfoPlist(displayName: "FancyOverloads", identifier: "com.test.example"), + CopyOfFile(original: symbolGraphFile), ]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) // Make sure that type decorators like arrays, dictionaries, and optionals are correctly highlighted. do { @@ -331,14 +329,12 @@ class DeclarationsRenderSectionTests: XCTestCase { subdirectory: "Test Resources" )! - let tempURL = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - InfoPlist(displayName: "FancyOverloads", identifier: "com.test.example"), - CopyOfFile(original: symbolGraphFile), - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + InfoPlist(displayName: "FancyOverloads", identifier: "com.test.example"), + CopyOfFile(original: symbolGraphFile), ]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) for hash in ["7eht8", "8p1lo", "858ja"] { let reference = ResolvedTopicReference( @@ -366,14 +362,12 @@ class DeclarationsRenderSectionTests: XCTestCase { subdirectory: "Test Resources" )! - let tempURL = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - InfoPlist(displayName: "ConformanceOverloads", identifier: "com.test.example"), - CopyOfFile(original: symbolGraphFile), - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + InfoPlist(displayName: "ConformanceOverloads", identifier: "com.test.example"), + CopyOfFile(original: symbolGraphFile), ]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) // MyClass // - myFunc() where T: Equatable diff --git a/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift b/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift index 65d81a9644..4f0e01ca41 100644 --- a/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DefaultAvailabilityTests.swift @@ -34,7 +34,7 @@ class DefaultAvailabilityTests: XCTestCase { // Test whether the default availability is loaded from Info.plist and applied during render time func testBundleWithDefaultAvailability() throws { // Copy an Info.plist with default availability - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { (url) in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { (url) in try? FileManager.default.removeItem(at: url.appendingPathComponent("Info.plist")) try? FileManager.default.copyItem(at: self.infoPlistAvailabilityURL, to: url.appendingPathComponent("Info.plist")) @@ -131,7 +131,7 @@ class DefaultAvailabilityTests: XCTestCase { JSONFile(name: "MyKit.symbols.json", content: makeSymbolGraph(moduleName: "MyKit")), ]) - let (_, bundle, context) = try loadBundle(from: createTempFolder(content: [catalog]), configuration: configuration) + let (bundle, context) = try loadBundle(catalog: catalog, configuration: configuration) let reference = try XCTUnwrap(context.soleRootModuleReference, file: file, line: line) // Test whether we: @@ -177,7 +177,7 @@ class DefaultAvailabilityTests: XCTestCase { // Set a beta status for the docs (which would normally be set via command line argument) configuration.externalMetadata.currentPlatforms = ["macOS": PlatformVersion(VersionTriplet(10, 16, 0), beta: true)] - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", configuration: configuration) { (url) in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", configuration: configuration) { (url) in // Copy an Info.plist with default availability of macOS 10.15.1 try? FileManager.default.removeItem(at: url.appendingPathComponent("Info.plist")) try? FileManager.default.copyItem(at: self.infoPlistAvailabilityURL, to: url.appendingPathComponent("Info.plist")) @@ -202,7 +202,7 @@ class DefaultAvailabilityTests: XCTestCase { var configuration = DocumentationContext.Configuration() // Set a beta status for the docs (which would normally be set via command line argument) configuration.externalMetadata.currentPlatforms = ["iOS": PlatformVersion(VersionTriplet(14, 0, 0), beta: true)] - let (_, bundle, context) = try testBundleAndContext(named: "TestBundle", configuration: configuration) + let (_, bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests", configuration: configuration) do { let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit/MyClass/myFunction()", fragment: nil, sourceLanguage: .swift) diff --git a/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift b/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift index 88148d8fa0..9039b2296d 100644 --- a/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DefaultCodeListingSyntaxTests.swift @@ -34,7 +34,7 @@ class DefaultCodeBlockSyntaxTests: XCTestCase { return renderNode.primaryContentSections.first! as! ContentRenderSection } - let (_, bundleWithLanguageDefault, context) = try testBundleAndContext(copying: "TestBundle") + let (_, bundleWithLanguageDefault, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") testBundleWithLanguageDefault = bundleWithLanguageDefault diff --git a/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift b/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift index 6e2121248e..8bede3a237 100644 --- a/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift +++ b/Tests/SwiftDocCTests/Rendering/DeprecationSummaryTests.swift @@ -31,7 +31,7 @@ class DeprecationSummaryTests: XCTestCase { /// This test verifies that a symbol's deprecation summary comes from its sidecar doc /// and it's preferred over the original deprecation note in the code docs. func testAuthoredDeprecatedSummary() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit/SideClass/init()", sourceLanguage: .swift)) // Compile docs and verify contents @@ -44,7 +44,7 @@ class DeprecationSummaryTests: XCTestCase { /// Test for a warning when symbol is not deprecated func testIncorrectlyAuthoredDeprecatedSummary() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], configureBundle: { url in // Add a sidecar file with wrong deprecated summary try """ # ``SideKit/SideClass`` diff --git a/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift b/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift index ffe4a206c6..20010942e4 100644 --- a/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift +++ b/Tests/SwiftDocCTests/Rendering/ExternalLinkTitleTests.swift @@ -24,7 +24,7 @@ public class ExternalLinkTitleTests: XCTestCase { semantic: Semantic()) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: node.reference) let result = translator.visit(MarkupContainer(document.children)) as! [RenderBlockContent] diff --git a/Tests/SwiftDocCTests/Rendering/HeadingAnchorTests.swift b/Tests/SwiftDocCTests/Rendering/HeadingAnchorTests.swift index d204402d16..bee43f167c 100644 --- a/Tests/SwiftDocCTests/Rendering/HeadingAnchorTests.swift +++ b/Tests/SwiftDocCTests/Rendering/HeadingAnchorTests.swift @@ -15,7 +15,7 @@ import SwiftDocCTestUtilities class HeadingAnchorTests: XCTestCase { func testEncodeHeadingAnchor() throws { - let catalogURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ TextFile(name: "Root.md", utf8Content: """ # My root page @@ -33,8 +33,8 @@ class HeadingAnchorTests: XCTestCase { - """), ]) - ]) - let (_, bundle, context) = try loadBundle(from: catalogURL) + + let (bundle, context) = try loadBundle(catalog: catalog) let reference = try XCTUnwrap(context.soleRootModuleReference) let node = try context.entity(with: reference) diff --git a/Tests/SwiftDocCTests/Rendering/LinkTitleResolverTests.swift b/Tests/SwiftDocCTests/Rendering/LinkTitleResolverTests.swift index 42561fffd6..2ec636ac11 100644 --- a/Tests/SwiftDocCTests/Rendering/LinkTitleResolverTests.swift +++ b/Tests/SwiftDocCTests/Rendering/LinkTitleResolverTests.swift @@ -14,7 +14,7 @@ import XCTest class LinkTitleResolverTests: XCTestCase { func testSymbolTitleResolving() throws { - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let resolver = LinkTitleResolver(context: context, source: nil) guard let reference = context.knownIdentifiers.filter({ ref -> Bool in return ref.path.hasSuffix("MyProtocol") diff --git a/Tests/SwiftDocCTests/Rendering/PropertyListDetailsRenderSectionTests.swift b/Tests/SwiftDocCTests/Rendering/PropertyListDetailsRenderSectionTests.swift index 48f6b13e03..3fa1b6c00f 100644 --- a/Tests/SwiftDocCTests/Rendering/PropertyListDetailsRenderSectionTests.swift +++ b/Tests/SwiftDocCTests/Rendering/PropertyListDetailsRenderSectionTests.swift @@ -52,12 +52,10 @@ class PropertyListDetailsRenderSectionTests: XCTestCase { } """ let symbolGraphString = makeSymbolGraphString(moduleName: "MyModule", symbols: symbolJSON) - let tempURL = try createTempFolder(content: [ - Folder(name: "unit-test.docc", content: [ - TextFile(name: "MyModule.symbols.json", utf8Content: symbolGraphString) - ]) + let catalog = Folder(name: "unit-test.docc", content: [ + TextFile(name: "MyModule.symbols.json", utf8Content: symbolGraphString) ]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) let node = try XCTUnwrap(context.documentationCache["plist:propertylistkey"]) let converter = DocumentationNodeConverter(bundle: bundle, context: context) let renderNode = converter.convert(node) diff --git a/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift b/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift index 8d0e742de2..4ab337313e 100644 --- a/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift @@ -322,7 +322,7 @@ class RESTSymbolsTests: XCTestCase { otherMixins: [SymbolGraph.Symbol.PlistDetails(rawKey: "plist-key-symbolname", customTitle: keyCustomName)] ) let symbols: [SymbolGraph.Symbol] = [someSymbol] - let exampleDocumentation = Folder( + let catalog = Folder( name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( @@ -331,7 +331,7 @@ class RESTSymbolsTests: XCTestCase { )), ] + extraFiles ) - let (_, bundle, context) = try loadBundle(from: (try createTempFolder(content: [exampleDocumentation]))) + let (bundle, context) = try loadBundle(catalog: catalog) let moduleReference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName", sourceLanguage: .swift) let moduleSymbol = try XCTUnwrap((try context.entity(with: moduleReference)).semantic as? Symbol) var translator = RenderNodeTranslator(context: context, bundle: bundle, identifier: moduleReference) diff --git a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift index 1fadc6e304..788d7c7386 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift @@ -15,7 +15,7 @@ import XCTest class RenderContentCompilerTests: XCTestCase { func testLinkOverrideTitle() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ @@ -133,7 +133,7 @@ class RenderContentCompilerTests: XCTestCase { } func testLineBreak() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = #""" diff --git a/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift b/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift index 6655a1ce59..d27d65ed5f 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderMetadataTests.swift @@ -72,7 +72,7 @@ class RenderMetadataTests: XCTestCase { func testAllPagesHaveTitleMetadata() throws { var typesOfPages = [Tutorial.self, TutorialTableOfContents.self, Article.self, TutorialArticle.self, Symbol.self] - for bundleName in ["TestBundle"] { + for bundleName in ["LegacyBundle_DoNotUseInNewTests"] { let (bundle, context) = try testBundleAndContext(named: bundleName) let renderContext = RenderContext(documentationContext: context, bundle: bundle) @@ -93,7 +93,7 @@ class RenderMetadataTests: XCTestCase { /// Test that a bystanders symbol graph is loaded, symbols are merged into the main module /// and the bystanders are included in the render node metadata. func testRendersBystandersFromSymbolGraph() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [:]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [:]) { url in let bystanderSymbolGraphURL = Bundle.module.url( forResource: "MyKit@Foundation@_MyKit_Foundation.symbols", withExtension: "json", subdirectory: "Test Resources")! try FileManager.default.copyItem(at: bystanderSymbolGraphURL, to: url.appendingPathComponent("MyKit@Foundation@_MyKit_Foundation.symbols.json")) @@ -117,7 +117,7 @@ class RenderMetadataTests: XCTestCase { /// Test that when a bystanders symbol graph is loaded that extends a different module, that /// those symbols correctly report the modules when rendered. func testRendersBystanderExtensionsFromSymbolGraph() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", externalResolvers: [:]) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", externalResolvers: [:]) { url in let baseSymbolGraphURL = Bundle.module.url( forResource: "BaseKit.symbols", withExtension: "json", subdirectory: "Test Resources")! try FileManager.default.copyItem(at: baseSymbolGraphURL, to: url.appendingPathComponent("BaseKit.symbols.json")) diff --git a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift index bb3998d227..45b5cdcd3b 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorSymbolVariantsTests.swift @@ -1177,7 +1177,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { } private func assertMultiVariantSymbol( - bundleName: String = "TestBundle", + bundleName: String = "LegacyBundle_DoNotUseInNewTests", configureContext: (DocumentationContext, ResolvedTopicReference) throws -> () = { _, _ in }, configureSymbol: (Symbol) throws -> () = { _ in }, configureRenderNodeTranslator: (inout RenderNodeTranslator) -> () = { _ in }, @@ -1222,7 +1222,7 @@ class RenderNodeTranslatorSymbolVariantsTests: XCTestCase { assertAfterApplyingVariant: (RenderNode) throws -> () = { _ in }, assertDataAfterApplyingVariant: (Data) throws -> () = { _ in } ) throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") let identifier = ResolvedTopicReference( bundleID: bundle.id, diff --git a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift index 167405ca0e..b0b267ab05 100644 --- a/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RenderNodeTranslatorTests.swift @@ -17,7 +17,7 @@ import SymbolKit class RenderNodeTranslatorTests: XCTestCase { private func findDiscussion(forSymbolPath: String, configureBundle: ((URL) throws -> Void)? = nil) throws -> ContentRenderSection? { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", configureBundle: configureBundle) + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", configureBundle: configureBundle) let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: forSymbolPath, sourceLanguage: .swift)) @@ -223,7 +223,7 @@ class RenderNodeTranslatorTests: XCTestCase { } func testArticleRoles() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() // Verify article's role @@ -281,7 +281,7 @@ class RenderNodeTranslatorTests: XCTestCase { // Verifies that links to sections include their container's abstract rdar://72110558 func testSectionAbstracts() throws { // Create an article including a link to a tutorial section - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], configureBundle: { url in try """ # Article Article abstract @@ -303,7 +303,7 @@ class RenderNodeTranslatorTests: XCTestCase { } func testEmptyTaskGroupsNotRendered() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let source = """ @@ -365,7 +365,7 @@ class RenderNodeTranslatorTests: XCTestCase { /// Tests the ordering of automatic groups for symbols func testAutomaticTaskGroupsOrderingInSymbols() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in try """ # ``SideKit/SideClass`` SideClass abstract @@ -492,7 +492,7 @@ class RenderNodeTranslatorTests: XCTestCase { /// Tests the ordering of automatic groups for articles func testAutomaticTaskGroupsOrderingInArticles() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in try """ # Article Article abstract @@ -599,7 +599,7 @@ class RenderNodeTranslatorTests: XCTestCase { /// Tests the ordering of automatic groups in defining protocol func testOrderingOfAutomaticGroupsInDefiningProtocol() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in // }) @@ -649,7 +649,7 @@ class RenderNodeTranslatorTests: XCTestCase { forResource: "FancyProtocol.symbols", withExtension: "json", subdirectory: "Test Resources")! // Create a test bundle copy with the symbol graph from above - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: []) { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: []) { url in try? FileManager.default.copyItem(at: fancyProtocolSGFURL, to: url.appendingPathComponent("FancyProtocol.symbols.json")) } @@ -885,7 +885,7 @@ class RenderNodeTranslatorTests: XCTestCase { // Verifies we don't render links to non linkable nodes. func testNonLinkableNodes() throws { // Create a bundle with variety absolute and relative links and symbol links to a non linkable node. - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in try """ # ``SideKit/SideClass`` Abstract. @@ -925,7 +925,7 @@ class RenderNodeTranslatorTests: XCTestCase { func testLinkInAbstract() throws { do { // First verify that `SideKit` page does not contain render reference to `SideKit/SideClass/Element`. - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/SideKit", sourceLanguage: .swift) let node = try context.entity(with: reference) @@ -940,7 +940,7 @@ class RenderNodeTranslatorTests: XCTestCase { do { // Create a bundle with a link in abstract, then verify the render reference is present in `SideKit` render node references. - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests", excludingPaths: [], externalResolvers: [:], externalSymbolResolver: nil, configureBundle: { url in try """ # ``SideKit/SideClass`` This is a link to . @@ -1273,7 +1273,7 @@ class RenderNodeTranslatorTests: XCTestCase { } func testExpectedRoleHeadingIsAssigned() throws { - let exampleDocumentation = Folder( + let catalog = Folder( name: "unit-test.docc", content: [ TextFile(name: "APICollection.md", utf8Content: """ @@ -1334,8 +1334,7 @@ class RenderNodeTranslatorTests: XCTestCase { ), ] ) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) func renderNodeArticleFromReferencePath( referencePath: String @@ -1364,7 +1363,7 @@ class RenderNodeTranslatorTests: XCTestCase { } func testExpectedRoleHeadingWhenAutomaticRoleHeadingIsDisabled() throws { - let exampleDocumentation = Folder( + let catalog = Folder( name: "unit-test.docc", content: [ TextFile(name: "APICollection.md", utf8Content: """ @@ -1427,8 +1426,7 @@ class RenderNodeTranslatorTests: XCTestCase { ), ] ) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) func renderNodeArticleFromReferencePath( referencePath: String diff --git a/Tests/SwiftDocCTests/Rendering/RoleTests.swift b/Tests/SwiftDocCTests/Rendering/RoleTests.swift index af578d495a..2bea97e3de 100644 --- a/Tests/SwiftDocCTests/Rendering/RoleTests.swift +++ b/Tests/SwiftDocCTests/Rendering/RoleTests.swift @@ -25,7 +25,7 @@ class RoleTests: XCTestCase { ] func testNodeRoles() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") // Compile docs and verify contents for (path, expectedRole) in expectedRoles { @@ -43,7 +43,7 @@ class RoleTests: XCTestCase { } func testDocumentationRenderReferenceRoles() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/documentation/MyKit", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) @@ -56,7 +56,7 @@ class RoleTests: XCTestCase { } func testTutorialsRenderReferenceRoles() throws { - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") let identifier = ResolvedTopicReference(bundleID: "org.swift.docc.example", path: "/tutorials/Test-Bundle/TestTutorial", fragment: nil, sourceLanguage: .swift) let node = try context.entity(with: identifier) diff --git a/Tests/SwiftDocCTests/Rendering/TermListTests.swift b/Tests/SwiftDocCTests/Rendering/TermListTests.swift index df18503a2f..fb6340b207 100644 --- a/Tests/SwiftDocCTests/Rendering/TermListTests.swift +++ b/Tests/SwiftDocCTests/Rendering/TermListTests.swift @@ -48,7 +48,7 @@ class TermListTests: XCTestCase { } func testLinksAndCodeVoiceAsTerms() throws { - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ TextFile(name: "Article.md", utf8Content: """ # Article @@ -77,15 +77,16 @@ class TermListTests: XCTestCase { ) ] )), - ]), - ]) + ]) let resolver = TestMultiResultExternalReferenceResolver() resolver.entitiesToReturn["/path/to/something"] = .success( .init(referencePath: "/path/to/something") ) - let (_, bundle, context) = try loadBundle(from: tempURL, externalResolvers: ["com.external.testbundle": resolver]) + var configuration = DocumentationContext.Configuration() + configuration.externalDocumentationConfiguration.sources = ["com.external.testbundle": resolver] + let (bundle, context) = try loadBundle(catalog: catalog, configuration: configuration) let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/unit-test/Article", sourceLanguage: .swift) let entity = try context.entity(with: reference) @@ -160,7 +161,7 @@ class TermListTests: XCTestCase { return } - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ @@ -203,7 +204,7 @@ class TermListTests: XCTestCase { return } - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var renderContentCompiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift)) let source = """ diff --git a/Tests/SwiftDocCTests/Semantics/ArticleTests.swift b/Tests/SwiftDocCTests/Semantics/ArticleTests.swift index 3c925f46e6..cbcd59387a 100644 --- a/Tests/SwiftDocCTests/Semantics/ArticleTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ArticleTests.swift @@ -22,7 +22,7 @@ class ArticleTests: XCTestCase { Here's an overview. """ let document = Document(parsing: source, options: []) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article) @@ -44,7 +44,7 @@ class ArticleTests: XCTestCase { Here's an overview. """ let document = Document(parsing: source, options: []) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article) @@ -73,7 +73,7 @@ class ArticleTests: XCTestCase { Here's an overview. """ let document = Document(parsing: source, options: []) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article) @@ -97,7 +97,7 @@ class ArticleTests: XCTestCase { # This is my article """ let document = Document(parsing: source, options: []) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article) @@ -115,7 +115,7 @@ class ArticleTests: XCTestCase { - This is not an abstract. """ let document = Document(parsing: source, options: []) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article) @@ -133,7 +133,7 @@ class ArticleTests: XCTestCase { This is my article """ let document = Document(parsing: source, options: []) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) @@ -153,7 +153,7 @@ class ArticleTests: XCTestCase { """ let document = Document(parsing: source, options: []) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) @@ -185,7 +185,7 @@ class ArticleTests: XCTestCase { Here's an overview. """ let document = Document(parsing: source, options: [.parseBlockDirectives]) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article) diff --git a/Tests/SwiftDocCTests/Semantics/AssessmentsTests.swift b/Tests/SwiftDocCTests/Semantics/AssessmentsTests.swift index f5ae243830..582cc0b365 100644 --- a/Tests/SwiftDocCTests/Semantics/AssessmentsTests.swift +++ b/Tests/SwiftDocCTests/Semantics/AssessmentsTests.swift @@ -19,7 +19,7 @@ class AssessmentsTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() diff --git a/Tests/SwiftDocCTests/Semantics/ChapterTests.swift b/Tests/SwiftDocCTests/Semantics/ChapterTests.swift index 9a813fa577..257b78ec40 100644 --- a/Tests/SwiftDocCTests/Semantics/ChapterTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ChapterTests.swift @@ -19,7 +19,7 @@ class ChapterTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let chapter = Chapter(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(chapter) @@ -42,7 +42,7 @@ class ChapterTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let chapter = Chapter(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertEqual(1, problems.count) @@ -71,7 +71,7 @@ class ChapterTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let chapter = Chapter(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertTrue(problems.isEmpty) @@ -83,7 +83,7 @@ class ChapterTests: XCTestCase { } func testDuplicateTutorialReferences() throws { - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") /* The test bundle contains the duplicate tutorial references in TestOverview: diff --git a/Tests/SwiftDocCTests/Semantics/ChoiceTests.swift b/Tests/SwiftDocCTests/Semantics/ChoiceTests.swift index 28a70df64c..4646e68bd7 100644 --- a/Tests/SwiftDocCTests/Semantics/ChoiceTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ChoiceTests.swift @@ -11,6 +11,7 @@ import XCTest @testable import SwiftDocC import Markdown +import SwiftDocCTestUtilities class ChoiceTests: XCTestCase { func testInvalidEmpty() throws { @@ -19,7 +20,7 @@ class ChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -46,7 +47,7 @@ class ChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -69,7 +70,7 @@ class ChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -95,7 +96,7 @@ class ChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -121,7 +122,7 @@ class ChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -151,7 +152,7 @@ class ChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -187,7 +188,7 @@ Choice @1:1-6:2 isCorrect: true let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -221,7 +222,10 @@ Choice @1:1-9:2 isCorrect: true let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try loadBundle(catalog: Folder(name: "unit-test.docc", content: [ + InfoPlist(identifier: "org.swift.docc.example"), + DataFile(name: "blah.png", data: Data()), + ])) directive.map { directive in var problems = [Problem]() diff --git a/Tests/SwiftDocCTests/Semantics/CodeTests.swift b/Tests/SwiftDocCTests/Semantics/CodeTests.swift index de2dda6acb..71e44f3e44 100644 --- a/Tests/SwiftDocCTests/Semantics/CodeTests.swift +++ b/Tests/SwiftDocCTests/Semantics/CodeTests.swift @@ -19,7 +19,7 @@ class CodeTests: XCTestCase { let source = "@Code" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let code = Code(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(code) diff --git a/Tests/SwiftDocCTests/Semantics/ContentAndMediaTests.swift b/Tests/SwiftDocCTests/Semantics/ContentAndMediaTests.swift index c03a512da2..a90607588b 100644 --- a/Tests/SwiftDocCTests/Semantics/ContentAndMediaTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ContentAndMediaTests.swift @@ -19,7 +19,7 @@ class ContentAndMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let contentAndMedia = ContentAndMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(contentAndMedia) @@ -37,7 +37,7 @@ class ContentAndMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let contentAndMedia = ContentAndMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(contentAndMedia) @@ -58,7 +58,7 @@ class ContentAndMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let contentAndMedia = ContentAndMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(contentAndMedia) @@ -81,7 +81,7 @@ class ContentAndMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let contentAndMedia = ContentAndMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(contentAndMedia) @@ -102,7 +102,7 @@ class ContentAndMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let contentAndMedia = ContentAndMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(contentAndMedia) diff --git a/Tests/SwiftDocCTests/Semantics/DisplayNameTests.swift b/Tests/SwiftDocCTests/Semantics/DisplayNameTests.swift index 39b437e4fe..6ba4662720 100644 --- a/Tests/SwiftDocCTests/Semantics/DisplayNameTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DisplayNameTests.swift @@ -19,7 +19,7 @@ class DisplayNameTests: XCTestCase { let source = "@DisplayName" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let displayName = DisplayName(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(displayName) @@ -32,7 +32,7 @@ class DisplayNameTests: XCTestCase { let source = "@DisplayName(\"Custom Symbol Name\")" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let displayName = DisplayName(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(displayName) @@ -44,7 +44,7 @@ class DisplayNameTests: XCTestCase { let source = "@DisplayName(\"Custom Symbol Name\", style: conceptual)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let displayName = DisplayName(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(displayName) @@ -56,7 +56,7 @@ class DisplayNameTests: XCTestCase { let source = "@DisplayName(\"Custom Symbol Name\", style: symbol)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let displayName = DisplayName(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(displayName) @@ -68,7 +68,7 @@ class DisplayNameTests: XCTestCase { let source = "@DisplayName(\"Custom Symbol Name\", style: somethingUnknown)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let displayName = DisplayName(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(displayName) @@ -81,7 +81,7 @@ class DisplayNameTests: XCTestCase { let source = "@DisplayName(\"Custom Symbol Name\", argument: value)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let displayName = DisplayName(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(displayName, "Even if there are warnings we can create a displayName value") @@ -98,7 +98,7 @@ class DisplayNameTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let displayName = DisplayName(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(displayName, "Even if there are warnings we can create a DisplayName value") @@ -116,7 +116,7 @@ class DisplayNameTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let displayName = DisplayName(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(displayName, "Even if there are warnings we can create a DisplayName value") diff --git a/Tests/SwiftDocCTests/Semantics/DocumentationExtensionTests.swift b/Tests/SwiftDocCTests/Semantics/DocumentationExtensionTests.swift index 66d35673a5..6387533a42 100644 --- a/Tests/SwiftDocCTests/Semantics/DocumentationExtensionTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DocumentationExtensionTests.swift @@ -19,7 +19,7 @@ class DocumentationExtensionTests: XCTestCase { let source = "@DocumentationExtension" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let options = DocumentationExtension(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(options) @@ -32,7 +32,7 @@ class DocumentationExtensionTests: XCTestCase { let source = "@DocumentationExtension(mergeBehavior: append)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let options = DocumentationExtension(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(options) @@ -45,7 +45,7 @@ class DocumentationExtensionTests: XCTestCase { let source = "@DocumentationExtension(mergeBehavior: override)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let options = DocumentationExtension(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(options) @@ -57,7 +57,7 @@ class DocumentationExtensionTests: XCTestCase { let source = "@DocumentationExtension(mergeBehavior: somethingUnknown )" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let options = DocumentationExtension(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(options) @@ -70,7 +70,7 @@ class DocumentationExtensionTests: XCTestCase { let source = "@DocumentationExtension(mergeBehavior: override, argument: value)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let options = DocumentationExtension(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(options, "Even if there are warnings we can create an options value") @@ -87,7 +87,7 @@ class DocumentationExtensionTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let options = DocumentationExtension(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(options, "Even if there are warnings we can create a DocumentationExtension value") @@ -105,7 +105,7 @@ class DocumentationExtensionTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let options = DocumentationExtension(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(options, "Even if there are warnings we can create a DocumentationExtension value") @@ -121,7 +121,7 @@ class DocumentationExtensionTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let options = DocumentationExtension(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(options) diff --git a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift index 8abb9cd787..664ce47513 100644 --- a/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift +++ b/Tests/SwiftDocCTests/Semantics/DoxygenTests.swift @@ -33,7 +33,7 @@ class DoxygenTests: XCTestCase { ) } - let tempURL = try createTempFolder(content: [ + let catalog = Folder(name: "unit-test.docc", content: [ JSONFile(name: "ModuleName.symbols.json", content: makeSymbolGraph( moduleName: "ModuleName", @@ -86,9 +86,8 @@ class DoxygenTests: XCTestCase { ] )), ]) - ]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) let reference = ResolvedTopicReference(bundleID: bundle.id, path: "/documentation/ModuleName/SomeClass", sourceLanguage: .swift) // Verify the expected content in the in-memory model diff --git a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasAtLeastOneTests.swift b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasAtLeastOneTests.swift index b737fe337e..5c9e09adbd 100644 --- a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasAtLeastOneTests.swift +++ b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasAtLeastOneTests.swift @@ -55,7 +55,7 @@ class HasAtLeastOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() do { var problems = [Problem]() @@ -94,7 +94,7 @@ class HasAtLeastOneTests: XCTestCase { var problems = [Problem]() XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in let (matches, remainder) = Semantic.Analyses.HasAtLeastOne(severityIfNotFound: .error).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) @@ -117,7 +117,7 @@ class HasAtLeastOneTests: XCTestCase { var problems = [Problem]() XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in let (matches, remainder) = Semantic.Analyses.HasAtLeastOne(severityIfNotFound: .error).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) @@ -138,7 +138,7 @@ class HasAtLeastOneTests: XCTestCase { var problems = [Problem]() XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in let (matches, remainder) = Semantic.Analyses.HasAtLeastOne(severityIfNotFound: .error).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) diff --git a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasAtMostOneTests.swift b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasAtMostOneTests.swift index 2c79436f24..ea9bd16516 100644 --- a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasAtMostOneTests.swift +++ b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasAtMostOneTests.swift @@ -19,7 +19,7 @@ class HasAtMostOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -40,7 +40,7 @@ class HasAtMostOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -63,7 +63,7 @@ class HasAtMostOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -90,7 +90,7 @@ class HasAtMostOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() diff --git a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasContentTests.swift b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasContentTests.swift index 1ea5879e5f..fa64a0bdf4 100644 --- a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasContentTests.swift +++ b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasContentTests.swift @@ -19,7 +19,7 @@ class HasContentTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -42,7 +42,7 @@ class HasContentTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() diff --git a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasExactlyOneTests.swift b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasExactlyOneTests.swift index b167bfc73e..8993631443 100644 --- a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasExactlyOneTests.swift +++ b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasExactlyOneTests.swift @@ -19,7 +19,7 @@ class HasExactlyOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -50,7 +50,7 @@ class HasExactlyOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -73,7 +73,7 @@ class HasExactlyOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -102,7 +102,7 @@ class HasExactlyOneTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() diff --git a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlyKnownArgumentsTests.swift b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlyKnownArgumentsTests.swift index de61619e5c..bfc655d36f 100644 --- a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlyKnownArgumentsTests.swift +++ b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlyKnownArgumentsTests.swift @@ -20,7 +20,7 @@ class HasOnlyKnownArgumentsTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] _ = Semantic.Analyses.HasOnlyKnownArguments(severityIfFound: .error, allowedArguments: ["foo", "bar"]).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) @@ -34,7 +34,7 @@ class HasOnlyKnownArgumentsTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] _ = Semantic.Analyses.HasOnlyKnownArguments(severityIfFound: .error, allowedArguments: []).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) @@ -48,7 +48,7 @@ class HasOnlyKnownArgumentsTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] _ = Semantic.Analyses.HasOnlyKnownArguments(severityIfFound: .error, allowedArguments: ["foo", "bar"]).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) @@ -61,7 +61,7 @@ class HasOnlyKnownArgumentsTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] _ = Semantic.Analyses.HasOnlyKnownArguments(severityIfFound: .error, allowedArguments: ["foo", "bar", "woof", "bark"]).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) diff --git a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlyKnownDirectivesTests.swift b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlyKnownDirectivesTests.swift index e2cdead3ef..137c2db88c 100644 --- a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlyKnownDirectivesTests.swift +++ b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlyKnownDirectivesTests.swift @@ -24,7 +24,7 @@ class HasOnlyKnownDirectivesTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] Semantic.Analyses.HasOnlyKnownDirectives(severityIfFound: .error, allowedDirectives: ["valid", "bar"]).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) @@ -44,7 +44,7 @@ class HasOnlyKnownDirectivesTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] Semantic.Analyses.HasOnlyKnownDirectives(severityIfFound: .error, allowedDirectives: []).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) @@ -64,7 +64,7 @@ class HasOnlyKnownDirectivesTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] Semantic.Analyses.HasOnlyKnownDirectives(severityIfFound: .error, allowedDirectives: ["valid"]).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) @@ -86,7 +86,7 @@ class HasOnlyKnownDirectivesTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() // Does allow arbitrary markup var problems: [Problem] = [] @@ -114,7 +114,7 @@ class HasOnlyKnownDirectivesTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] Semantic.Analyses.HasOnlyKnownDirectives(severityIfFound: .error, allowedDirectives: ["foo", "bar", "woof", "bark"]).analyze(directive, children: directive.children, source: nil, for: bundle, in: context, problems: &problems) diff --git a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlySequentialHeadingsTests.swift b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlySequentialHeadingsTests.swift index 2b504ccc44..4860f836ef 100644 --- a/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlySequentialHeadingsTests.swift +++ b/Tests/SwiftDocCTests/Semantics/General Purpose Analyses/HasOnlySequentialHeadingsTests.swift @@ -27,7 +27,7 @@ some more *stuff* """ let document = Document(parsing: source, options: .parseBlockDirectives) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] Semantic.Analyses.HasOnlySequentialHeadings(severityIfFound: .warning, startingFromLevel: 2).analyze(containerDirective, children: document.children, source: nil, for: bundle, in: context, problems: &problems) @@ -50,7 +50,7 @@ some more *stuff* """ let document = Document(parsing: source, options: .parseBlockDirectives) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] Semantic.Analyses.HasOnlySequentialHeadings(severityIfFound: .warning, startingFromLevel: 2).analyze(containerDirective, children: document.children, source: nil, for: bundle, in: context, problems: &problems) @@ -65,7 +65,7 @@ some more *stuff* """ let document = Document(parsing: source, options: .parseBlockDirectives) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] Semantic.Analyses.HasOnlySequentialHeadings(severityIfFound: .warning, startingFromLevel: 2).analyze(containerDirective, children: document.children, source: nil, for: bundle, in: context, problems: &problems) @@ -86,7 +86,7 @@ some more *stuff* """ let document = Document(parsing: source, options: .parseBlockDirectives) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems: [Problem] = [] Semantic.Analyses.HasOnlySequentialHeadings(severityIfFound: .warning, startingFromLevel: 2).analyze(containerDirective, children: document.children, source: nil, for: bundle, in: context, problems: &problems) diff --git a/Tests/SwiftDocCTests/Semantics/ImageMediaTests.swift b/Tests/SwiftDocCTests/Semantics/ImageMediaTests.swift index 41c6df14e1..74adaf7dcf 100644 --- a/Tests/SwiftDocCTests/Semantics/ImageMediaTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ImageMediaTests.swift @@ -19,7 +19,7 @@ class ImageMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let image = ImageMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(image) @@ -38,7 +38,7 @@ class ImageMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let image = ImageMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(image) @@ -57,7 +57,7 @@ class ImageMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let image = ImageMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(image) @@ -75,7 +75,7 @@ class ImageMediaTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let image = ImageMedia(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(image) @@ -239,7 +239,7 @@ class ImageMediaTests: XCTestCase { func testImageDirectiveDoesNotResolveVideoReference() throws { // First check that the Video exists - let (_, videoProblems, _) = try parseDirective(VideoMedia.self, in: "TestBundle") { + let (_, videoProblems, _) = try parseDirective(VideoMedia.self, in: "LegacyBundle_DoNotUseInNewTests") { """ @Video(source: "introvideo") """ @@ -248,7 +248,7 @@ class ImageMediaTests: XCTestCase { XCTAssertEqual(videoProblems, []) // Then check that it doesn't resolve as an image - let (renderedContent, imageProblems, image) = try parseDirective(ImageMedia.self, in: "TestBundle") { + let (renderedContent, imageProblems, image) = try parseDirective(ImageMedia.self, in: "LegacyBundle_DoNotUseInNewTests") { """ @Image(source: "introvideo") """ diff --git a/Tests/SwiftDocCTests/Semantics/IntroTests.swift b/Tests/SwiftDocCTests/Semantics/IntroTests.swift index 57a1e355f1..b996037483 100644 --- a/Tests/SwiftDocCTests/Semantics/IntroTests.swift +++ b/Tests/SwiftDocCTests/Semantics/IntroTests.swift @@ -17,7 +17,7 @@ class IntroTests: XCTestCase { let source = "@Intro" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let intro = Intro(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(intro) @@ -42,7 +42,7 @@ class IntroTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let intro = Intro(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(intro) @@ -68,7 +68,7 @@ class IntroTests: XCTestCase { let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let intro = Intro(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(intro) diff --git a/Tests/SwiftDocCTests/Semantics/JustificationTests.swift b/Tests/SwiftDocCTests/Semantics/JustificationTests.swift index a4a7b55762..ab5023643d 100644 --- a/Tests/SwiftDocCTests/Semantics/JustificationTests.swift +++ b/Tests/SwiftDocCTests/Semantics/JustificationTests.swift @@ -19,7 +19,7 @@ class JustificationTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() @@ -44,7 +44,7 @@ class JustificationTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() directive.map { directive in var problems = [Problem]() diff --git a/Tests/SwiftDocCTests/Semantics/MarkupReferenceResolverTests.swift b/Tests/SwiftDocCTests/Semantics/MarkupReferenceResolverTests.swift index f6c70a830c..5ffdbf18d4 100644 --- a/Tests/SwiftDocCTests/Semantics/MarkupReferenceResolverTests.swift +++ b/Tests/SwiftDocCTests/Semantics/MarkupReferenceResolverTests.swift @@ -14,7 +14,7 @@ import Markdown class MarkupReferenceResolverTests: XCTestCase { func testArbitraryReferenceInComment() throws { - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") let source = """ @Comment { ``hello`` and ``world`` are 2 arbitrary symbol links. diff --git a/Tests/SwiftDocCTests/Semantics/MetadataTests.swift b/Tests/SwiftDocCTests/Semantics/MetadataTests.swift index 1da87e4004..888695f31a 100644 --- a/Tests/SwiftDocCTests/Semantics/MetadataTests.swift +++ b/Tests/SwiftDocCTests/Semantics/MetadataTests.swift @@ -19,7 +19,7 @@ class MetadataTests: XCTestCase { let source = "@Metadata" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata, "Even if a Metadata directive is empty we can create it") @@ -33,7 +33,7 @@ class MetadataTests: XCTestCase { let source = "@Metadata(argument: value)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata, "Even if there are warnings we can create a metadata value") @@ -50,7 +50,7 @@ class MetadataTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata, "Even if there are warnings we can create a Metadata value") @@ -69,7 +69,7 @@ class MetadataTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata, "Even if there are warnings we can create a Metadata value") @@ -88,7 +88,7 @@ class MetadataTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata) @@ -105,7 +105,7 @@ class MetadataTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata) @@ -125,7 +125,7 @@ class MetadataTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata) @@ -142,7 +142,7 @@ class MetadataTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata) @@ -160,7 +160,7 @@ class MetadataTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata) @@ -176,7 +176,7 @@ class MetadataTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let metadata = Metadata(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(metadata) @@ -197,7 +197,7 @@ class MetadataTests: XCTestCase { The abstract of this article """ let document = Document(parsing: source, options: .parseBlockDirectives) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "An Article value can be created with a Metadata child.") @@ -219,7 +219,7 @@ class MetadataTests: XCTestCase { The abstract of this documentation extension """ let document = Document(parsing: source, options: [.parseBlockDirectives, .parseSymbolLinks]) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "An Article value can be created with a Metadata child with a DisplayName child.") @@ -243,7 +243,7 @@ class MetadataTests: XCTestCase { The abstract of this documentation extension """ let document = Document(parsing: source, options: [.parseBlockDirectives, .parseSymbolLinks]) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "An Article value can be created with a Metadata child with a DisplayName child.") @@ -279,7 +279,7 @@ class MetadataTests: XCTestCase { The abstract of this documentation extension """ let document = Document(parsing: source, options: [.parseBlockDirectives, .parseSymbolLinks]) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "An Article value can be created with a Metadata child with a TitleHeading child.") @@ -307,7 +307,7 @@ class MetadataTests: XCTestCase { The abstract of this documentation extension """ let document = Document(parsing: source, options: [.parseBlockDirectives, .parseSymbolLinks]) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext() var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "An Article value can be created with a Metadata child with a DisplayName child.") @@ -414,7 +414,7 @@ class MetadataTests: XCTestCase { line: UInt = #line ) throws -> (problems: [String], metadata: Metadata) { let document = Document(parsing: source, options: [.parseBlockDirectives, .parseSymbolLinks]) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var analyzer = SemanticAnalyzer(source: nil, context: context, bundle: bundle) _ = analyzer.visit(document) diff --git a/Tests/SwiftDocCTests/Semantics/MultipleChoiceTests.swift b/Tests/SwiftDocCTests/Semantics/MultipleChoiceTests.swift index 1bdc998712..8fb02a273d 100644 --- a/Tests/SwiftDocCTests/Semantics/MultipleChoiceTests.swift +++ b/Tests/SwiftDocCTests/Semantics/MultipleChoiceTests.swift @@ -19,7 +19,7 @@ class MultipleChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -53,7 +53,7 @@ class MultipleChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") try directive.map { directive in var problems = [Problem]() @@ -101,7 +101,7 @@ class MultipleChoiceTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -158,7 +158,7 @@ MultipleChoice @1:1-24:2 title: 'SwiftDocC.MarkupContainer' let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -214,7 +214,7 @@ MultipleChoice @1:1-18:2 title: 'SwiftDocC.MarkupContainer' let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -274,7 +274,7 @@ MultipleChoice @1:1-22:2 title: 'SwiftDocC.MarkupContainer' let document = Document(parsing: source, options: .parseBlockDirectives) let directive = try XCTUnwrap(document.child(at: 0) as? BlockDirective) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() XCTAssertEqual(MultipleChoice.directiveName, directive.name) diff --git a/Tests/SwiftDocCTests/Semantics/RedirectedTests.swift b/Tests/SwiftDocCTests/Semantics/RedirectedTests.swift index 2a06658f3e..289e690933 100644 --- a/Tests/SwiftDocCTests/Semantics/RedirectedTests.swift +++ b/Tests/SwiftDocCTests/Semantics/RedirectedTests.swift @@ -19,7 +19,7 @@ class RedirectedTests: XCTestCase { let source = "@Redirected" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(redirected) @@ -33,7 +33,7 @@ class RedirectedTests: XCTestCase { let source = "@Redirected(from: \(oldPath))" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(redirected) @@ -46,7 +46,7 @@ class RedirectedTests: XCTestCase { let source = "@Redirected(from: \(oldPath), argument: value)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(redirected, "Even if there are warnings we can create a Redirected value") @@ -64,7 +64,7 @@ class RedirectedTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(redirected, "Even if there are warnings we can create a Redirected value") @@ -83,7 +83,7 @@ class RedirectedTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(redirected, "Even if there are warnings we can create a Redirected value") @@ -107,7 +107,7 @@ class RedirectedTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tutorialTableOfContents = TutorialTableOfContents(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(tutorialTableOfContents, "A tutorial table-of-contents value can be created with a Redirected child.") @@ -139,7 +139,7 @@ class RedirectedTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let volume = Volume(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(volume, "A Volume value can be created with a Redirected child.") @@ -204,7 +204,7 @@ class RedirectedTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tutorial = Tutorial(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(tutorial, "A Tutorial value can be created with a Redirected child.") @@ -232,7 +232,7 @@ class RedirectedTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let article = TutorialArticle(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "A TutorialArticle value can be created with a Redirected child.") @@ -281,7 +281,7 @@ class RedirectedTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let article = Resources(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "A Resources value can be created with a Redirected child.") @@ -302,7 +302,7 @@ class RedirectedTests: XCTestCase { ![full width image](referenced-article-image.png) """ let document = Document(parsing: source, options: .parseBlockDirectives) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "An Article value can be created with a Redirected child.") @@ -337,7 +337,7 @@ class RedirectedTests: XCTestCase { ![full width image](referenced-article-image.png) """ let document = Document(parsing: source, options: .parseBlockDirectives) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "An Article value can be created with a Redirected child.") @@ -374,7 +374,7 @@ class RedirectedTests: XCTestCase { ![full width image](referenced-article-image.png) """ let document = Document(parsing: source, options: .parseBlockDirectives) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(article, "An Article value can be created with a Redirected child.") @@ -398,7 +398,7 @@ class RedirectedTests: XCTestCase { let source = "@Redirected(fromURL: /old/path)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(redirected) diff --git a/Tests/SwiftDocCTests/Semantics/Reference/LinksTests.swift b/Tests/SwiftDocCTests/Semantics/Reference/LinksTests.swift index 8c0f1e25a0..f2238b08d1 100644 --- a/Tests/SwiftDocCTests/Semantics/Reference/LinksTests.swift +++ b/Tests/SwiftDocCTests/Semantics/Reference/LinksTests.swift @@ -185,7 +185,7 @@ class LinksTests: XCTestCase { } do { - let (renderedContent, problems, links) = try parseDirective(Links.self, in: "TestBundle") { + let (renderedContent, problems, links) = try parseDirective(Links.self, in: "LegacyBundle_DoNotUseInNewTests") { """ @Links(visualStyle: compactGrid) { - ``MyKit/MyClass`` diff --git a/Tests/SwiftDocCTests/Semantics/ResourcesTests.swift b/Tests/SwiftDocCTests/Semantics/ResourcesTests.swift index bcb2538011..6bc0ccf34b 100644 --- a/Tests/SwiftDocCTests/Semantics/ResourcesTests.swift +++ b/Tests/SwiftDocCTests/Semantics/ResourcesTests.swift @@ -17,7 +17,7 @@ class ResourcesTests: XCTestCase { let source = "@\(Resources.directiveName)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let resources = Resources(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(resources) @@ -67,7 +67,7 @@ class ResourcesTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let resources = Resources(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(resources) @@ -120,7 +120,7 @@ Resources @1:1-29:2 """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let resources = Resources(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(resources) diff --git a/Tests/SwiftDocCTests/Semantics/SectionTests.swift b/Tests/SwiftDocCTests/Semantics/SectionTests.swift index 0fe9934c18..0ed1e5b662 100644 --- a/Tests/SwiftDocCTests/Semantics/SectionTests.swift +++ b/Tests/SwiftDocCTests/Semantics/SectionTests.swift @@ -19,7 +19,7 @@ class TutorialSectionTests: XCTestCase { let source = "@Section" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let section = TutorialSection(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(section) diff --git a/Tests/SwiftDocCTests/Semantics/StackTests.swift b/Tests/SwiftDocCTests/Semantics/StackTests.swift index 0c8a208120..a6e5104255 100644 --- a/Tests/SwiftDocCTests/Semantics/StackTests.swift +++ b/Tests/SwiftDocCTests/Semantics/StackTests.swift @@ -19,7 +19,7 @@ class StackTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -48,7 +48,7 @@ class StackTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -78,7 +78,7 @@ class StackTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() diff --git a/Tests/SwiftDocCTests/Semantics/StepTests.swift b/Tests/SwiftDocCTests/Semantics/StepTests.swift index 68301655cb..81d1b1f965 100644 --- a/Tests/SwiftDocCTests/Semantics/StepTests.swift +++ b/Tests/SwiftDocCTests/Semantics/StepTests.swift @@ -19,7 +19,7 @@ class StepTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let step = Step(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertEqual([ @@ -46,7 +46,7 @@ class StepTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let step = Step(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertTrue(problems.isEmpty) @@ -104,7 +104,7 @@ Step @1:1-9:2 """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let step = Step(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertEqual(2, problems.count) diff --git a/Tests/SwiftDocCTests/Semantics/SymbolTests.swift b/Tests/SwiftDocCTests/Semantics/SymbolTests.swift index b2657b0360..d607e7936f 100644 --- a/Tests/SwiftDocCTests/Semantics/SymbolTests.swift +++ b/Tests/SwiftDocCTests/Semantics/SymbolTests.swift @@ -531,7 +531,7 @@ class SymbolTests: XCTestCase { withExtension: "symbols.json", subdirectory: "Test Resources" )! - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in try? FileManager.default.copyItem(at: deckKitSymbolGraph, to: url.appendingPathComponent("DeckKit.symbols.json")) } let symbol = try XCTUnwrap(context.documentationCache["c:objc(cs)PlayingCard(cm)newWithRank:ofSuit:"]?.semantic as? Symbol) @@ -549,7 +549,7 @@ class SymbolTests: XCTestCase { } func testUnresolvedReferenceWarningsInDocumentationExtension() throws { - let (url, _, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (url, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in let myKitDocumentationExtensionComment = """ # ``MyKit/MyClass`` @@ -959,7 +959,7 @@ class SymbolTests: XCTestCase { - """ - let (_, _, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, _, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in var graph = try JSONDecoder().decode(SymbolGraph.self, from: Data(contentsOf: url.appendingPathComponent("mykit-iOS.symbols.json"))) let myFunctionUSR = "s:5MyKit0A5ClassC10myFunctionyyF" @@ -1203,7 +1203,7 @@ class SymbolTests: XCTestCase { func makeDocumentationNodeSymbol(docComment: String, articleContent: String?, file: StaticString = #file, line: UInt = #line) throws -> (Symbol, [Problem]) { let myFunctionUSR = "s:5MyKit0A5ClassC10myFunctionyyF" - let (_, bundle, context) = try testBundleAndContext(copying: "TestBundle") { url in + let (_, bundle, context) = try testBundleAndContext(copying: "LegacyBundle_DoNotUseInNewTests") { url in var graph = try JSONDecoder().decode(SymbolGraph.self, from: Data(contentsOf: url.appendingPathComponent("mykit-iOS.symbols.json"))) let newDocComment = SymbolGraph.LineList(docComment.components(separatedBy: .newlines).enumerated().map { arg -> SymbolGraph.LineList.Line in diff --git a/Tests/SwiftDocCTests/Semantics/TechnologyTests.swift b/Tests/SwiftDocCTests/Semantics/TechnologyTests.swift index bce53b1f14..6297b10e92 100644 --- a/Tests/SwiftDocCTests/Semantics/TechnologyTests.swift +++ b/Tests/SwiftDocCTests/Semantics/TechnologyTests.swift @@ -19,7 +19,7 @@ class TechnologyTests: XCTestCase { let source = "@Tutorials" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let technology = TutorialTableOfContents(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(technology) diff --git a/Tests/SwiftDocCTests/Semantics/TileTests.swift b/Tests/SwiftDocCTests/Semantics/TileTests.swift index 74d3dee8e8..af8424622d 100644 --- a/Tests/SwiftDocCTests/Semantics/TileTests.swift +++ b/Tests/SwiftDocCTests/Semantics/TileTests.swift @@ -26,7 +26,7 @@ class TileTests: XCTestCase { let source = "@\(directiveName)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tile = Tile(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(tile) @@ -49,7 +49,7 @@ class TileTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tile = Tile(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(tile) @@ -75,7 +75,7 @@ class TileTests: XCTestCase { let source = "@\(directiveName)" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tile = Tile(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(tile) @@ -97,7 +97,7 @@ class TileTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tile = Tile(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNotNil(tile) @@ -120,7 +120,7 @@ class TileTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tile = Tile(from: directive, source: nil, for: bundle, in: context, problems: &problems) // Destination is set. @@ -136,7 +136,7 @@ class TileTests: XCTestCase { """ let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tile = Tile(from: directive, source: nil, for: bundle, in: context, problems: &problems) // Destination is nil. @@ -149,7 +149,7 @@ class TileTests: XCTestCase { let source = "@UnknownTile" let document = Document(parsing: source, options: .parseBlockDirectives) let directive = document.child(at: 0)! as! BlockDirective - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") var problems = [Problem]() let tile = Tile(from: directive, source: nil, for: bundle, in: context, problems: &problems) XCTAssertNil(tile) diff --git a/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift b/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift index a81dbc6466..f2939a3c96 100644 --- a/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift +++ b/Tests/SwiftDocCTests/Semantics/TutorialArticleTests.swift @@ -19,7 +19,7 @@ class TutorialArticleTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -56,7 +56,7 @@ class TutorialArticleTests: XCTestCase { let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -106,7 +106,7 @@ TutorialArticle @1:1-13:2 let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -155,7 +155,7 @@ TutorialArticle @1:1-23:2 let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -265,7 +265,7 @@ TutorialArticle @1:1-23:2 title: 'Basic Augmented Reality App' time: '20' let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -361,7 +361,7 @@ TutorialArticle @1:1-81:2 let directive = document.child(at: 0) as? BlockDirective XCTAssertNotNil(directive) - let (bundle, context) = try testBundleAndContext(named: "TestBundle") + let (bundle, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") directive.map { directive in var problems = [Problem]() @@ -398,7 +398,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' let reference = ResolvedTopicReference(bundleID: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) let node = TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .file(url: URL(fileURLWithPath: "/path/to/\(title)")), title: title) - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") context.topicGraph.addNode(node) let engine = DiagnosticEngine() @@ -417,7 +417,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' let reference = ResolvedTopicReference(bundleID: "org.swift.docc.TopicGraphTests", path: "/\(title)", sourceLanguage: .swift) let node = TopicGraph.Node(reference: reference, kind: .tutorialTableOfContents, source: .external, title: title) - let (_, context) = try testBundleAndContext(named: "TestBundle") + let (_, context) = try testBundleAndContext(named: "LegacyBundle_DoNotUseInNewTests") context.topicGraph.addNode(node) let engine = DiagnosticEngine() @@ -437,7 +437,7 @@ TutorialArticle @1:1-42:2 title: 'Basic Augmented Reality App' time: '20' let range = SourceLocation(line: 1, column: 1, source: url).. (DocumentationBundle, DocumentationContext) { - let exampleDocumentation = Folder(name: "MentionedIn.docc", content: [ + let catalog = Folder(name: "MentionedIn.docc", content: [ JSONFile(name: "MentionedIn.symbols.json", content: makeSymbolGraph( moduleName: "MentionedIn", symbols: [ @@ -72,8 +72,7 @@ extension XCTestCase { """), ]) - let tempURL = try createTempFolder(content: [exampleDocumentation]) - let (_, bundle, context) = try loadBundle(from: tempURL) + let (bundle, context) = try loadBundle(catalog: catalog) return (bundle, context) } } diff --git a/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift b/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift index 1454e69084..e8d2f57c2f 100644 --- a/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift +++ b/Tests/SwiftDocCTests/XCTestCase+LoadingTestData.swift @@ -43,11 +43,13 @@ extension XCTestCase { /// - Parameters: /// - catalog: The directory structure of the documentation catalog /// - otherFileSystemDirectories: Any other directories in the test file system. + /// - diagnosticEngine: The diagnostic engine for the created context. /// - configuration: Configuration for the created context. /// - Returns: The loaded documentation bundle and context for the given catalog input. func loadBundle( catalog: Folder, otherFileSystemDirectories: [Folder] = [], + diagnosticEngine: DiagnosticEngine = .init(), configuration: DocumentationContext.Configuration = .init() ) throws -> (DocumentationBundle, DocumentationContext) { let fileSystem = try TestFileSystem(folders: [catalog] + otherFileSystemDirectories) @@ -55,7 +57,7 @@ extension XCTestCase { let (bundle, dataProvider) = try DocumentationContext.InputsProvider(fileManager: fileSystem) .inputsAndDataProvider(startingPoint: URL(fileURLWithPath: "/\(catalog.name)"), options: .init()) - let context = try DocumentationContext(bundle: bundle, dataProvider: dataProvider, configuration: configuration) + let context = try DocumentationContext(bundle: bundle, dataProvider: dataProvider, diagnosticEngine: diagnosticEngine, configuration: configuration) return (bundle, context) } @@ -186,6 +188,22 @@ extension XCTestCase { return (problemIDs, directive) } + func parseDirective( + _ directive: Directive.Type, + catalog: Folder, + content: () -> String, + file: StaticString = #file, + line: UInt = #line + ) throws -> ( + renderBlockContent: [RenderBlockContent], + problemIdentifiers: [String], + directive: Directive?, + collectedReferences: [String : RenderReference] + ) { + let (bundle, context) = try loadBundle(catalog: catalog) + return try parseDirective(directive, bundle: bundle, context: context, content: content, file: file, line: line) + } + func parseDirective( _ directive: Directive.Type, in bundleName: String? = nil, @@ -224,6 +242,22 @@ extension XCTestCase { } else { (bundle, context) = try testBundleAndContext() } + return try parseDirective(directive, bundle: bundle, context: context, content: content, file: file, line: line) + } + + private func parseDirective( + _ directive: Directive.Type, + bundle: DocumentationBundle, + context: DocumentationContext, + content: () -> String, + file: StaticString = #file, + line: UInt = #line + ) throws -> ( + renderBlockContent: [RenderBlockContent], + problemIdentifiers: [String], + directive: Directive?, + collectedReferences: [String : RenderReference] + ) { context.diagnosticEngine.clearDiagnostics() let source = URL(fileURLWithPath: "/path/to/test-source-\(ProcessInfo.processInfo.globallyUniqueString)") diff --git a/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandSourceRepositoryTests.swift b/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandSourceRepositoryTests.swift index 24f842fa5f..654006839c 100644 --- a/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandSourceRepositoryTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandSourceRepositoryTests.swift @@ -16,7 +16,7 @@ import ArgumentParser class ConvertSubcommandSourceRepositoryTests: XCTestCase { private let testBundleURL = Bundle.module.url( - forResource: "TestBundle", + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles" )! diff --git a/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandTests.swift b/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandTests.swift index 4cc94120f2..8cd7e82d45 100644 --- a/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandTests.swift @@ -15,7 +15,7 @@ import SwiftDocCTestUtilities class ConvertSubcommandTests: XCTestCase { private let testBundleURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! private let testTemplateURL = Bundle.module.url( forResource: "Test Template", withExtension: nil, subdirectory: "Test Resources")! diff --git a/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/PreviewSubcommandTests.swift b/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/PreviewSubcommandTests.swift index c6c3f89710..1f586324d3 100644 --- a/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/PreviewSubcommandTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ArgumentParsing/PreviewSubcommandTests.swift @@ -15,7 +15,7 @@ import XCTest class PreviewSubcommandTests: XCTestCase { func testOptionsValidation() throws { let testBundleURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! // Create HTML template dir. let templateDir = try createTemporaryDirectory() diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift index b112eef5bf..031e9f6a10 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionIndexerTests.swift @@ -18,7 +18,7 @@ class ConvertActionIndexerTests: XCTestCase { // Tests the standalone indexer func testConvertActionIndexer() throws { let (bundle, dataProvider) = try DocumentationContext.InputsProvider() - .inputsAndDataProvider(startingPoint: testCatalogURL(named: "TestBundle"), options: .init()) + .inputsAndDataProvider(startingPoint: testCatalogURL(named: "LegacyBundle_DoNotUseInNewTests"), options: .init()) let context = try DocumentationContext(bundle: bundle, dataProvider: dataProvider) let converter = DocumentationNodeConverter(bundle: bundle, context: context) diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionStaticHostableTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionStaticHostableTests.swift index 88c9c1f909..0c2c0498b1 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionStaticHostableTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionStaticHostableTests.swift @@ -18,7 +18,7 @@ class ConvertActionStaticHostableTests: StaticHostingBaseTests { /// Creates a DocC archive and then archives it with options to produce static content which is then validated. func testConvertActionStaticHostableTestOutput() async throws { - let bundleURL = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let bundleURL = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let targetURL = try createTemporaryDirectory() let fileManager = FileManager.default diff --git a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift index c0f1b1d2a5..13adf2759f 100644 --- a/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/ConvertActionTests.swift @@ -19,11 +19,11 @@ import Markdown class ConvertActionTests: XCTestCase { #if !os(iOS) let imageFile = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("figure1.png") let symbolGraphFile = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("FillIntroduced.symbols.json") let objectiveCSymbolGraphFile = Bundle.module.url( @@ -33,7 +33,7 @@ class ConvertActionTests: XCTestCase { )! let projectZipFile = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("project.zip") func testCopyingImageAssets() async throws { @@ -82,7 +82,7 @@ class ConvertActionTests: XCTestCase { func testCopyingVideoAssets() async throws { let videoFile = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("introvideo.mp4") XCTAssert(FileManager.default.fileExists(atPath: videoFile.path)) @@ -131,15 +131,15 @@ class ConvertActionTests: XCTestCase { // Ensures we don't regress on copying download assets to the build folder (72599615) func testCopyingDownloadAssets() async throws { let downloadFile = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("project.zip") let tutorialFile = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("TestTutorial.tutorial") let tutorialOverviewFile = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("TestOverview.tutorial") XCTAssert(FileManager.default.fileExists(atPath: downloadFile.path)) @@ -240,7 +240,7 @@ class ConvertActionTests: XCTestCase { } func testConvertWithoutBundle() async throws { - let myKitSymbolGraph = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let myKitSymbolGraph = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json") XCTAssert(FileManager.default.fileExists(atPath: myKitSymbolGraph.path)) @@ -1706,7 +1706,7 @@ class ConvertActionTests: XCTestCase { func runCompiler(analyze: Bool) async throws -> [Problem] { // This bundle has both non-analyze and analyze style warnings. let testBundleURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let bundle = try Folder.createFromDisk(url: testBundleURL) let testDataProvider = try TestFileSystem(folders: [bundle, Folder.emptyHTMLTemplateDirectory]) @@ -1749,7 +1749,7 @@ class ConvertActionTests: XCTestCase { /// and also with and without generating digest produces the same results func testConvertTestBundleWithHighConcurrency() async throws { let testBundleURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let bundle = try Folder.createFromDisk(url: testBundleURL) struct TestReferenceResolver: ExternalDocumentationSource { @@ -1839,7 +1839,7 @@ class ConvertActionTests: XCTestCase { let testBundleURL = try XCTUnwrap( Bundle.module.url( - forResource: "TestBundle", + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles" ) @@ -1915,7 +1915,7 @@ class ConvertActionTests: XCTestCase { func testConvertActionNavigatorIndexGeneration() async throws { // The navigator index needs to test with the real file manager - let bundleURL = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let bundleURL = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let targetURL = try createTemporaryDirectory() let templateURL = try createTemporaryDirectory().appendingPathComponent("template") @@ -2257,7 +2257,7 @@ class ConvertActionTests: XCTestCase { let targetDirectory = URL(fileURLWithPath: testDataProvider.currentDirectoryPath) .appendingPathComponent("target", isDirectory: true) - var action = try ConvertAction( + let action = try ConvertAction( documentationBundleURL: bundle.absoluteURL, outOfProcessResolver: nil, analyze: true, @@ -2291,7 +2291,7 @@ class ConvertActionTests: XCTestCase { // TODO: Support TestFileSystem in DiagnosticFileWriter let diagnosticFile = try createTemporaryDirectory().appendingPathComponent("test-diagnostics.json") - var action = try ConvertAction( + let action = try ConvertAction( documentationBundleURL: bundle.absoluteURL, outOfProcessResolver: nil, analyze: true, @@ -2363,7 +2363,7 @@ class ConvertActionTests: XCTestCase { let digestFileURL = targetDirectory .appendingPathComponent("diagnostics.json") - var action = try ConvertAction( + let action = try ConvertAction( documentationBundleURL: bundle.absoluteURL, outOfProcessResolver: nil, analyze: false, @@ -2394,7 +2394,7 @@ class ConvertActionTests: XCTestCase { let targetDirectory = temporaryDirectory.appendingPathComponent("target", isDirectory: true) - var action = try ConvertAction( + let action = try ConvertAction( documentationBundleURL: catalogURL, outOfProcessResolver: nil, analyze: false, @@ -2530,7 +2530,7 @@ class ConvertActionTests: XCTestCase { let targetDirectory = temporaryDirectory.appendingPathComponent("target.doccarchive", isDirectory: true) - var action = try ConvertAction( + let action = try ConvertAction( documentationBundleURL: catalogURL, outOfProcessResolver: nil, analyze: false, @@ -2825,7 +2825,7 @@ class ConvertActionTests: XCTestCase { } func testConvertWithoutBundleDerivesDisplayNameAndIdentifierFromSingleModuleSymbolGraph() async throws { - let myKitSymbolGraph = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let myKitSymbolGraph = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json") XCTAssert(FileManager.default.fileExists(atPath: myKitSymbolGraph.path)) @@ -2859,7 +2859,7 @@ class ConvertActionTests: XCTestCase { } func testConvertWithoutBundleErrorsForMultipleModulesSymbolGraph() async throws { - let testBundle = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let testBundle = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let myKitSymbolGraph = testBundle .appendingPathComponent("mykit-iOS.symbols.json") let sideKitSymbolGraph = testBundle diff --git a/Tests/SwiftDocCUtilitiesTests/IndexActionTests.swift b/Tests/SwiftDocCUtilitiesTests/IndexActionTests.swift index 5bd3303ad0..982794eaea 100644 --- a/Tests/SwiftDocCUtilitiesTests/IndexActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/IndexActionTests.swift @@ -19,7 +19,7 @@ class IndexActionTests: XCTestCase { #if !os(iOS) func testIndexActionOutputIsDeterministic() async throws { // Convert a test bundle as input for the IndexAction - let bundleURL = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let bundleURL = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let targetURL = try createTemporaryDirectory() let templateURL = try createTemporaryDirectory().appendingPathComponent("template") diff --git a/Tests/SwiftDocCUtilitiesTests/PreviewActionIntegrationTests.swift b/Tests/SwiftDocCUtilitiesTests/PreviewActionIntegrationTests.swift index 9e25ec6ed3..82e991b994 100644 --- a/Tests/SwiftDocCUtilitiesTests/PreviewActionIntegrationTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/PreviewActionIntegrationTests.swift @@ -24,7 +24,7 @@ class PreviewActionIntegrationTests: XCTestCase { forResource: "image", withExtension: "png", subdirectory: "Test Resources")! let symbolURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! .appendingPathComponent("mykit-iOS.symbols.json") // Write source documentation bundle. diff --git a/Tests/SwiftDocCUtilitiesTests/StaticHostableTransformerTests.swift b/Tests/SwiftDocCUtilitiesTests/StaticHostableTransformerTests.swift index edce10b200..d348e37791 100644 --- a/Tests/SwiftDocCUtilitiesTests/StaticHostableTransformerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/StaticHostableTransformerTests.swift @@ -20,7 +20,7 @@ class StaticHostableTransformerTests: StaticHostingBaseTests { func testStaticHostableTransformerOutput() async throws { // Convert a test bundle as input for the StaticHostableTransformer - let bundleURL = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let bundleURL = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let targetURL = try createTemporaryDirectory() let fileManager = FileManager.default @@ -123,7 +123,7 @@ class StaticHostableTransformerTests: StaticHostingBaseTests { func testStaticHostableTransformerIndexHTMLOutput() async throws { // Convert a test bundle as input for the StaticHostableTransformer - let bundleURL = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let bundleURL = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let targetURL = try createTemporaryDirectory() let templateURL = try createTemporaryDirectory().appendingPathComponent("template") diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/Default Code Listing Syntax.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/Default Code Listing Syntax.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/Default Code Listing Syntax.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/Default Code Listing Syntax.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/FillIntroduced.symbols.json b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/FillIntroduced.symbols.json similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/FillIntroduced.symbols.json rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/FillIntroduced.symbols.json diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/Info.plist b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/Info.plist similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/Info.plist rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/Info.plist diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/MyKit@SideKit.symbols.json b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/MyKit@SideKit.symbols.json similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/MyKit@SideKit.symbols.json rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/MyKit@SideKit.symbols.json diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TestOverview.tutorial b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TestOverview.tutorial similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TestOverview.tutorial rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TestOverview.tutorial diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TestTutorial.tutorial b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TestTutorial.tutorial similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TestTutorial.tutorial rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TestTutorial.tutorial diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TestTutorial2.tutorial b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TestTutorial2.tutorial similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TestTutorial2.tutorial rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TestTutorial2.tutorial diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TestTutorialArticle.tutorial b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TestTutorialArticle.tutorial similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TestTutorialArticle.tutorial rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TestTutorialArticle.tutorial diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TutorialMediaWithSpaces.tutorial b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TutorialMediaWithSpaces.tutorial similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/TutorialMediaWithSpaces.tutorial rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/TutorialMediaWithSpaces.tutorial diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/article.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/article.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/article.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/article.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/article2.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/article2.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/article2.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/article2.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/article3.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/article3.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/article3.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/article3.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/myclass.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/myclass.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/myclass.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/myclass.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/mykit.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/mykit.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/mykit.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/mykit.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/myprotocol.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/myprotocol.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/myprotocol.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/myprotocol.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/sideclass-init.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/sideclass-init.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/sideclass-init.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/sideclass-init.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/sidekit.md b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/sidekit.md similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/documentation/sidekit.md rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/documentation/sidekit.md diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/figure1.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/figure1.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/figure1.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/figure1.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/figure1~dark.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/figure1~dark.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/figure1~dark.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/figure1~dark.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld.swift b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld.swift similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld.swift rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld.swift diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld1.swift b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld1.swift similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld1.swift rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld1.swift diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld2.swift b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld2.swift similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld2.swift rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld2.swift diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld3.swift b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld3.swift similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld3.swift rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld3.swift diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld4.swift b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld4.swift similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/helloworld4.swift rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/helloworld4.swift diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/intro.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/intro.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/intro.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/intro.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/introposter.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/introposter.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/introposter.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/introposter.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/introposter2.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/introposter2.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/introposter2.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/introposter2.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/introvideo.mp4 b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/introvideo.mp4 similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/introvideo.mp4 rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/introvideo.mp4 diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/introvideo~dark.mp4 b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/introvideo~dark.mp4 similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/introvideo~dark.mp4 rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/introvideo~dark.mp4 diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/mykit-iOS.symbols.json b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/mykit-iOS.symbols.json similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/mykit-iOS.symbols.json rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/mykit-iOS.symbols.json diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/project.zip b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/project.zip similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/project.zip rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/project.zip diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/sidekit.symbols.json b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/sidekit.symbols.json similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/sidekit.symbols.json rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/sidekit.symbols.json diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/something@2x.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/something@2x.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/something@2x.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/something@2x.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/step.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/step.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/step.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/step.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/titled2up.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/titled2up.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/titled2up.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/titled2up.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/titled2upCapital.PNG b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/titled2upCapital.PNG similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/titled2upCapital.PNG rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/titled2upCapital.PNG diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/with spaces.mp4 b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/with spaces.mp4 similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/with spaces.mp4 rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/with spaces.mp4 diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/with spaces.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/with spaces.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/with spaces.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/with spaces.png diff --git a/Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/with spaces@2x.png b/Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/with spaces@2x.png similarity index 100% rename from Tests/SwiftDocCUtilitiesTests/Test Bundles/TestBundle.docc/with spaces@2x.png rename to Tests/SwiftDocCUtilitiesTests/Test Bundles/LegacyBundle_DoNotUseInNewTests.docc/with spaces@2x.png diff --git a/Tests/SwiftDocCUtilitiesTests/TransformForStaticHostingActionTests.swift b/Tests/SwiftDocCUtilitiesTests/TransformForStaticHostingActionTests.swift index cab542addc..912e5824a7 100644 --- a/Tests/SwiftDocCUtilitiesTests/TransformForStaticHostingActionTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/TransformForStaticHostingActionTests.swift @@ -20,7 +20,7 @@ class TransformForStaticHostingActionTests: StaticHostingBaseTests { func testTransformForStaticHostingTestExternalOutput() async throws { // Convert a test bundle as input for the TransformForStaticHostingAction - let bundleURL = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let bundleURL = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let targetURL = try createTemporaryDirectory() let templateURL = try createTemporaryDirectory().appendingPathComponent("template") @@ -100,7 +100,7 @@ class TransformForStaticHostingActionTests: StaticHostingBaseTests { func testTransformForStaticHostingActionTestInPlaceOutput() async throws { // Convert a test bundle as input for the TransformForStaticHostingAction - let bundleURL = Bundle.module.url(forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + let bundleURL = Bundle.module.url(forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! let targetURL = try createTemporaryDirectory() let fileManager = FileManager.default diff --git a/Tests/SwiftDocCUtilitiesTests/Utility/FileTests.swift b/Tests/SwiftDocCUtilitiesTests/Utility/FileTests.swift index f2fc22fa34..c8f3f2ead0 100644 --- a/Tests/SwiftDocCUtilitiesTests/Utility/FileTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/Utility/FileTests.swift @@ -23,7 +23,7 @@ class FileTests: XCTestCase { func testCreateFromDisk() throws { let testBundleURL = Bundle.module.url( - forResource: "TestBundle", withExtension: "docc", subdirectory: "Test Bundles")! + forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")! // Generates a list of all paths recursively inside a folder func pathsIn(folder: Folder, url: URL) -> [String] {