Skip to content

Commit 8faf0d3

Browse files
committed
Remove linux-specific code and enable tests that pass on linux
1 parent ff972f1 commit 8faf0d3

File tree

6 files changed

+2
-80
lines changed

6 files changed

+2
-80
lines changed

Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
import Foundation
1212
import Crypto
1313

14-
// Fallback solution for Linux as it has no PropertyList support.
15-
#if os(Linux)
16-
fileprivate typealias PropertyListEncoder = JSONEncoder
17-
fileprivate typealias PropertyListDecoder = JSONDecoder
18-
#endif
19-
2014
/// A protocol to provide data to be indexed.
2115
public protocol RenderNodeProvider {
2216
/// Get an instance of `RenderNode` to be processed by the index.

Sources/SwiftDocC/Infrastructure/Workspace/LocalFileSystemDataProvider.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ public struct LocalFileSystemDataProvider: DocumentationWorkspaceDataProvider, F
3131
/// - Returns: A virtual file system that describe the file and directory structure within the given URL.
3232
private static func buildTree(root: URL) throws -> FSNode {
3333
var children: [FSNode] = []
34-
#if os(Linux)
35-
// Resource values and enumeration options aren't implemented on Linux.
36-
let childURLs = try FileManager.default.contentsOfDirectory(at: root, includingPropertiesForKeys: [URLResourceKey.isDirectoryKey], options: .init())
37-
#else
3834
let childURLs = try FileManager.default.contentsOfDirectory(at: root, includingPropertiesForKeys: [URLResourceKey.isDirectoryKey], options: .skipsHiddenFiles)
39-
#endif
4035

4136
for url in childURLs {
4237
if FileManager.default.directoryExists(atPath: url.path) {

Sources/SwiftDocC/Model/Rendering/RenderContext.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,14 @@ public struct RenderContext {
6060
renderReferenceDependencies: dependencies
6161
)
6262
}
63-
64-
#if os(macOS) || os(iOS)
65-
// Concurrently render content on macOS & iOS
63+
6664
let results: [(reference: ResolvedTopicReference, content: RenderReferenceStore.TopicContent)] = references.concurrentPerform { reference, results in
6765
results.append((reference, renderContentFor(reference)))
6866
}
6967
for result in results {
7068
topics[result.reference] = result.content
7169
}
72-
73-
#elseif os(Linux)
74-
// Serially render on Linux
75-
references.forEach {
76-
topics[$0] = renderContentFor($0)
77-
}
78-
#else
79-
#error("Unexpected platform.")
80-
#endif
81-
70+
8271
let assets = documentationContext.assetManagers
8372
.reduce(into: [AssetReference: DataAsset]()) { (storage, element) in
8473
let (bundleIdentifer, assetManager) = element

Sources/SwiftDocC/Utility/LinuxBundleShims.swift

Lines changed: 0 additions & 18 deletions
This file was deleted.

Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,6 @@ class ConvertServiceTests: XCTestCase {
700700
}
701701

702702
func testReturnsRenderReferenceStoreWhenRequestedForOnDiskBundleWithUncuratedArticles() throws {
703-
#if os(Linux)
704-
throw XCTSkip("""
705-
Skipped on Linux due to an issue in Foundation.Codable where dictionaries are sometimes getting encoded as \
706-
arrays. (SR-15036)
707-
""")
708-
#else
709703
let (testBundleURL, _, _) = try testBundleAndContext(
710704
copying: "TestBundle",
711705
excludingPaths: [
@@ -826,16 +820,9 @@ class ConvertServiceTests: XCTestCase {
826820
}
827821
}
828822
)
829-
#endif
830823
}
831824

832825
func testNoRenderReferencesToNonLinkableNodes() throws {
833-
#if os(Linux)
834-
throw XCTSkip("""
835-
Skipped on Linux due to an issue in Foundation.Codable where dictionaries are sometimes getting encoded as \
836-
arrays. (SR-15036)
837-
""")
838-
#else
839826
let (testBundleURL, _, _) = try testBundleAndContext(
840827
copying: "TestBundle",
841828
excludingPaths: [
@@ -876,16 +863,9 @@ class ConvertServiceTests: XCTestCase {
876863
}
877864

878865
)
879-
#endif
880866
}
881867

882868
func testReturnsRenderReferenceStoreWhenRequestedForOnDiskBundleWithCuratedArticles() throws {
883-
#if os(Linux)
884-
throw XCTSkip("""
885-
Skipped on Linux due to an issue in Foundation.Codable where dictionaries are sometimes getting encoded as \
886-
arrays. (SR-15036)
887-
""")
888-
#else
889869
let (testBundleURL, _, _) = try testBundleAndContext(
890870
// Use a bundle that contains only articles, one of which is declared as the TechnologyRoot and curates the
891871
// other articles.
@@ -939,7 +919,6 @@ class ConvertServiceTests: XCTestCase {
939919
)
940920
}
941921
)
942-
#endif
943922
}
944923

945924
func testConvertPageWithLinkResolving() throws {

Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ Root
236236
}
237237

238238
func testNavigationTreeLargeDumpAndReadAsync() throws {
239-
#if !os(Linux)
240239
let targetURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(UUID().uuidString)
241240
try FileManager.default.createDirectory(at: targetURL, withIntermediateDirectories: true, attributes: nil)
242241
defer {
@@ -279,11 +278,9 @@ Root
279278
}
280279

281280
XCTAssertTrue(validateTree(node: readTreePresentationIdentifier.root, validator: presentationIdentifierValidator), "The tree lacks the presentation identifier.")
282-
#endif
283281
}
284282

285283
func testNavigatorIndexGenerationEmpty() throws {
286-
#if !os(Linux)
287284
let targetURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(UUID().uuidString)
288285
try FileManager.default.createDirectory(at: targetURL, withIntermediateDirectories: true, attributes: nil)
289286
defer {
@@ -300,11 +297,9 @@ Root
300297

301298
let readTree = NavigatorTree()
302299
XCTAssertThrowsError(try readTree.read(from: indexURL, interfaceLanguages: [.swift], timeout: 0.25, queue: DispatchQueue.main, broadcast: nil))
303-
#endif
304300
}
305301

306302
func testNavigatorIndexGenerationOneNode() throws {
307-
#if !os(Linux)
308303
let targetURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(UUID().uuidString)
309304
try FileManager.default.createDirectory(at: targetURL, withIntermediateDirectories: true, attributes: nil)
310305
defer {
@@ -331,11 +326,9 @@ Root
331326
XCTAssert(counter == 1, "The broadcast callback has to be called at exactly 1 time.")
332327
XCTAssertEqual(original.root.countItems(), readTree.root.countItems())
333328
XCTAssertTrue(compare(lhs: original.root, rhs: readTree.root))
334-
#endif
335329
}
336330

337331
func testNavigatorIndexGenerationOperator() throws {
338-
#if !os(Linux)
339332
let operatorURL = Bundle.module.url(
340333
forResource: "Operator", withExtension: "json", subdirectory: "Test Resources")!
341334

@@ -353,7 +346,6 @@ Root
353346
builder.finalize()
354347

355348
XCTAssertNotNil(builder.navigatorIndex)
356-
#endif
357349
}
358350

359351
func testNavigatorIndexGeneration() throws {
@@ -513,7 +505,6 @@ Root
513505
}
514506

515507
func testNavigatorIndexGenerationWithLanguageGrouping() throws {
516-
#if !os(Linux)
517508
let (bundle, context) = try testBundleAndContext(named: "TestBundle")
518509
let renderContext = RenderContext(documentationContext: context, bundle: bundle)
519510
let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext)
@@ -557,7 +548,6 @@ Root
557548

558549
assertUniqueIDs(node: navigatorIndex.navigatorTree.root)
559550
assertEqualDumps(navigatorIndex.navigatorTree.root.dumpTree(), try testTree(named: "testNavigatorIndexGenerationWithLanguageGrouping"))
560-
#endif
561551
}
562552

563553

@@ -625,7 +615,6 @@ Root
625615
}
626616

627617
func testNavigatorIndexAvailabilityGeneration() throws {
628-
#if !os(Linux)
629618
let (bundle, context) = try testBundleAndContext(named: "TestBundle")
630619
let renderContext = RenderContext(documentationContext: context, bundle: bundle)
631620
let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext)
@@ -720,11 +709,9 @@ Root
720709
let availabilityDB = try navigatorIndex.environment.openDatabase(named: "availability")
721710
XCTAssertThrowsError(try availabilityDB.put(key: "content", value: "test"))
722711
XCTAssertNil(availabilityDB.get(type: String.self, forKey: "content"))
723-
#endif
724712
}
725713

726714
func testNavigatorIndexDifferenHasherGeneration() throws {
727-
#if !os(Linux)
728715
let (bundle, context) = try testBundleAndContext(named: "TestBundle")
729716
let renderContext = RenderContext(documentationContext: context, bundle: bundle)
730717
let converter = DocumentationContextConverter(bundle: bundle, context: context, renderContext: renderContext)
@@ -780,8 +767,6 @@ Root
780767
let sideClassNode = try XCTUnwrap(search(node: navigatorIndex.navigatorTree.root) { navigatorIndex.path(for: $0.id!) == "/documentation/sidekit/sideclass" })
781768
let availabilities = navigatorIndex.availabilities(for: sideClassNode.item.availabilityID)
782769
XCTAssertEqual(availabilities.count, 1)
783-
784-
#endif
785770
}
786771

787772
func testPlatformVersion() {
@@ -1133,7 +1118,6 @@ Root
11331118
}
11341119

11351120
func testNavigatorIndexAsReadOnlyFile() throws {
1136-
#if !os(Linux)
11371121
let (bundle, context) = try testBundleAndContext(named: "TestBundle")
11381122
let converter = DocumentationNodeConverter(bundle: bundle, context: context)
11391123

@@ -1164,7 +1148,6 @@ Root
11641148

11651149
// Make sure we throw if an index can't be opened even after the fallback, avoiding entering an infinite loop.
11661150
XCTAssertThrowsError(try NavigatorIndex(url: targetURL, readNavigatorTree: false))
1167-
#endif
11681151
}
11691152

11701153
func testNavigatorTitle() throws {

0 commit comments

Comments
 (0)