Skip to content

Commit 19a6e11

Browse files
authored
ExitTest.find(withArguments:) -> ExitTest.findInEnvironmentForSwiftPM() (#346)
Rename the `ExitTest.find(withArguments:)` function because it doesn't actually use command-line arguments in the current implementation. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 956bad4 commit 19a6e11

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

Sources/Testing/ExitTests/ExitTest.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,16 @@ extension ExitTest {
213213
/// recording any issues that occur.
214214
public typealias Handler = @Sendable (_ exitTest: borrowing ExitTest) async throws -> ExitCondition
215215

216-
/// Find the exit test function specified by the given command-line arguments,
217-
/// if any.
218-
///
219-
/// - Parameters:
220-
/// - args: The command-line arguments to this process.
216+
/// Find the exit test function specified in the environment of the current
217+
/// process, if any.
221218
///
222219
/// - Returns: The exit test this process should run, or `nil` if it is not
223220
/// expected to run any.
224221
///
225222
/// This function should only be used when the process was started via the
226223
/// `__swiftPMEntryPoint()` function. The effect of using it under other
227224
/// configurations is undefined.
228-
public static func find(withArguments args: [String]) -> Self? {
225+
static func findInEnvironmentForSwiftPM() -> Self? {
229226
let sourceLocationString = Environment.variable(named: "SWT_EXPERIMENTAL_EXIT_TEST_SOURCE_LOCATION")
230227
if let sourceLocationData = sourceLocationString?.data(using: .utf8),
231228
let sourceLocation = try? JSONDecoder().decode(SourceLocation.self, from: sourceLocationData) {

Sources/Testing/Running/EntryPoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private import Foundation
5555
options.isVerbose = args.contains("--verbose")
5656

5757
#if !SWT_NO_EXIT_TESTS
58-
if let exitTest = ExitTest.find(withArguments: args) {
58+
if let exitTest = ExitTest.findInEnvironmentForSwiftPM() {
5959
await exitTest()
6060
return exitCode.rawValue
6161
}

Sources/Testing/Running/XCTestScaffold.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public enum XCTestScaffold: Sendable {
161161

162162
#if !SWT_NO_EXIT_TESTS
163163
// Exit test handling.
164-
if let exitTest = ExitTest.find(withArguments: CommandLine.arguments()) {
164+
if let exitTest = ExitTest.findInEnvironmentForSwiftPM() {
165165
await exitTest()
166166
exit(EXIT_SUCCESS)
167167
}

0 commit comments

Comments
 (0)