-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Extends rustdoc on how to caputure output #32338
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
/// .stdout(Stdio::piped()) | ||
/// .arg("file.txt") | ||
/// .spawn() | ||
/// .unwrap_or_else(|e| { panic!("failed to execute child: {}", e) }); |
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.
These calls can nowadays be .expect("failed to execute child")
I believe
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.
I was using the example of output
as a template and it does use unwrap_or_else
which I prefer since it transports the underlying error. But sure, I'll update the PR.
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.
Ah that's a good point, if you wanna update the other blocks feel free :)
- After discussing with @alexcrichton, the initial commit has been fine. This reverts commit 3b5cfa3.
@lukaspustina sorry but do you want to apply the changes here? Or another PR? I'm confused... |
@alexcrichton I leave the PR as initially intended following the already existing test for |
/// By default, stdin, stdout and stderr are inherited from the parent. | ||
/// In order to capture the output into this `Result<Output>` it is | ||
/// necessary to create new pipes between parent and child. Use | ||
/// `stdout(Stdio::piped())` or `stdout(Stdio::piped())`, respectively. |
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 one of these supposed to be stderr(Stdio::piped())
?
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.
Argh. Of course. Thanks for the catch.
It may actually be easier to just go ahead and throw the changes into this PR, the cycle time for landing PRs is unfortunately kinda high so may as well land it all at once if we can! (plus there shouldn't be many conflicts). Also note that |
- All Rust Doc tests execute the same command `/bin/cat file.txt` which `should_panic` on all platforms consistently, because either `/bin/cat` or `file.txt` do not exist.
@alexcrichton: Done. |
Looks like a legit test failure. |
Since I changed no_run to should_panic on some tests, the were run but two lacked an actual assertion. Further, I missed to check the return type on another test.
@alexcrichton: Ping. Anything I can do to enhance the PR? |
Extends rustdoc on how to caputure output - The documentation is quite about how to caputure a process' output when using ` std::process::Child::wait_with_output()`. - This PR adds an example for this particular use case.
std::process::Child::wait_with_output()
.