-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fixes to ExitStatus and its docs #82411
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fbd575a
process::unix: Handle other wait statuses in ExitStatus as Display
ijackson d8cfd56
process::unix: Test wait status formatting
ijackson 4bb8425
ExitStatus: Improve documentation re wait status vs exit status
ijackson 67cfc22
ExitStatus stop signal display test: Make it Linux only
ijackson a240ff5
ExitStatus unknown wait status test: Make it Linux only
ijackson 8e4433a
ExitStatus tests: Make less legible to satisfy "tidy"
ijackson 11ca644
Always compile the fragile wait status test cases, just run them cond…
ijackson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#[test] | ||
fn exitstatus_display_tests() { | ||
// In practice this is the same on every Unix. | ||
// If some weird platform turns out to be different, and this test fails, use #[cfg]. | ||
use crate::os::unix::process::ExitStatusExt; | ||
use crate::process::ExitStatus; | ||
|
||
let t = |v, s| assert_eq!(s, format!("{}", <ExitStatus as ExitStatusExt>::from_raw(v))); | ||
|
||
t(0x0000f, "signal: 15"); | ||
t(0x0008b, "signal: 11 (core dumped)"); | ||
t(0x00000, "exit code: 0"); | ||
t(0x0ff00, "exit code: 255"); | ||
|
||
// On MacOS, 0x0137f is WIFCONTINUED, not WIFSTOPPED. Probably *BSD is similar. | ||
// https://github.com/rust-lang/rust/pull/82749#issuecomment-790525956 | ||
// The purpose of this test is to test our string formatting, not our understanding of the wait | ||
// status magic numbers. So restrict these to Linux. | ||
#[cfg(target_os = "linux")] | ||
t(0x0137f, "stopped (not terminated) by signal: 19"); | ||
#[cfg(target_os = "linux")] | ||
t(0x0ffff, "continued (WIFCONTINUED)"); | ||
|
||
// Testing "unrecognised wait status" is hard because the wait.h macros typically | ||
// assume that the value came from wait and isn't mad. With the glibc I have here | ||
// this works: | ||
#[cfg(all(target_os = "linux", target_env = "gnu"))] | ||
t(0x000ff, "unrecognised wait status: 255 0xff"); | ||
ijackson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.