ripgrep/tests
Andrew Gallant d199058e77 cli: make rg -vf file behave sensibly
Previously, when `file` is empty (literally empty, as in, zero byte),
`rg -f file` and `rg -vf file` would behave identically. This is odd
and also doesn't match how GNU grep behaves. It's also not logically
correct. An empty file means _zero_ patterns which is an empty set. An
empty set matches nothing. Inverting the empty set should result in
matching everything.

This was because of an errant optimization that lets ripgrep quit early
if it can statically detect that no matches are possible.

Moreover, there was *also* a bug in how we constructed the PCRE2 pattern
when there are zero patterns. PCRE2 doesn't have a concept of sets of
patterns (unlike the `regex` crate), so we need to fake it with an empty
character class.

Fixes #1332, Fixes #3001, Closes #3041
2025-09-19 21:08:19 -04:00
..
data tests: fix tests for buffer size change 2021-03-23 18:14:18 -04:00
binary.rs tests: fix tests for buffer size change 2021-03-23 18:14:18 -04:00
feature.rs cli: prefix all non-fatal error messages with 'rg: ' 2024-01-06 14:15:52 -05:00
hay.rs tests: re-tool integration tests 2018-08-20 07:10:19 -04:00
json.rs style: simplify string formatting 2025-09-19 21:08:19 -04:00
macros.rs style: rustfmt everything 2020-02-17 19:24:53 -05:00
misc.rs ci: add more ARM build configurations to CI and release workflows 2024-01-06 10:21:34 -05:00
multiline.rs printer: vimgrep now only prints one line 2021-05-31 21:51:18 -04:00
regression.rs cli: make rg -vf file behave sensibly 2025-09-19 21:08:19 -04:00
tests.rs binary: rejigger ripgrep's handling of binary files 2019-04-14 19:29:27 -04:00
util.rs style: simplify string formatting 2025-09-19 21:08:19 -04:00