diff options
author | Andrew Gallant <jamslam@gmail.com> | 2018-07-22 12:07:18 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-07-22 12:07:18 -0400 |
commit | dca8110da2a2783dedeb00f2cab21f3b55d211ad (patch) | |
tree | d71c8921127885bd0e2426f5cc01c19d93f77759 /tests | |
parent | 0d11497d2133f1973321ae383e139a9f1a71500f (diff) |
ripgrep: when given no patterns, don't match
Generally speaking, ripgrep prevents the case of not having any patterns
via its arg parsing. However, it is possible for users to provide a file
of patterns via the `-f` flag. If that file is empty, then ripgrep has
nothing to search for and therefore should not ever produce any match.
One way of fixing this might be to replace the absence of patterns with
a pattern that can never match, but this still requires opening and
searching through every file, which is quite a waste. Instead, we detect
this case explicitly and quit early.
Fixes #900
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 8a38f545..e6cc1534 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1320,6 +1320,12 @@ clean!(regression_807, "test", ".", |wd: WorkDir, mut cmd: Command| { assert_eq!(lines, format!("{}:test\n", path(".a/c/file"))); }); +// See: https://github.com/BurntSushi/ripgrep/issues/900 +sherlock!(regression_900, "-fpat", "sherlock", |wd: WorkDir, mut cmd: Command| { + wd.create("pat", ""); + wd.assert_err(&mut cmd); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/1 clean!(feature_1_sjis, "Шерлок Холмс", ".", |wd: WorkDir, mut cmd: Command| { let sherlock = |