diff options
author | Andrew Gallant <jamslam@gmail.com> | 2023-11-25 10:39:08 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2023-11-25 15:03:53 -0500 |
commit | 9ed7565fcb47d02e76398d41f24ba0817f6b9c2f (patch) | |
tree | 847118ef328de5b61e62ee445de9bf20d689da73 /tests | |
parent | 7bb9f35d2d0b02952e20c082b17be856788e5f44 (diff) |
cli: error when searching for NUL
Basically, unless the -a/--text flag is given, it is generally always an
error to search for an explicit NUL byte because the binary detection
will prevent it from matching.
Fixes #1838
Diffstat (limited to 'tests')
-rw-r--r-- | tests/regression.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/regression.rs b/tests/regression.rs index 04138fdf..54490b98 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -977,6 +977,20 @@ rgtest!(r1765, |dir: Dir, mut cmd: TestCommand| { assert!(!cmd.stdout().is_empty()); }); +// See: https://github.com/BurntSushi/ripgrep/issues/1838 +rgtest!(r1838_nul_error_with_binary_detection, |dir: Dir, _: TestCommand| { + // We don't support this error reporting with PCRE2 since we can't parse + // the pattern (easily) to give a good error message. + if dir.is_pcre2() { + return; + } + dir.create("test", "foo\n"); + + dir.command().args(&[r"foo\x00?"]).assert_err(); + eqnice!("test:foo\n", dir.command().args(&["-a", r"foo\x00?"]).stdout()); +}); + +// See: https://github.com/BurntSushi/ripgrep/issues/1866 rgtest!(r1866, |dir: Dir, mut cmd: TestCommand| { dir.create("test", "foobar\nfoobar\nfoo quux"); cmd.args(&[ |