Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0] Add stub for Testing module #5078

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -241,24 +241,31 @@ 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: [
"Foundation",
"FoundationXML",
"FoundationNetworking",
.targetItem(name: "XCTest", condition: .when(platforms: [.linux])),
"Testing",
"xdgTestHelper"
],
resources: [
25 changes: 25 additions & 0 deletions Sources/Testing/Testing.swift
Original file line number Diff line number Diff line change
@@ -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)
}