diff options
author | Mika Dede <xervondev@gmail.com> | 2018-12-01 13:31:33 +0100 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-01-22 21:37:23 -0500 |
commit | a7f2d482342eb2250b5a32ee03a8fe16990228dc (patch) | |
tree | 17ae6c62666162da2f0bbb1c8d360910ec609d30 /tests | |
parent | 57500ad01381f8c4ed6436af627680969c6e2de2 (diff) |
printer: fix path handling in summarizer
This commit fixes a bug where both of the following commands always
reported an error:
rg --files-with-matches foo file
rg --files-without-match foo file
In particular, the printer was erroneously respecting the `path` option
even the the summary kind was `PathWithMatch` or `PathWithoutMatch`. The
documented behavior is that those summary kinds always require a path,
and thus, the `path` option has no effect. We fix this by correcting the
case analysis.
This also fixes a bug where the exit code for `--files-without-match`
was not set correctly. We update the printer's `has_match` method to
report the correct value.
Fixes #1106, Closes #1130
Diffstat (limited to 'tests')
-rw-r--r-- | tests/regression.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/regression.rs b/tests/regression.rs index 90760ec9..8102fd90 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -569,6 +569,21 @@ rgtest!(r1064, |dir: Dir, mut cmd: TestCommand| { eqnice!("input:abc\n", cmd.arg("a(.*c)").stdout()); }); +// See: https://github.com/BurntSushi/ripgrep/issues/1130 +rgtest!(r1130, |dir: Dir, mut cmd: TestCommand| { + dir.create("foo", "test"); + eqnice!( + "foo\n", + cmd.arg("--files-with-matches").arg("test").arg("foo").stdout() + ); + + let mut cmd = dir.command(); + eqnice!( + "foo\n", + cmd.arg("--files-without-match").arg("nada").arg("foo").stdout() + ); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/1164 rgtest!(r1164, |dir: Dir, mut cmd: TestCommand| { dir.create_dir(".git"); |