From e2a83255ac1bae438aae1c2ae660f116f76a9851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Thu, 16 Jan 2025 10:43:40 +0100 Subject: [PATCH 1/5] Silence warning about concurrent access to reference in a DispatchQueue --- Sources/SwiftDocC/Indexing/Navigator/NavigatorTree.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/SwiftDocC/Indexing/Navigator/NavigatorTree.swift b/Sources/SwiftDocC/Indexing/Navigator/NavigatorTree.swift index 95d71a53c4..164e2f5f57 100644 --- a/Sources/SwiftDocC/Indexing/Navigator/NavigatorTree.swift +++ b/Sources/SwiftDocC/Indexing/Navigator/NavigatorTree.swift @@ -119,7 +119,12 @@ public class NavigatorTree { func __read() { let deadline = DispatchTime.now() + timeout +#if swift(>=5.10) + // Access to this local variable is synchronized using the DispatchQueue `queue`, passed as an argument. + nonisolated(unsafe) var processedNodes = [NavigatorTree.Node]() +#else var processedNodes = [NavigatorTree.Node]() +#endif while readingCursor.cursor < readingCursor.data.count { let length = MemoryLayout.stride From 66e5e673412a6a549bbde0872e4cc7159fd82626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Thu, 16 Jan 2025 10:44:08 +0100 Subject: [PATCH 2/5] Avoid deprecation warning when assigning `nil` to deprecated property --- .../SwiftDocC/Indexing/Navigator/NavigatorIndex.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift b/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift index 503d4e0611..3803cf172e 100644 --- a/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift +++ b/Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift @@ -479,7 +479,11 @@ extension NavigatorIndex { /// The data provider. @available(*, deprecated, message: "This deprecated API will be removed after 6.2 is released") - public let renderNodeProvider: RenderNodeProvider? + public var renderNodeProvider: RenderNodeProvider? { + _renderNodeProvider as! RenderNodeProvider? + } + // This property only exist to be able to assign `nil` to `renderNodeProvider` in the new initializer without causing a deprecation warning. + private let _renderNodeProvider: Any? /// The documentation archive to build an index from. public let archiveURL: URL? @@ -575,7 +579,7 @@ extension NavigatorIndex { /// - usePageTitle: Configure the builder to use the "page title" instead of the "navigator title" as the title for each entry. public init(archiveURL: URL? = nil, outputURL: URL, bundleIdentifier: String, sortRootChildrenByName: Bool = false, groupByLanguage: Bool = false, writePathsOnDisk: Bool = true, usePageTitle: Bool = false) { self.archiveURL = archiveURL - self.renderNodeProvider = nil + self._renderNodeProvider = nil self.outputURL = outputURL self.bundleIdentifier = bundleIdentifier self.sortRootChildrenByName = sortRootChildrenByName @@ -587,7 +591,7 @@ extension NavigatorIndex { @available(*, deprecated, renamed: "init(archiveURL:outputURL:bundleIdentifier:sortRootChildrenByName:groupByLanguage:writePathsOnDisk:usePageTitle:)", message: "Use 'init(archiveURL:outputURL:bundleIdentifier:sortRootChildrenByName:groupByLanguage:writePathsOnDisk:usePageTitle:)' instead. This deprecated API will be removed after 6.2 is released") @_disfavoredOverload public init(renderNodeProvider: RenderNodeProvider? = nil, outputURL: URL, bundleIdentifier: String, sortRootChildrenByName: Bool = false, groupByLanguage: Bool = false, writePathsOnDisk: Bool = true, usePageTitle: Bool = false) { - self.renderNodeProvider = renderNodeProvider + self._renderNodeProvider = renderNodeProvider self.archiveURL = nil self.outputURL = outputURL self.bundleIdentifier = bundleIdentifier From aaf5245b085c858b498a73ed3016fe5b0ae513d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Thu, 16 Jan 2025 11:05:35 +0100 Subject: [PATCH 3/5] Avoid warning about capture of non-sendable type in preview HTTP handler Note: this requires SwiftNIO 2.78.0 or later Also, remove unused non-sendable HTTP handlers in tests --- Package.resolved | 8 ++++---- Package.swift | 2 +- .../PreviewServer/PreviewHTTPHandler.swift | 2 +- .../PreviewServer/PreviewHTTPHandlerTests.swift | 2 -- .../PreviewServer/ServerTestUtils.swift | 2 -- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Package.resolved b/Package.resolved index 84d2740c95..e1588fd3b8 100644 --- a/Package.resolved +++ b/Package.resolved @@ -95,8 +95,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "fc79798d5a150d61361a27ce0c51169b889e23de", - "version" : "2.68.0" + "revision" : "ba72f31e11275fc5bf060c966cf6c1f36842a291", + "version" : "2.79.0" } }, { @@ -104,8 +104,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-system.git", "state" : { - "revision" : "6a9e38e7bd22a3b8ba80bddf395623cf68f57807", - "version" : "1.3.1" + "revision" : "c8a44d836fe7913603e246acab7c528c2e780168", + "version" : "1.4.0" } } ], diff --git a/Package.swift b/Package.swift index 1d09552a5f..f3f0364a79 100644 --- a/Package.swift +++ b/Package.swift @@ -129,7 +129,7 @@ let package = Package( if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { // Building standalone, so fetch all dependencies remotely. package.dependencies += [ - .package(url: "https://github.com/apple/swift-nio.git", from: "2.53.0"), + .package(url: "https://github.com/apple/swift-nio.git", from: "2.78.0"), .package(url: "https://github.com/apple/swift-markdown.git", branch: "main"), .package(url: "https://github.com/apple/swift-lmdb.git", branch: "main"), .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"), diff --git a/Sources/SwiftDocCUtilities/PreviewServer/PreviewHTTPHandler.swift b/Sources/SwiftDocCUtilities/PreviewServer/PreviewHTTPHandler.swift index d0d36db8d7..3d19b854ab 100644 --- a/Sources/SwiftDocCUtilities/PreviewServer/PreviewHTTPHandler.swift +++ b/Sources/SwiftDocCUtilities/PreviewServer/PreviewHTTPHandler.swift @@ -111,7 +111,7 @@ final class PreviewHTTPHandler: ChannelInboundHandler { // If we don't need to keep the connection alive, close `context` after flushing the response if !self.keepAlive { - promise.futureResult.whenComplete { _ in context.close(promise: nil) } + promise.futureResult.assumeIsolated().whenComplete { _ in context.close(promise: nil) } } context.writeAndFlush(self.wrapOutboundOut(.end(trailers)), promise: promise) diff --git a/Tests/SwiftDocCUtilitiesTests/PreviewServer/PreviewHTTPHandlerTests.swift b/Tests/SwiftDocCUtilitiesTests/PreviewServer/PreviewHTTPHandlerTests.swift index 51165db4a7..0a142f0372 100644 --- a/Tests/SwiftDocCUtilitiesTests/PreviewServer/PreviewHTTPHandlerTests.swift +++ b/Tests/SwiftDocCUtilitiesTests/PreviewServer/PreviewHTTPHandlerTests.swift @@ -33,10 +33,8 @@ class PreviewHTTPHandlerTests: XCTestCase { let response = Response() - XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPResponseEncoder()).wait()) XCTAssertNoThrow(try channel.pipeline.addHandler(response).wait()) XCTAssertNoThrow(try channel.pipeline.addHandler(channelHandler).wait()) - XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPServerPipelineHandler()).wait()) XCTAssertNoThrow(try channel.connect(to: SocketAddress(ipAddress: "127.0.0.1", port: 1)).wait()) diff --git a/Tests/SwiftDocCUtilitiesTests/PreviewServer/ServerTestUtils.swift b/Tests/SwiftDocCUtilitiesTests/PreviewServer/ServerTestUtils.swift index 373c1e0669..f34d5a81e5 100644 --- a/Tests/SwiftDocCUtilitiesTests/PreviewServer/ServerTestUtils.swift +++ b/Tests/SwiftDocCUtilitiesTests/PreviewServer/ServerTestUtils.swift @@ -92,10 +92,8 @@ func responseWithPipeline(request: HTTPRequestHead, handler factory: RequestHand let response = Response() - XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPResponseEncoder()).wait(), file: (file), line: line) XCTAssertNoThrow(try channel.pipeline.addHandler(response).wait(), file: (file), line: line) XCTAssertNoThrow(try channel.pipeline.addHandler(channelHandler).wait(), file: (file), line: line) - XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPServerPipelineHandler()).wait(), file: (file), line: line) XCTAssertNoThrow(try channel.connect(to: SocketAddress(ipAddress: "127.0.0.1", port: 1)).wait(), file: (file), line: line) From c2a018ed2922458ba2c7f6695e55805161653ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Thu, 16 Jan 2025 11:34:55 +0100 Subject: [PATCH 4/5] Don't check license headers in "./bin/benchmark/.build/*" --- bin/check-source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/check-source b/bin/check-source index 733f0432bd..481511aa2c 100755 --- a/bin/check-source +++ b/bin/check-source @@ -44,7 +44,6 @@ for language in swift-or-c bash md-or-tutorial html docker; do declare -a matching_files declare -a exceptions declare -a reader - expections=( ) matching_files=( -name '*' ) reader=head case "$language" in @@ -136,6 +135,7 @@ EOF cd "$here/.." find . \ \( \! -path './.build/*' -a \ + \! -path './bin/benchmark/.build/*' -a \ \! -name '.' -a \ \( "${matching_files[@]}" \) -a \ \( \! \( "${exceptions[@]}" \) \) \) | while read line; do From 296fe6a4b5f2a55ac9ecb18796d0e7c5ac9f2093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Thu, 16 Jan 2025 11:37:41 +0100 Subject: [PATCH 5/5] Avoid passing non-sendable FileManager into addTeardownBlock in test --- .../XCTestCase+TemporaryDirectory.swift | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Sources/SwiftDocCTestUtilities/XCTestCase+TemporaryDirectory.swift b/Sources/SwiftDocCTestUtilities/XCTestCase+TemporaryDirectory.swift index 2389e18798..a439987a3f 100644 --- a/Sources/SwiftDocCTestUtilities/XCTestCase+TemporaryDirectory.swift +++ b/Sources/SwiftDocCTestUtilities/XCTestCase+TemporaryDirectory.swift @@ -36,9 +36,8 @@ public extension XCTestCase { /// /// - Parameters: /// - pathComponents: The name of the temporary directory. - /// - fileManager: The file manager that will create the directory. /// - Returns: The URL of the newly created directory. - func createTemporaryDirectory(named: String, fileManager: FileManager = .default) throws -> URL { + func createTemporaryDirectory(named: String) throws -> URL { try createTemporaryDirectory(pathComponents: named) } @@ -48,9 +47,8 @@ public extension XCTestCase { /// /// - Parameters: /// - pathComponents: Additional path components to add to the temporary URL. - /// - fileManager: The file manager that will create the directory. /// - Returns: The URL of the newly created directory. - func createTemporaryDirectory(pathComponents: String..., fileManager: FileManager = .default) throws -> URL { + func createTemporaryDirectory(pathComponents: String...) throws -> URL { let bundleParentDir = Bundle(for: Self.self).bundleURL.deletingLastPathComponent() let baseURL = bundleParentDir.appendingPathComponent(name.replacingWhitespaceAndPunctuation(with: "-")) @@ -62,20 +60,20 @@ public extension XCTestCase { addTeardownBlock { do { - if fileManager.fileExists(atPath: baseURL.path) { - try fileManager.removeItem(at: baseURL) + if FileManager.default.fileExists(atPath: baseURL.path) { + try FileManager.default.removeItem(at: baseURL) } } catch { XCTFail("Failed to remove temporary directory: '\(error)'") } } - if !fileManager.fileExists(atPath: bundleParentDir.path) { + if !FileManager.default.fileExists(atPath: bundleParentDir.path) { // Create the base URL directory without intermediate directories so that an error is raised if the parent directory doesn't exist. - try fileManager.createDirectory(at: baseURL, withIntermediateDirectories: false, attributes: nil) + try FileManager.default.createDirectory(at: baseURL, withIntermediateDirectories: false, attributes: nil) } - try fileManager.createDirectory(at: tempURL, withIntermediateDirectories: true, attributes: nil) + try FileManager.default.createDirectory(at: tempURL, withIntermediateDirectories: true, attributes: nil) return tempURL }