diff --git a/IntegrationTests/Tests/IntegrationTests/BasicTests.swift b/IntegrationTests/Tests/IntegrationTests/BasicTests.swift index f02fd1faa69..91d6abd483a 100644 --- a/IntegrationTests/Tests/IntegrationTests/BasicTests.swift +++ b/IntegrationTests/Tests/IntegrationTests/BasicTests.swift @@ -94,7 +94,7 @@ private struct BasicTests { } @Test( - .skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")"), + .skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")") ) func testSwiftCompiler() throws { try withTemporaryDirectory { tempDir in diff --git a/Package.swift b/Package.swift index 15d291a3eba..216810019bc 100644 --- a/Package.swift +++ b/Package.swift @@ -725,7 +725,7 @@ let package = Package( // MARK: Additional Test Dependencies - .testTarget( + .target( /** SwiftPM internal build test suite support library */ name: "_InternalBuildTestSupport", dependencies: [ @@ -734,13 +734,12 @@ let package = Package( "SwiftBuildSupport", "_InternalTestSupport" ], - path: "Sources/_InternalBuildTestSupport", swiftSettings: [ .unsafeFlags(["-static"]), ] ), - .testTarget( + .target( /** SwiftPM internal test suite support library */ name: "_InternalTestSupport", dependencies: [ @@ -755,7 +754,6 @@ let package = Package( .product(name: "OrderedCollections", package: "swift-collections"), "Workspace", ], - path: "./Sources/_InternalTestSupport", swiftSettings: [ .unsafeFlags(["-static"]), ] diff --git a/Sources/_InternalTestSupport/Process.swift b/Sources/_InternalTestSupport/Process.swift deleted file mode 100644 index eacfcbc2896..00000000000 --- a/Sources/_InternalTestSupport/Process.swift +++ /dev/null @@ -1,43 +0,0 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ - -public import Foundation - -public enum OperatingSystem: Hashable, Sendable { - case macOS - case windows - case linux - case android - case unknown -} - -extension ProcessInfo { - #if os(macOS) - public static let hostOperatingSystem = OperatingSystem.macOS - #elseif os(Linux) - public static let hostOperatingSystem = OperatingSystem.linux - #elseif os(Windows) - public static let hostOperatingSystem = OperatingSystem.windows - #else - public static let hostOperatingSystem = OperatingSystem.unknown - #endif - - #if os(Windows) - public static let EOL = "\r\n" - #else - public static let EOL = "\n" - #endif - - #if os(Windows) - public static let exeSuffix = ".exe" - #else - public static let exeSuffix = "" - #endif -} diff --git a/Sources/_InternalTestSupport/SkippedTestSupport.swift b/Sources/_InternalTestSupport/SkippedTestSupport.swift deleted file mode 100644 index b73727d1c64..00000000000 --- a/Sources/_InternalTestSupport/SkippedTestSupport.swift +++ /dev/null @@ -1,70 +0,0 @@ - -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ - -import class Foundation.FileManager -import class Foundation.ProcessInfo -import Testing - -extension Trait where Self == Testing.ConditionTrait { - /// Skip test if the host operating system does not match the running OS. - public static func requireHostOS(_ os: OperatingSystem, when condition: Bool = true) -> Self { - enabled("This test requires a \(os) host OS.") { - ProcessInfo.hostOperatingSystem == os && condition - } - } - - /// Skip test if the host operating system matches the running OS. - public static func skipHostOS(_ os: OperatingSystem, _ comment: Comment? = nil) -> Self { - disabled(comment ?? "This test cannot run on a \(os) host OS.") { - ProcessInfo.hostOperatingSystem == os - } - } - - /// Skip test unconditionally - public static func skip(_ comment: Comment? = nil) -> Self { - disabled(comment ?? "Unconditional skip, a comment should be added for the reason") { true } - } - - /// Skip test if the environment is self hosted. - public static func skipSwiftCISelfHosted(_ comment: Comment? = nil) -> Self { - disabled(comment ?? "SwiftCI is self hosted") { - ProcessInfo.processInfo.environment["SWIFTCI_IS_SELF_HOSTED"] != nil - } - } - - /// Skip test if the test environment has a restricted network access, i.e. cannot get to internet. - public static func requireUnrestrictedNetworkAccess(_ comment: Comment? = nil) -> Self { - disabled(comment ?? "CI Environment has restricted network access") { - ProcessInfo.processInfo.environment["SWIFTCI_RESTRICTED_NETWORK_ACCESS"] != nil - } - } - - /// Skip test if built by XCode. - public static func skipIfXcodeBuilt() -> Self { - disabled("Tests built by Xcode") { - #if Xcode - true - #else - false - #endif - } - } - - /// Constructs a condition trait that causes a test to be disabled if the Foundation process spawning implementation - /// is not using `posix_spawn_file_actions_addchdir`. - public static var requireThreadSafeWorkingDirectory: Self { - disabled("Thread-safe process working directory support is unavailable.") { - // Amazon Linux 2 has glibc 2.26, and glibc 2.29 is needed for posix_spawn_file_actions_addchdir_np support - FileManager.default.contents(atPath: "/etc/system-release") - .map { String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" } ?? false - } - } -} diff --git a/Tests/PackageRegistryTests/RegistryClientTests.swift b/Tests/PackageRegistryTests/RegistryClientTests.swift index b8390c1900f..809fdf32b89 100644 --- a/Tests/PackageRegistryTests/RegistryClientTests.swift +++ b/Tests/PackageRegistryTests/RegistryClientTests.swift @@ -803,7 +803,7 @@ final class RegistryClientTests: XCTestCase { let availableManifests = try await registryClient.getAvailableManifests( package: identity, version: version, - observabilityScope: ObservabilitySystem.NOOP, + observabilityScope: ObservabilitySystem.NOOP ) XCTAssertEqual(availableManifests["Package.swift"]?.toolsVersion, .v5_5) @@ -3987,7 +3987,7 @@ extension RegistryClient { package: package.underlying, version: version, fileSystem: InMemoryFileSystem(), - observabilityScope: ObservabilitySystem.NOOP, + observabilityScope: ObservabilitySystem.NOOP ) }