From fd3aef5789a4e37986cd38065abf111ec0494767 Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Fri, 8 Nov 2024 13:52:04 +0000 Subject: [PATCH 1/2] QueryEngine: Calculate stable hashes for Foundation.URL and FoundationEssentials.URL Until Swift 6.0, the fully-qualified name of the URL type was `Foundation.URL`. After the adoption of FoundationEssentials, the name changed to `FoundationEssentials.URL`. This difference causes the hashes to change, so for backwards compatibility we pin the type name to `Foundation.URL`. Fixes #45 --- Sources/Helpers/Vendor/QueryEngine/CacheKey.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/Helpers/Vendor/QueryEngine/CacheKey.swift b/Sources/Helpers/Vendor/QueryEngine/CacheKey.swift index c09b0de..b3c2c05 100644 --- a/Sources/Helpers/Vendor/QueryEngine/CacheKey.swift +++ b/Sources/Helpers/Vendor/QueryEngine/CacheKey.swift @@ -167,7 +167,11 @@ extension FilePath.Component: LeafCacheKey { extension URL: LeafCacheKey { func hash(with hashFunction: inout some HashFunction) { - String(reflecting: Self.self).hash(with: &hashFunction) + // Until Swift 6.0, the fully-qualified name of the URL type was `Foundation.URL`. + // After the adoption of FoundationEssentials, the name changed to `FoundationEssentials.URL`. + // This difference causes the hashes to change, so for backwards compatibility we pin the + // type name to `Foundation.URL`. + "Foundation.URL".hash(with: &hashFunction) self.description.hash(with: &hashFunction) } } From 95b78b4df5c04e79b84fb2878163950b436fa14b Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Fri, 8 Nov 2024 09:27:47 +0000 Subject: [PATCH 2/2] tests: Run tests on Linux CI The EndToEnd tests cannot currently be run: * they deadlock when run under `swift test` (#143) * the CI requires the use of an HTTP proxy to download from the Internet, but SDK generator does not support proxies (#145) The tests are not compiled on macOS, but this commit marks them with `XCTSkip` so they are not run on Linux either. Future commits will loosen these restrictions. Fixes #45 --- Docker/docker-compose.yaml | 2 +- .../EndToEndTests.swift | 4 ++++ Utilities/test.sh | 20 ------------------- 3 files changed, 5 insertions(+), 21 deletions(-) delete mode 100755 Utilities/test.sh diff --git a/Docker/docker-compose.yaml b/Docker/docker-compose.yaml index 88af3c9..18e3832 100644 --- a/Docker/docker-compose.yaml +++ b/Docker/docker-compose.yaml @@ -25,7 +25,7 @@ services: test: <<: *common - command: /bin/bash -xcl "./Utilities/test.sh $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-}" + command: /bin/bash -xcl "swift test $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-}" # util diff --git a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift index 513ac98..c839349 100644 --- a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift +++ b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift @@ -39,6 +39,8 @@ final class EndToEndTests: XCTestCase { #if !os(macOS) func testPackageInitExecutable() async throws { + throw XCTSkip("EndToEnd tests currently deadlock under `swift test`: https://github.com/swiftlang/swift-sdk-generator/issues/143") + let fm = FileManager.default var packageDirectory = FilePath(#filePath) @@ -102,6 +104,8 @@ final class EndToEndTests: XCTestCase { } func testRepeatedSDKBuilds() async throws { + throw XCTSkip("EndToEnd tests currently deadlock under `swift test`: https://github.com/swiftlang/swift-sdk-generator/issues/143") + let fm = FileManager.default var packageDirectory = FilePath(#filePath) diff --git a/Utilities/test.sh b/Utilities/test.sh deleted file mode 100755 index 0c34e4d..0000000 --- a/Utilities/test.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -##===----------------------------------------------------------------------===## -## -## This source file is part of the Swift open source project -## -## Copyright (c) YEARS Apple Inc. and the Swift project authors -## Licensed under Apache License v2.0 with Runtime Library Exception -## -## See https://swift.org/LICENSE.txt for license information -## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -## -##===----------------------------------------------------------------------===## - -set -ex - -if [ "$(uname)" = Darwin ]; then - swift test $@ -else - swift build --build-tests $@ -fi