summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-03-10 10:34:35 -0500
committerAndrew Gallant <jamslam@gmail.com>2018-03-10 10:38:34 -0500
commit11a8f0eaf0f661c5b20c20fa2399314905d84fc1 (patch)
treec094e2ebb16b0c614e69f77d72852ce924893fbb /tests
parent27fc9f2fd341bd3ed672f79d43bf983514188b96 (diff)
args: treat --count --only-matching as --count-matches
Namely, when ripgrep is asked to count things and is also asked to print every match on its own line, then we should just automatically count the matches and not the lines. This is a departure from how GNU grep behaves, but there is a compelling argument to be made that GNU grep's behavior doesn't make a lot of sense. Note that since this changes the behavior of combining two existing flags, this is a breaking change.
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index b35f23f6..4ffb6d6d 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -426,6 +426,13 @@ sherlock!(count_matches_inverted, "Sherlock", ".", |wd: WorkDir, mut cmd: Comman
assert_eq!(lines, expected);
});
+sherlock!(count_matches_via_only, "the", ".", |wd: WorkDir, mut cmd: Command| {
+ cmd.arg("--count").arg("--only-matching");
+ let lines: String = wd.stdout(&mut cmd);
+ let expected = "sherlock:4\n";
+ assert_eq!(lines, expected);
+});
+
sherlock!(files_with_matches, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| {
cmd.arg("--files-with-matches");
let lines: String = wd.stdout(&mut cmd);