Skip to content

Commit efdd66f

Browse files
committed
Restore existing overloads for source compatibility's sake and clean up the documentation
1 parent 0a568ed commit efdd66f

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

Sources/XCTest/Public/XCTestMain.swift

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
/// Starts a test run for the specified test cases.
3434
///
35-
/// This function will not return. If the test cases pass, then it will call `exit(EXIT_SUCCESS)`. If there is a failure, then it will call `exit(EXIT_FAILURE)`.
3635
/// Example usage:
3736
///
3837
/// class TestFoo: XCTestCase {
@@ -50,15 +49,26 @@
5049
/// // etc...
5150
/// }
5251
///
53-
/// XCTMain([ testCase(TestFoo.allTests) ])
52+
/// let exitCode = XCTMain([ testCase(TestFoo.allTests) ])
5453
///
55-
/// Command line arguments can be used to select a particular test case or class to execute. For example:
54+
/// Command line arguments can be used to select a particular test case or class
55+
/// to execute. For example:
5656
///
5757
/// ./FooTests FooTestCase/testFoo # Run a single test case
5858
/// ./FooTests FooTestCase # Run all the tests in FooTestCase
5959
///
60-
/// - Parameter testCases: An array of test cases run, each produced by a call to the `testCase` function
61-
/// - seealso: `testCase`
60+
/// - Parameters:
61+
/// - testCases: An array of test cases run, each produced by a call to the
62+
/// `testCase` function.
63+
/// - arguments: Command-line arguments to pass to XCTest. By default, the
64+
/// arguments passed to the process are used.
65+
/// - observers: Zero or more observers that should observe events that
66+
/// occur while testing. If `nil` (the default), events are written to
67+
/// the console.
68+
///
69+
/// - Returns: The exit code to use when the process terminates. `EXIT_SUCCESS`
70+
/// indicates success, while any other value (including `EXIT_FAILURE`)
71+
/// indicates failure.
6272
@_disfavoredOverload
6373
public func XCTMain(
6474
_ testCases: [XCTestCaseEntry],
@@ -143,11 +153,21 @@ public func XCTMain(
143153
}
144154
}
145155

156+
// @available(*, deprecated, message: "Call the overload of XCTMain() that returns an exit code instead.")
157+
public func XCTMain(_ testCases: [XCTestCaseEntry]) -> Never {
158+
exit(XCTMain(testCases, arguments: CommandLine.arguments, observers: nil) as CInt)
159+
}
160+
161+
// @available(*, deprecated, message: "Call the overload of XCTMain() that returns an exit code instead.")
162+
public func XCTMain(_ testCases: [XCTestCaseEntry], arguments: [String]) -> Never {
163+
exit(XCTMain(testCases, arguments: arguments, observers: nil) as CInt)
164+
}
165+
146166
// @available(*, deprecated, message: "Call the overload of XCTMain() that returns an exit code instead.")
147167
public func XCTMain(
148168
_ testCases: [XCTestCaseEntry],
149-
arguments: [String] = CommandLine.arguments,
150-
observers: [XCTestObservation]? = nil
169+
arguments: [String],
170+
observers: [XCTestObservation]
151171
) -> Never {
152172
exit(XCTMain(testCases, arguments: arguments, observers: observers) as CInt)
153173
}

0 commit comments

Comments
 (0)