-
Notifications
You must be signed in to change notification settings - Fork 898
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
Fix using --help, --verbose, etc. #3620
Conversation
This solution is a little sloppy, but I think anything else would require a much larger change. |
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 the fix! Can you add a test ?
Sure. However, there aren't any tests for |
@ehuss re test: I never did so myself, but is it possible to create a method which returns the binary's name, conditionally compiling the method on whether or not a test is run ? Instead of below, do Line 121 in 466ddc9
#[cfg(test)]
fn get_binary() -> String {
// absolute path should be returned
"./target/debug/rustfmt"
}
#[cfg(not(test))]
fn get_binary() -> String {
"rustfmt"
} This would mean that Lines 1074 to 1078 in dbac28b
|
I have updated with the different approach, and added some tests. I just used the standard current_exe trick for now. I'm actually working on adding a first-class way for tests to find the binaries in cargo, so hopefully sometime soon that won't be necessary anymore. |
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.
LGTM! Thanks @ehuss, nice tests
use std::env; | ||
use std::process::Command; | ||
|
||
/// Run the cargo-fmt executable and return its output. |
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.
Can you add comment that the tuple corresponds to (stdout, stderr)
of the execution ?
Thanks! |
When running
cargo fmt -- --help
, no output would be displayed.Closes rust-lang/cargo#7027.