This is pretty much what Assert::fails_with(self, expect_exit_code: i32) provides, except that an exit code of 0 is accepted. The current implementation fails the assertion if expect_exit_code=0 and the command returns with an exit code of 0.
Rationale for the functionality: I'm testing for specific exit codes with something that looks like:
let t = vec![
(&["all","fine"], 0),
(&["user","error"], 1),
(&["program","error"], 2),
];
for (args, exit) in t {
Assert::main_binary().with_args(args).fails_with(exit).unwrap();
}
But this fails unless I special-case exit==0 to remove the fails_with() call. It's not hard, but it's ugly and surprising.
I'm not sure if fails_with() should be modified to accept 0 as an argument (ie this issue is a bug) or if a new function (say exits_with()) should be created (ie this issue is a feature request). Tell me which and I'll try to send a PR.
assert_cli 0.5.4 rust 1.25.0
This is pretty much what
Assert::fails_with(self, expect_exit_code: i32)provides, except that an exit code of 0 is accepted. The current implementation fails the assertion ifexpect_exit_code=0and the command returns with an exit code of 0.Rationale for the functionality: I'm testing for specific exit codes with something that looks like:
But this fails unless I special-case
exit==0to remove thefails_with()call. It's not hard, but it's ugly and surprising.I'm not sure if
fails_with()should be modified to accept 0 as an argument (ie this issue is a bug) or if a new function (sayexits_with()) should be created (ie this issue is a feature request). Tell me which and I'll try to send a PR.assert_cli 0.5.4 rust 1.25.0