-
Notifications
You must be signed in to change notification settings - Fork 13
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
cli: return an errors if testing #260
Conversation
I'm wondering why the initial issue was not seen on release v1.1. Do you know what introduced this behavior? |
You mean that on v1.1 "--help" and "--version" were not raised as errors? |
I'm not 100% sure of which versions are impacted, but testing a few builds on my machine, v1.0:
(IIRC the packaged v1.0 had not the issue). v1.1:
(But the packaged v1.1 had the issue). main w/ 3c651d7 reverted:
|
It seems clap's behavior changed. The following code: use clap::Command;
fn main() {
let arg_vec = vec!["my_prog", "--help"];
let matches = Command::new("myprog")
.ignore_errors(true)
.try_get_matches_from(arg_vec);
println!("Matches {:?}", matches);
} Yields different results when built against clap 3.2.25 (used in retis 1.1.0) and 4.3.19 (used by retis's main). 3.2.25:
4.3.19:
|
I think the previous behavior is the buggy one so they must have fixed it. |
Actually: clap-rs/clap#4988 |
Thanks for the links. I'm still wondering why my local build of v1.1.0 did not had the issue while the build in copr had it, but I'm assuming the version of |
27e67dc
to
e47f0da
Compare
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.
"build_from() should only be used directly by unit tests." <- could we add this in the function comments?
Fixes: retis-org#259 build_from() should only be used directly by unit tests. It would be private if it wasn't needed in other modules for testing purposes. It always returns an error. However, build(), which is called by main(), exits the program based on that error using clap. Signed-off-by: Adrian Moreno <[email protected]>
e47f0da
to
633531f
Compare
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!
Fixes: #259
Instead of aborting the program, return the error so that tests can check against them.