mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-29 03:13:54 -07:00
printer: fix handling of has_match
for summary printer
Previously, `Quiet` mode in the summary printer always acted like "print matching paths," except without the printing. This happened even if we wanted to "print non-matching paths." Since this only afflicted quiet mode, this had the effect of flipping the exit status when `--files-without-match --quiet` was used. Fixes #3108, Ref #3118
This commit is contained in:
@@ -1476,3 +1476,44 @@ rgtest!(r2990_trip_over_trailing_dot, |dir: Dir, _cmd: TestCommand| {
|
||||
let got = dir.command().args(&["--files", "-g", "!asdf./"]).stdout();
|
||||
eqnice!("asdf/foo\n", got);
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/3108
|
||||
rgtest!(r3108_files_without_match_quiet_exit, |dir: Dir, _: TestCommand| {
|
||||
dir.create("yes-match", "abc");
|
||||
dir.create("non-match", "xyz");
|
||||
|
||||
dir.command().args(&["-q", "abc", "non-match"]).assert_exit_code(1);
|
||||
dir.command().args(&["-q", "abc", "yes-match"]).assert_exit_code(0);
|
||||
dir.command()
|
||||
.args(&["--files-with-matches", "-q", "abc", "non-match"])
|
||||
.assert_exit_code(1);
|
||||
dir.command()
|
||||
.args(&["--files-with-matches", "-q", "abc", "yes-match"])
|
||||
.assert_exit_code(0);
|
||||
|
||||
dir.command()
|
||||
.args(&["--files-without-match", "abc", "non-match"])
|
||||
.assert_exit_code(0);
|
||||
dir.command()
|
||||
.args(&["--files-without-match", "abc", "yes-match"])
|
||||
.assert_exit_code(1);
|
||||
|
||||
let got = dir
|
||||
.command()
|
||||
.args(&["--files-without-match", "abc", "non-match"])
|
||||
.stdout();
|
||||
eqnice!("non-match\n", got);
|
||||
|
||||
dir.command()
|
||||
.args(&["--files-without-match", "-q", "abc", "non-match"])
|
||||
.assert_exit_code(0);
|
||||
dir.command()
|
||||
.args(&["--files-without-match", "-q", "abc", "yes-match"])
|
||||
.assert_exit_code(1);
|
||||
|
||||
let got = dir
|
||||
.command()
|
||||
.args(&["--files-without-match", "-q", "abc", "non-match"])
|
||||
.stdout();
|
||||
eqnice!("", got);
|
||||
});
|
||||
|
Reference in New Issue
Block a user