-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promote exit tests to API #324
base: main
Are you sure you want to change the base?
Conversation
fe21f14
to
988ddfe
Compare
988ddfe
to
697123a
Compare
19f37c3
to
4825821
Compare
feb425b
to
e84b014
Compare
6f0e7f0
to
875b870
Compare
875b870
to
4365611
Compare
4365611
to
7d25e07
Compare
Rebased. |
@swift-ci test |
417cb17
to
5705163
Compare
@swift-ci test |
1 similar comment
@swift-ci test |
ecda40c
to
59ec9f5
Compare
@swift-ci test |
One of the first enhancement requests we received for swift-testing was the ability to test for precondition failures and other critical failures that terminate the current process when they occur. This feature is also frequently requested for XCTest. With swift-testing, we have the opportunity to build such a feature in an ergonomic way. Read the full proposal [here](https://github.com/apple/swift-testing/blob/jgrynspan/exit-tests-proposal/Documentation/Proposals/NNNN-exit-tests.md).
59ec9f5
to
4c0d958
Compare
@swift-ci test |
@swift-ci test |
@swift-ci test |
@swift-ci test |
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this article, it's really helpful for developers!
/// See https://en.cppreference.com/w/c/program/EXIT_status for more | ||
/// information about exit codes defined by the C standard. | ||
/// } | ||
/// | ||
/// On macOS, FreeBSD, OpenBSD, and Windows, the full exit code reported by | ||
/// the process is yielded to the parent process. Linux and other POSIX-like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "yielded" the correct word here? I associate it with coroutines, but this documentation is about a function. "…the function returns the full value of the process's exit code."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Reported" may be better. The mechanism that gets this value into the parent process involves the kernel, so the terminology is more vague than usual.
public struct Result: Sendable { | ||
/// The exit condition the exit test exited with. | ||
/// The status of the process hosting the exit test at the time it exits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "The exit status reported by the process hosting the exit test"? Just trying to reduce the number of clauses here.
|
||
### Constraints on exit tests | ||
|
||
#### State cannot be captured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#### State cannot be captured | |
#### Don't capture state in the test body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't an instruction. It's physically impossible to do it. There is no "do".
|
||
#### State cannot be captured | ||
|
||
Exit tests cannot capture any state originating in the parent process or from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exit tests cannot capture any state originating in the parent process or from | |
Exit tests can't capture any state originating in the parent process or from |
#### State cannot be captured | ||
|
||
Exit tests cannot capture any state originating in the parent process or from | ||
the enclosing lexical context. For example, the following exit test will fail to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the enclosing lexical context. For example, the following exit test will fail to | |
the enclosing lexical context. For example, the following exit test fails to |
} | ||
``` | ||
|
||
#### Exit tests cannot be nested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#### Exit tests cannot be nested | |
#### Don't nest exit tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't an instruction. It's physically impossible to do it. There is no "do".
|
||
#### Exit tests cannot be nested | ||
|
||
An exit test cannot run within another exit test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An exit test cannot run within another exit test. | |
An exit test can't run another exit test. |
It means the same to say "a test can't run a child test" as "a test can't run in a parent test", and it's simpler.
This PR promotes exit tests to API, pending approval of the proposal at swiftlang/swift-evolution#2718.
View the full proposal here.
Checklist: