Skip to content

Commit

Permalink
Merge branch 'doc-opts' into 'master'
Browse files Browse the repository at this point in the history
Add more CLI options tests

See merge request mkjeldsen/commitmsgfmt!62
  • Loading branch information
commonquail committed Oct 4, 2023
2 parents 8ac293b + 8103766 commit 500c22f
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ y
#[test]
fn arg_width_short_form_is_w() {
let mut cmd = target_binary();
cmd.args(&["-w", "1"]);
cmd.args(&["-w1"]);
let output = run_debug_binary_with_input(cmd, b"subject\nb o d y");

assert_cmd_success(&output);
Expand Down Expand Up @@ -421,9 +421,9 @@ b o d y
let out = String::from_utf8_lossy(&output.stdout);
let out_ci = out.to_lowercase();
assert!(out_ci.contains("usage:"));
assert!(out.contains("-h, --help"));
assert!(out.contains("-V, --version"));
assert!(out.contains("-w, --width"));
assert!(out.contains("\n -h, --help"));
assert!(out.contains("\n -V, --version"));
assert!(out.contains("\n -w, --width"));
assert!(out.contains("exempt"));
}

Expand All @@ -438,9 +438,9 @@ b o d y
let out = String::from_utf8_lossy(&output.stdout);
let out_ci = out.to_lowercase();
assert!(out_ci.contains("usage:"));
assert!(out.contains("-h, --help"));
assert!(out.contains("-V, --version"));
assert!(out.contains("-w, --width"));
assert!(out.contains("\n -h, --help"));
assert!(out.contains("\n -V, --version"));
assert!(out.contains("\n -w, --width"));
assert!(!out.contains("exempt"));
}

Expand Down Expand Up @@ -544,6 +544,19 @@ b o d y
assert!(!out.contains("usage"));
}

#[test]
fn args_parse_combined_shortform() {
let mut cmd = target_binary();
cmd.arg("-hV");
let output = run_debug_binary_no_input(cmd);

assert_cmd_success(&output);

let out = String::from_utf8_lossy(&output.stdout);
let out = out.to_lowercase();
assert!(out.contains("usage"));
}

// Sometime after the release of v1.2.0, external changes to Travis CI have
// caused this test to begin failing consistently. Anecdotally, it likewise
// has a higher failure rate on Ubuntu 19.10 than in the past.
Expand Down

0 comments on commit 500c22f

Please sign in to comment.