Skip to content

Commit 3f1d809

Browse files
committed
[6.0] Add stub for Testing module
* Add stub for Testing module * Fix indentation
1 parent 59e6789 commit 3f1d809

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

Package.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,31 @@ let package = Package(
241241
.swiftLanguageVersion(.v6)
242242
]
243243
),
244-
.target(
245244
// swift-corelibs-foundation has a copy of XCTest's sources so:
246245
// (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
247246
// (2) we do not depend on a swift-corelibs-xctest Swift package, which depends on Foundation, which causes a circular dependency in swiftpm
248247
// We believe Foundation is the only project that needs to take this rather drastic measure.
248+
// 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
249+
.target(
249250
name: "XCTest",
250251
dependencies: [
251252
"Foundation"
252253
],
253254
path: "Sources/XCTest"
254255
),
256+
.target(
257+
name: "Testing",
258+
dependencies: [],
259+
path: "Sources/Testing"
260+
),
255261
.testTarget(
256262
name: "TestFoundation",
257263
dependencies: [
258264
"Foundation",
259265
"FoundationXML",
260266
"FoundationNetworking",
261267
.targetItem(name: "XCTest", condition: .when(platforms: [.linux])),
268+
"Testing",
262269
"xdgTestHelper"
263270
],
264271
resources: [

Sources/Testing/Testing.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This source file is part of the Swift.org open source project
2+
//
3+
// Copyright (c) 2024 Apple Inc. and the Swift project authors
4+
// Licensed under Apache License v2.0 with Runtime Library Exception
5+
//
6+
// See http://swift.org/LICENSE.txt for license information
7+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
8+
//
9+
10+
#if canImport(Glibc)
11+
import Glibc
12+
#elseif canImport(Musl)
13+
import Musl
14+
#elseif os(WASI)
15+
import WASILibc
16+
#elseif canImport(CRT)
17+
import CRT
18+
#endif
19+
20+
21+
// 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.
22+
// The test runner will automatically call this function when running tests, so it must exit gracefully rather than using `fatalError()`.
23+
public func __swiftPMEntryPoint(passing _: (any Sendable)? = nil) async -> Never {
24+
exit(0)
25+
}

0 commit comments

Comments
 (0)