@@ -17,12 +17,42 @@ private import _TestingInternals
17
17
/// test is expected to pass or fail by passing them to
18
18
/// ``expect(exitsWith:observing:_:sourceLocation:performing:)`` or
19
19
/// ``require(exitsWith:observing:_:sourceLocation:performing:)``.
20
- @_spi ( Experimental)
20
+ ///
21
+ /// ## Topics
22
+ ///
23
+ /// ### Successful exit conditions
24
+ ///
25
+ /// - ``success``
26
+ ///
27
+ /// ### Failing exit conditions
28
+ ///
29
+ /// - ``failure``
30
+ /// - ``exitCode(_:)``
31
+ /// - ``signal(_:)``
32
+ ///
33
+ /// ### Comparing exit conditions
34
+ ///
35
+ /// - ``/Swift/Optional/==(_:_:)``
36
+ /// - ``/Swift/Optional/!=(_:_:)``
37
+ /// - ``/Swift/Optional/===(_:_:)``
38
+ /// - ``/Swift/Optional/!==(_:_:)``
39
+ ///
40
+ /// @Metadata {
41
+ /// @Available(Swift, introduced: 6.2)
42
+ /// }
21
43
#if SWT_NO_PROCESS_SPAWNING
22
44
@available ( * , unavailable, message: " Exit tests are not available on this platform. " )
23
45
#endif
24
46
public enum ExitCondition : Sendable {
25
47
/// The process terminated successfully with status `EXIT_SUCCESS`.
48
+ ///
49
+ /// The C programming language defines two [standard exit codes](https://en.cppreference.com/w/c/program/EXIT_status),
50
+ /// `EXIT_SUCCESS` and `EXIT_FAILURE` as well as `0` (as a synonym for
51
+ /// `EXIT_SUCCESS`.)
52
+ ///
53
+ /// @Metadata {
54
+ /// @Available(Swift, introduced: 6.2)
55
+ /// }
26
56
public static var success : Self {
27
57
// Strictly speaking, the C standard treats 0 as a successful exit code and
28
58
// potentially distinct from EXIT_SUCCESS. To my knowledge, no modern
@@ -33,6 +63,10 @@ public enum ExitCondition: Sendable {
33
63
34
64
/// The process terminated abnormally with any status other than
35
65
/// `EXIT_SUCCESS` or with any signal.
66
+ ///
67
+ /// @Metadata {
68
+ /// @Available(Swift, introduced: 6.2)
69
+ /// }
36
70
case failure
37
71
38
72
/// The process terminated with the given exit code.
@@ -56,6 +90,10 @@ public enum ExitCondition: Sendable {
56
90
/// the process is yielded to the parent process. Linux and other POSIX-like
57
91
/// systems may only reliably report the low unsigned 8 bits (0–255) of
58
92
/// the exit code.
93
+ ///
94
+ /// @Metadata {
95
+ /// @Available(Swift, introduced: 6.2)
96
+ /// }
59
97
case exitCode( _ exitCode: CInt )
60
98
61
99
/// The process terminated with the given signal.
@@ -73,12 +111,18 @@ public enum ExitCondition: Sendable {
73
111
/// | FreeBSD | [`<signal.h>`](https://man.freebsd.org/cgi/man.cgi?signal(3)) |
74
112
/// | OpenBSD | [`<signal.h>`](https://man.openbsd.org/signal.3) |
75
113
/// | Windows | [`<signal.h>`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/signal-constants) |
114
+ ///
115
+ /// @Metadata {
116
+ /// @Available(Swift, introduced: 6.2)
117
+ /// }
76
118
case signal( _ signal: CInt )
77
119
}
78
120
79
121
// MARK: - Equatable
80
122
81
- @_spi ( Experimental)
123
+ /// @Metadata {
124
+ /// @Available(Swift, introduced: 6.2)
125
+ /// }
82
126
#if SWT_NO_PROCESS_SPAWNING
83
127
@available ( * , unavailable, message: " Exit tests are not available on this platform. " )
84
128
#endif
@@ -109,7 +153,11 @@ extension Optional<ExitCondition> {
109
153
/// or [`Hashable`](https://developer.apple.com/documentation/swift/hashable).
110
154
///
111
155
/// For any values `a` and `b`, `a == b` implies that `a != b` is `false`.
112
- public static func == ( lhs: Self , rhs: Self ) -> Bool {
156
+ ///
157
+ /// @Metadata {
158
+ /// @Available(Swift, introduced: 6.2)
159
+ /// }
160
+ public static func == ( lhs: ExitCondition ? , rhs: ExitCondition ? ) -> Bool {
113
161
#if !SWT_NO_PROCESS_SPAWNING
114
162
return switch ( lhs, rhs) {
115
163
case let ( . failure, . exitCode( exitCode) ) , let ( . exitCode( exitCode) , . failure) :
@@ -151,7 +199,11 @@ extension Optional<ExitCondition> {
151
199
/// or [`Hashable`](https://developer.apple.com/documentation/swift/hashable).
152
200
///
153
201
/// For any values `a` and `b`, `a == b` implies that `a != b` is `false`.
154
- public static func != ( lhs: Self , rhs: Self ) -> Bool {
202
+ ///
203
+ /// @Metadata {
204
+ /// @Available(Swift, introduced: 6.2)
205
+ /// }
206
+ public static func != ( lhs: ExitCondition ? , rhs: ExitCondition ? ) -> Bool {
155
207
#if !SWT_NO_PROCESS_SPAWNING
156
208
!( lhs == rhs)
157
209
#else
@@ -185,7 +237,11 @@ extension Optional<ExitCondition> {
185
237
/// or [`Hashable`](https://developer.apple.com/documentation/swift/hashable).
186
238
///
187
239
/// For any values `a` and `b`, `a === b` implies that `a !== b` is `false`.
188
- public static func === ( lhs: Self , rhs: Self ) -> Bool {
240
+ ///
241
+ /// @Metadata {
242
+ /// @Available(Swift, introduced: 6.2)
243
+ /// }
244
+ public static func === ( lhs: ExitCondition ? , rhs: ExitCondition ? ) -> Bool {
189
245
return switch ( lhs, rhs) {
190
246
case ( . none, . none) :
191
247
true
@@ -226,7 +282,11 @@ extension Optional<ExitCondition> {
226
282
/// or [`Hashable`](https://developer.apple.com/documentation/swift/hashable).
227
283
///
228
284
/// For any values `a` and `b`, `a === b` implies that `a !== b` is `false`.
229
- public static func !== ( lhs: Self , rhs: Self ) -> Bool {
285
+ ///
286
+ /// @Metadata {
287
+ /// @Available(Swift, introduced: 6.2)
288
+ /// }
289
+ public static func !== ( lhs: ExitCondition ? , rhs: ExitCondition ? ) -> Bool {
230
290
#if !SWT_NO_PROCESS_SPAWNING
231
291
!( lhs === rhs)
232
292
#else
0 commit comments