Skip to content

Commit 4418280

Browse files
authored
Add stub for Testing module (#5077)
* Add stub for Testing module * Fix indentation
1 parent 1b8c1ea commit 4418280

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
@@ -323,24 +323,31 @@ let package = Package(
323323
.swiftLanguageMode(.v6)
324324
]
325325
),
326-
.target(
327326
// swift-corelibs-foundation has a copy of XCTest's sources so:
328327
// (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
329328
// (2) we do not depend on a swift-corelibs-xctest Swift package, which depends on Foundation, which causes a circular dependency in swiftpm
330329
// We believe Foundation is the only project that needs to take this rather drastic measure.
330+
// 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
331+
.target(
331332
name: "XCTest",
332333
dependencies: [
333334
"Foundation"
334335
],
335336
path: "Sources/XCTest"
336337
),
338+
.target(
339+
name: "Testing",
340+
dependencies: [],
341+
path: "Sources/Testing"
342+
),
337343
.testTarget(
338344
name: "TestFoundation",
339345
dependencies: [
340346
"Foundation",
341347
"FoundationXML",
342348
"FoundationNetworking",
343349
"XCTest",
350+
"Testing",
344351
.target(name: "xdgTestHelper", condition: .when(platforms: [.linux]))
345352
],
346353
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)