From 3f1d809218854a61ff29cae8b92013e512c7e02a Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Wed, 21 Aug 2024 10:21:30 -0700 Subject: [PATCH] [6.0] Add stub for Testing module * Add stub for Testing module * Fix indentation --- Package.swift | 9 ++++++++- Sources/Testing/Testing.swift | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Sources/Testing/Testing.swift diff --git a/Package.swift b/Package.swift index 6d6603880e..9ebe54901f 100644 --- a/Package.swift +++ b/Package.swift @@ -241,17 +241,23 @@ let package = Package( .swiftLanguageVersion(.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: [ @@ -259,6 +265,7 @@ let package = Package( "FoundationXML", "FoundationNetworking", .targetItem(name: "XCTest", condition: .when(platforms: [.linux])), + "Testing", "xdgTestHelper" ], 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) +}