From 6661903b189505602b51c2aae8c0d6bda95cb3c7 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 13 Aug 2025 17:11:42 -0400 Subject: [PATCH] Linux support --- .github/workflows/ci.yml | 3 +++ Tests/SkipFoundationTests/CoreLibs/TestDecimal.swift | 2 +- .../Formats/TestAttributedString.swift | 2 +- .../Formats/TestAttributedStringPerformance.swift | 2 +- .../Formats/TestXMLDocument.swift | 3 +++ .../SkipFoundationTests/Formats/TestXMLParser.swift | 3 +++ .../Formatters/TestRelativeDateTimeFormatter.swift | 4 ++++ .../SkipFoundationTests/Foundation/BundleTests.swift | 5 +---- Tests/SkipFoundationTests/Foundation/DateTests.swift | 3 +++ .../SkipFoundationTests/Foundation/DigestTests.swift | 2 ++ Tests/SkipFoundationTests/Foundation/JSONTests.swift | 3 --- .../SkipFoundationTests/Foundation/LocaleTests.swift | 4 ++++ .../SkipFoundationTests/Foundation/LoggerTests.swift | 2 ++ .../Network/TestCachedURLResponse.swift | 3 +++ .../Network/TestDataURLProtocol.swift | 3 +++ .../SkipFoundationTests/Network/TestHTTPCookie.swift | 3 +++ .../Network/TestHTTPCookieStorage.swift | 3 +++ .../Network/TestHTTPURLResponse.swift | 3 +++ Tests/SkipFoundationTests/Network/TestHost.swift | 3 +++ .../SkipFoundationTests/Network/TestSocketPort.swift | 3 +++ Tests/SkipFoundationTests/Network/TestURL.swift | 3 +++ Tests/SkipFoundationTests/Network/TestURLCache.swift | 3 +++ .../Network/TestURLComponents.swift | 3 +++ .../Network/TestURLCredential.swift | 3 +++ .../Network/TestURLCredentialStorage.swift | 3 +++ .../Network/TestURLProtectionSpace.swift | 3 +++ .../SkipFoundationTests/Network/TestURLRequest.swift | 3 +++ .../Network/TestURLResponse.swift | 3 +++ .../SkipFoundationTests/Network/TestURLSession.swift | 7 +++++++ Tests/SkipFoundationTests/SkipFoundationTests.swift | 6 ++++++ .../System/TestNotificationCenter.swift | 4 ++++ Tests/SkipFoundationTests/System/TestThread.swift | 12 ++++++++++++ Tests/SkipFoundationTests/XCSkipTests.swift | 2 +- 33 files changed, 103 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e476c69..ba7da9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,3 +14,6 @@ permissions: jobs: call-workflow: uses: skiptools/actions/.github/workflows/skip-framework.yml@v1 + with: + runs-on: "['macos-13', 'ubuntu-24.04']" + diff --git a/Tests/SkipFoundationTests/CoreLibs/TestDecimal.swift b/Tests/SkipFoundationTests/CoreLibs/TestDecimal.swift index 6890350..df8d69d 100644 --- a/Tests/SkipFoundationTests/CoreLibs/TestDecimal.swift +++ b/Tests/SkipFoundationTests/CoreLibs/TestDecimal.swift @@ -3,7 +3,7 @@ import Foundation import XCTest -#if !SKIP // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size +#if !SKIP && canImport(Darwin) // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Formats/TestAttributedString.swift b/Tests/SkipFoundationTests/Formats/TestAttributedString.swift index 6d0750e..828ba99 100644 --- a/Tests/SkipFoundationTests/Formats/TestAttributedString.swift +++ b/Tests/SkipFoundationTests/Formats/TestAttributedString.swift @@ -3,7 +3,7 @@ import Foundation import XCTest -#if !SKIP // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size +#if !SKIP && canImport(Darwin) // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Formats/TestAttributedStringPerformance.swift b/Tests/SkipFoundationTests/Formats/TestAttributedStringPerformance.swift index 671f01c..853b5de 100644 --- a/Tests/SkipFoundationTests/Formats/TestAttributedStringPerformance.swift +++ b/Tests/SkipFoundationTests/Formats/TestAttributedStringPerformance.swift @@ -3,7 +3,7 @@ import Foundation import XCTest -#if !SKIP +#if canImport(Darwin) // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: //===----------------------------------------------------------------------===// diff --git a/Tests/SkipFoundationTests/Formats/TestXMLDocument.swift b/Tests/SkipFoundationTests/Formats/TestXMLDocument.swift index b95700a..0af5396 100644 --- a/Tests/SkipFoundationTests/Formats/TestXMLDocument.swift +++ b/Tests/SkipFoundationTests/Formats/TestXMLDocument.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationXML) +import FoundationXML +#endif import XCTest #if !SKIP // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size diff --git a/Tests/SkipFoundationTests/Formats/TestXMLParser.swift b/Tests/SkipFoundationTests/Formats/TestXMLParser.swift index 833aabd..ce115d2 100644 --- a/Tests/SkipFoundationTests/Formats/TestXMLParser.swift +++ b/Tests/SkipFoundationTests/Formats/TestXMLParser.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationXML) +import FoundationXML +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Formatters/TestRelativeDateTimeFormatter.swift b/Tests/SkipFoundationTests/Formatters/TestRelativeDateTimeFormatter.swift index d2f6235..b2e9484 100644 --- a/Tests/SkipFoundationTests/Formatters/TestRelativeDateTimeFormatter.swift +++ b/Tests/SkipFoundationTests/Formatters/TestRelativeDateTimeFormatter.swift @@ -3,6 +3,8 @@ import Foundation import XCTest +#if SKIP || canImport(Darwin) + fileprivate typealias CaseRelativeFormat = (numericFull: String, namedShort: String, namedAbbreviated: String, dateComponents: DateComponents, timeInterval: TimeInterval) /// Kotlin formats time intervals approaching/at 0 as "x ago" @@ -297,3 +299,5 @@ class TestRelativeDateTimeFormatter: XCTestCase { return (timeInterval, components, formattedString) } } + +#endif diff --git a/Tests/SkipFoundationTests/Foundation/BundleTests.swift b/Tests/SkipFoundationTests/Foundation/BundleTests.swift index a32507b..1a7baad 100644 --- a/Tests/SkipFoundationTests/Foundation/BundleTests.swift +++ b/Tests/SkipFoundationTests/Foundation/BundleTests.swift @@ -1,19 +1,16 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation -import OSLog import XCTest @available(macOS 13, iOS 16, watchOS 10, tvOS 16, *) final class BundleTests: XCTestCase { - let logger: Logger = Logger(subsystem: "test", category: "BundleTests") - func testBundle() throws { // Swift will be: Contents/Resources/ -- file:///~/Library/Developer/Xcode/DerivedData/DemoApp-ABCDEF/Build/Products/Debug/SkipFoundationTests.xctest/Contents/Resources/Skip_SkipFoundationTests.bundle/ // Kotlin will be: file:///~/Library/Developer/Xcode/DerivedData/DemoApp-ABCDEF/Build/Products/Debug/SkipFoundationTests.xctest/Contents/Resources/skip-foundation_SkipFoundationTests.bundle/Contents/Resources/textasset.txt let resourceURL: URL = try XCTUnwrap(Bundle.module.url(forResource: "textasset", withExtension: "txt", subdirectory: nil, localization: nil)) - logger.info("resourceURL: \(resourceURL.absoluteString)") + //logger.info("resourceURL: \(resourceURL.absoluteString)") let str = try String(contentsOf: resourceURL) XCTAssertEqual("Some text\n", str) } diff --git a/Tests/SkipFoundationTests/Foundation/DateTests.swift b/Tests/SkipFoundationTests/Foundation/DateTests.swift index cd54bff..80b50f6 100644 --- a/Tests/SkipFoundationTests/Foundation/DateTests.swift +++ b/Tests/SkipFoundationTests/Foundation/DateTests.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(CoreFoundation) +import CoreFoundation // for CFAbsoluteTimeGetCurrent() +#endif import XCTest @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) diff --git a/Tests/SkipFoundationTests/Foundation/DigestTests.swift b/Tests/SkipFoundationTests/Foundation/DigestTests.swift index f08b694..18a4a2a 100644 --- a/Tests/SkipFoundationTests/Foundation/DigestTests.swift +++ b/Tests/SkipFoundationTests/Foundation/DigestTests.swift @@ -13,6 +13,7 @@ extension Data { } #endif +#if SKIP || canImport(CryptoKit) // i.e., not Linux @available(macOS 11, iOS 14, watchOS 7, tvOS 14, *) final class DigestTests: XCTestCase { func testSHA256() { @@ -93,4 +94,5 @@ final class DigestTests: XCTestCase { XCTAssertEqual("TrfwQeSZQ8gTfY7U+NQY+CDxexfk6hHVDJ2pevtMM2OXmxY9X/60uWhsXnMym1+vzg7XGgO729yGQgsPdAY19A==", Data(HMACSHA512.authenticationCode(for: Data("Your message to sign".utf8), using: SymmetricKey(data: Data("your-secret-key".utf8)))).base64EncodedString()) } } +#endif diff --git a/Tests/SkipFoundationTests/Foundation/JSONTests.swift b/Tests/SkipFoundationTests/Foundation/JSONTests.swift index 5ec642c..49391c9 100644 --- a/Tests/SkipFoundationTests/Foundation/JSONTests.swift +++ b/Tests/SkipFoundationTests/Foundation/JSONTests.swift @@ -1,13 +1,10 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception -import OSLog import XCTest import Foundation @available(macOS 11, iOS 14, watchOS 7, tvOS 14, *) class TestJSON : XCTestCase { - fileprivate let logger: Logger = Logger(subsystem: "test", category: "TestJSON") - struct StringField : Equatable, Codable { var stringField: String } diff --git a/Tests/SkipFoundationTests/Foundation/LocaleTests.swift b/Tests/SkipFoundationTests/Foundation/LocaleTests.swift index f979f5b..fc1d8f8 100644 --- a/Tests/SkipFoundationTests/Foundation/LocaleTests.swift +++ b/Tests/SkipFoundationTests/Foundation/LocaleTests.swift @@ -3,6 +3,8 @@ import Foundation import XCTest +#if SKIP || canImport(Darwin) + @available(macOS 13, iOS 16, watchOS 10, tvOS 16, *) final class LocaleTests: XCTestCase { func testLanguageCodes() throws { @@ -1051,3 +1053,5 @@ let xcstringsSample = """ } """ +#endif + diff --git a/Tests/SkipFoundationTests/Foundation/LoggerTests.swift b/Tests/SkipFoundationTests/Foundation/LoggerTests.swift index f179167..21a1c85 100644 --- a/Tests/SkipFoundationTests/Foundation/LoggerTests.swift +++ b/Tests/SkipFoundationTests/Foundation/LoggerTests.swift @@ -1,5 +1,6 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception +#if SKIP || canImport(OSLog) import OSLog import XCTest @@ -24,3 +25,4 @@ final class LoggerTests: XCTestCase { logger.error("logger error test") } } +#endif diff --git a/Tests/SkipFoundationTests/Network/TestCachedURLResponse.swift b/Tests/SkipFoundationTests/Network/TestCachedURLResponse.swift index b1c5bdc..c310829 100644 --- a/Tests/SkipFoundationTests/Network/TestCachedURLResponse.swift +++ b/Tests/SkipFoundationTests/Network/TestCachedURLResponse.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestDataURLProtocol.swift b/Tests/SkipFoundationTests/Network/TestDataURLProtocol.swift index d50b83c..a4d9563 100644 --- a/Tests/SkipFoundationTests/Network/TestDataURLProtocol.swift +++ b/Tests/SkipFoundationTests/Network/TestDataURLProtocol.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestHTTPCookie.swift b/Tests/SkipFoundationTests/Network/TestHTTPCookie.swift index 8aa1178..918de6a 100644 --- a/Tests/SkipFoundationTests/Network/TestHTTPCookie.swift +++ b/Tests/SkipFoundationTests/Network/TestHTTPCookie.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest #if !SKIP // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size diff --git a/Tests/SkipFoundationTests/Network/TestHTTPCookieStorage.swift b/Tests/SkipFoundationTests/Network/TestHTTPCookieStorage.swift index 3c0a0b4..5e2bee9 100644 --- a/Tests/SkipFoundationTests/Network/TestHTTPCookieStorage.swift +++ b/Tests/SkipFoundationTests/Network/TestHTTPCookieStorage.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest #if !SKIP // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size diff --git a/Tests/SkipFoundationTests/Network/TestHTTPURLResponse.swift b/Tests/SkipFoundationTests/Network/TestHTTPURLResponse.swift index 9052fbf..7e346f1 100644 --- a/Tests/SkipFoundationTests/Network/TestHTTPURLResponse.swift +++ b/Tests/SkipFoundationTests/Network/TestHTTPURLResponse.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestHost.swift b/Tests/SkipFoundationTests/Network/TestHost.swift index af50f87..7db0d57 100644 --- a/Tests/SkipFoundationTests/Network/TestHost.swift +++ b/Tests/SkipFoundationTests/Network/TestHost.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestSocketPort.swift b/Tests/SkipFoundationTests/Network/TestSocketPort.swift index 8b67f62..c9149ed 100644 --- a/Tests/SkipFoundationTests/Network/TestSocketPort.swift +++ b/Tests/SkipFoundationTests/Network/TestSocketPort.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest #if !SKIP // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size diff --git a/Tests/SkipFoundationTests/Network/TestURL.swift b/Tests/SkipFoundationTests/Network/TestURL.swift index acf4c82..13ec580 100644 --- a/Tests/SkipFoundationTests/Network/TestURL.swift +++ b/Tests/SkipFoundationTests/Network/TestURL.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // TODO: remove '// API marked unavailable for Skip:' portions as we make more API available diff --git a/Tests/SkipFoundationTests/Network/TestURLCache.swift b/Tests/SkipFoundationTests/Network/TestURLCache.swift index 7821e61..ea425aa 100644 --- a/Tests/SkipFoundationTests/Network/TestURLCache.swift +++ b/Tests/SkipFoundationTests/Network/TestURLCache.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest #if !SKIP // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size diff --git a/Tests/SkipFoundationTests/Network/TestURLComponents.swift b/Tests/SkipFoundationTests/Network/TestURLComponents.swift index 9ee2ab7..c1465b7 100644 --- a/Tests/SkipFoundationTests/Network/TestURLComponents.swift +++ b/Tests/SkipFoundationTests/Network/TestURLComponents.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestURLCredential.swift b/Tests/SkipFoundationTests/Network/TestURLCredential.swift index d287f07..bd6b201 100644 --- a/Tests/SkipFoundationTests/Network/TestURLCredential.swift +++ b/Tests/SkipFoundationTests/Network/TestURLCredential.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestURLCredentialStorage.swift b/Tests/SkipFoundationTests/Network/TestURLCredentialStorage.swift index f3f0502..7cd7a61 100644 --- a/Tests/SkipFoundationTests/Network/TestURLCredentialStorage.swift +++ b/Tests/SkipFoundationTests/Network/TestURLCredentialStorage.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest #if !SKIP // disabled for to reduce test count and avoid io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size diff --git a/Tests/SkipFoundationTests/Network/TestURLProtectionSpace.swift b/Tests/SkipFoundationTests/Network/TestURLProtectionSpace.swift index 61db273..d19a5f5 100644 --- a/Tests/SkipFoundationTests/Network/TestURLProtectionSpace.swift +++ b/Tests/SkipFoundationTests/Network/TestURLProtectionSpace.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestURLRequest.swift b/Tests/SkipFoundationTests/Network/TestURLRequest.swift index 48f94c9..5b5b7d9 100644 --- a/Tests/SkipFoundationTests/Network/TestURLRequest.swift +++ b/Tests/SkipFoundationTests/Network/TestURLRequest.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestURLResponse.swift b/Tests/SkipFoundationTests/Network/TestURLResponse.swift index e4df07a..3187425 100644 --- a/Tests/SkipFoundationTests/Network/TestURLResponse.swift +++ b/Tests/SkipFoundationTests/Network/TestURLResponse.swift @@ -1,6 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest // These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/Network/TestURLSession.swift b/Tests/SkipFoundationTests/Network/TestURLSession.swift index 2cf7216..288c3bc 100644 --- a/Tests/SkipFoundationTests/Network/TestURLSession.swift +++ b/Tests/SkipFoundationTests/Network/TestURLSession.swift @@ -1,8 +1,12 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif import XCTest +#if SKIP || canImport(Darwin) // many of these tests don't build for Linux class TestURLSession: XCTestCase { func testDefaultURLSessionConfiguration() { let config = URLSessionConfiguration.default @@ -10,6 +14,7 @@ class TestURLSession: XCTestCase { XCTAssertEqual(60.0, config.timeoutIntervalForRequest) XCTAssertEqual(604800.0, config.timeoutIntervalForResource) XCTAssertEqual(true, config.allowsCellularAccess) + #if !os(Linux) //XCTAssertEqual(true, config.allowsExpensiveNetworkAccess) XCTAssertEqual(true, config.allowsConstrainedNetworkAccess) XCTAssertEqual(false, config.waitsForConnectivity) @@ -17,6 +22,7 @@ class TestURLSession: XCTestCase { XCTAssertEqual(nil, config.sharedContainerIdentifier) XCTAssertEqual(false, config.sessionSendsLaunchEvents) //XCTAssertEqual(nil, config.connectionProxyDictionary) + #endif XCTAssertEqual(false, config.httpShouldUsePipelining) XCTAssertEqual(true, config.httpShouldSetCookies) //XCTAssertEqual(nil, config.httpAdditionalHeaders) @@ -270,6 +276,7 @@ class TestURLSession: XCTestCase { } } } +#endif // //// These tests are adapted from https://github.com/apple/swift-corelibs-foundation/blob/main/Tests/Foundation/Tests which have the following license: diff --git a/Tests/SkipFoundationTests/SkipFoundationTests.swift b/Tests/SkipFoundationTests/SkipFoundationTests.swift index b0eb329..b4374ae 100644 --- a/Tests/SkipFoundationTests/SkipFoundationTests.swift +++ b/Tests/SkipFoundationTests/SkipFoundationTests.swift @@ -1,7 +1,9 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation +#if SKIP || canImport(OSLog) import OSLog +#endif import XCTest #if !SKIP @testable import func SkipFoundation.SkipFoundationInternalModuleName @@ -9,7 +11,9 @@ import XCTest #endif final class SkipFoundationTests: XCTestCase { + #if SKIP || canImport(OSLog) let logger: Logger = Logger(subsystem: "test", category: "SkipFoundationTests") + #endif func testSkipFoundation() throws { XCTAssertEqual(3, 1 + 2) @@ -25,7 +29,9 @@ final class SkipFoundationTests: XCTestCase { if isRobolectric { XCTAssertEqual(value, env[key], "Unexpected value for Robolectric system property \(key): \(env[key] ?? "")") } else if isAndroidEmulator { + #if SKIP || canImport(OSLog) logger.log("ANDROID ENV: \(key)=\(env[key] ?? "")") + #endif XCTAssertNotNil(env[key], "Android system property should not been nil for key \(key)") } else { XCTAssertNil(env[key], "Swift system property should have been nil for key \(key) value=\(env[key] ?? "")") diff --git a/Tests/SkipFoundationTests/System/TestNotificationCenter.swift b/Tests/SkipFoundationTests/System/TestNotificationCenter.swift index 319e841..610cbda 100644 --- a/Tests/SkipFoundationTests/System/TestNotificationCenter.swift +++ b/Tests/SkipFoundationTests/System/TestNotificationCenter.swift @@ -133,6 +133,8 @@ class TestNotificationCenter : XCTestCase { XCTAssertTrue(flag) } + #if SKIP || canImport(Darwin) // i.e., not Linux + func test_notificationsSequence() async { let notificationCenter = NotificationCenter() let notificationName = Notification.Name(rawValue: "test_notificationsSequence_name") @@ -176,6 +178,8 @@ class TestNotificationCenter : XCTestCase { XCTAssertEqual(count, 2) } + #endif // SKIP || canImport(Darwin) // i.e., not Linux + func test_observeOnPostingQueue() { #if SKIP throw XCTSkip("TODO") diff --git a/Tests/SkipFoundationTests/System/TestThread.swift b/Tests/SkipFoundationTests/System/TestThread.swift index 295f2e3..4a33f3c 100644 --- a/Tests/SkipFoundationTests/System/TestThread.swift +++ b/Tests/SkipFoundationTests/System/TestThread.swift @@ -26,7 +26,9 @@ class TestThread : XCTestCase { let thread1 = Thread.current let thread2 = Thread.current XCTAssertEqual(thread1, thread2) + #if !os(Linux) XCTAssertEqual(thread1, Thread.main) + #endif } func test_threadStart() { @@ -69,11 +71,15 @@ class TestThread : XCTestCase { testInternalThreadName("Original thread") #else // No name is set initially + #if !os(Linux) XCTAssertEqual(Thread.current.name, "") + #endif testInternalThreadName("") #endif Thread.current.name = "mainThread" + #if !os(Linux) XCTAssertEqual(Thread.main.name, "mainThread") + #endif testInternalThreadName("mainThread") Thread.current.name = "12345678901234567890" @@ -89,9 +95,13 @@ class TestThread : XCTestCase { } func test_mainThread() { + #if !os(Linux) XCTAssertTrue(Thread.isMainThread) + #endif let t = Thread.main + #if !os(Linux) XCTAssertTrue(t.isMainThread) + #endif let c = Thread.current XCTAssertTrue(c.isMainThread) XCTAssertTrue(c.isExecuting) @@ -104,7 +114,9 @@ class TestThread : XCTestCase { let thread = Thread() { condition.lock() XCTAssertFalse(Thread.isMainThread) + #if !os(Linux) XCTAssertFalse(Thread.main == Thread.current) + #endif condition.broadcast() condition.unlock() } diff --git a/Tests/SkipFoundationTests/XCSkipTests.swift b/Tests/SkipFoundationTests/XCSkipTests.swift index afcac89..de3a554 100644 --- a/Tests/SkipFoundationTests/XCSkipTests.swift +++ b/Tests/SkipFoundationTests/XCSkipTests.swift @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception import Foundation -#if os(macOS) +#if canImport(SkipTest) import SkipTest /// This test case will run the transpiled tests for the Skip module.