Skip to content

Commit 82e96cc

Browse files
authored
[6.0] Add stub for Testing module (#5078)
* Add stub for Testing module * Fix indentation
1 parent e372166 commit 82e96cc

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

Package.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -258,24 +258,31 @@ let package = Package(
258258
.swiftLanguageVersion(.v6)
259259
]
260260
),
261-
.target(
262261
// swift-corelibs-foundation has a copy of XCTest's sources so:
263262
// (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
264263
// (2) we do not depend on a swift-corelibs-xctest Swift package, which depends on Foundation, which causes a circular dependency in swiftpm
265264
// We believe Foundation is the only project that needs to take this rather drastic measure.
265+
// 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
266+
.target(
266267
name: "XCTest",
267268
dependencies: [
268269
"Foundation"
269270
],
270271
path: "Sources/XCTest"
271272
),
273+
.target(
274+
name: "Testing",
275+
dependencies: [],
276+
path: "Sources/Testing"
277+
),
272278
.testTarget(
273279
name: "TestFoundation",
274280
dependencies: [
275281
"Foundation",
276282
"FoundationXML",
277283
"FoundationNetworking",
278284
.targetItem(name: "XCTest", condition: .when(platforms: [.linux])),
285+
"Testing",
279286
"xdgTestHelper"
280287
],
281288
resources: [

Sources/Testing/Testing.swift

+25
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)