diff --git a/Package.swift b/Package.swift index b63612a790..2b5b5e0534 100644 --- a/Package.swift +++ b/Package.swift @@ -323,17 +323,23 @@ let package = Package( .swiftLanguageMode(.v6) ] ), - .target( // swift-corelibs-foundation has a copy of XCTest's sources so: // (1) we do not depend on the toolchain's XCTest, which depends on toolchain's Foundation, which we cannot pull in at the same time as a Foundation package // (2) we do not depend on a swift-corelibs-xctest Swift package, which depends on Foundation, which causes a circular dependency in swiftpm // We believe Foundation is the only project that needs to take this rather drastic measure. + // We also have a stub for swift-testing for the same purpose, but without an implementation since this package has no swift-testing style tests + .target( name: "XCTest", dependencies: [ "Foundation" ], path: "Sources/XCTest" ), + .target( + name: "Testing", + dependencies: [], + path: "Sources/Testing" + ), .testTarget( name: "TestFoundation", dependencies: [ @@ -341,6 +347,7 @@ let package = Package( "FoundationXML", "FoundationNetworking", "XCTest", + "Testing", .target(name: "xdgTestHelper", condition: .when(platforms: [.linux])) ], resources: [ diff --git a/Sources/Testing/Testing.swift b/Sources/Testing/Testing.swift new file mode 100644 index 0000000000..712d9deef4 --- /dev/null +++ b/Sources/Testing/Testing.swift @@ -0,0 +1,25 @@ +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2024 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 the list of Swift project authors +// + +#if canImport(Glibc) +import Glibc +#elseif canImport(Musl) +import Musl +#elseif os(WASI) +import WASILibc +#elseif canImport(CRT) +import CRT +#endif + + +// This function is used to mimic a bare minimum of the swift-testing library. Since this package has no swift-testing tests, we simply exit. +// The test runner will automatically call this function when running tests, so it must exit gracefully rather than using `fatalError()`. +public func __swiftPMEntryPoint(passing _: (any Sendable)? = nil) async -> Never { + exit(0) +}