diff options
author | Andrew Schwartzmeyer <andrew@schwartzmeyer.com> | 2016-09-23 19:06:34 -0700 |
---|---|---|
committer | Andrew Schwartzmeyer <andrew@schwartzmeyer.com> | 2016-09-24 21:40:17 -0700 |
commit | a8f3d9e87e7e9192a9c1815da7c07d4522ccc1b2 (patch) | |
tree | 27dc814fa92f1f56359dfe75b281cc42fff2f376 /tests | |
parent | 1595f0faf594be5d303b1783857d23a0fda74230 (diff) |
Add --files-with-matches flag.
Closes #26.
Acts like --count but emits only the paths of files with matches,
suitable for piping to xargs. Both mmap and no-mmap searches terminate
after the first match is found. Documentation updated and tests added.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 72f5ab69..bcf62172 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -292,6 +292,20 @@ sherlock!(glob_negate, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { assert_eq!(lines, "file.py:Sherlock\n"); }); +sherlock!(count, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { + cmd.arg("--count"); + let lines: String = wd.stdout(&mut cmd); + let expected = "sherlock:2\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); + let expected = "sherlock\n"; + assert_eq!(lines, expected); +}); + sherlock!(after_context, |wd: WorkDir, mut cmd: Command| { cmd.arg("-A").arg("1"); let lines: String = wd.stdout(&mut cmd); |