Skip to content

Commit

Permalink
Add stub for Testing module (swiftlang#5077)
Browse files Browse the repository at this point in the history
* Add stub for Testing module

* Fix indentation
  • Loading branch information
jmschonfeld authored Aug 21, 2024
1 parent 1b8c1ea commit 4418280
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,24 +323,31 @@ let package = Package(
.swiftLanguageMode(.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",
"XCTest",
"Testing",
.target(name: "xdgTestHelper", condition: .when(platforms: [.linux]))
],
resources: [
Expand Down
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)
}

0 comments on commit 4418280

Please sign in to comment.