stats: fix case where "bytes searched" could be wrong
Specifically, if the search was instructed to quit early, we might not have correctly marked the number of bytes consumed. I don't think this bug occurs when memory maps are used to read the haystack. Closes #2944
This commit is contained in:
@@ -1454,3 +1454,10 @@ rgtest!(r2658_null_data_line_regexp, |dir: Dir, mut cmd: TestCommand| {
|
||||
let got = cmd.args(&["--null-data", "--line-regexp", r"bar"]).stdout();
|
||||
eqnice!("haystack:bar\0", got);
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/pull/2944
|
||||
rgtest!(r2944_incorrect_bytes_searched, |dir: Dir, mut cmd: TestCommand| {
|
||||
dir.create("haystack", "foo1\nfoo2\nfoo3\nfoo4\nfoo5\n");
|
||||
let got = cmd.args(&["--stats", "-m2", "foo", "."]).stdout();
|
||||
assert!(got.contains("10 bytes searched\n"));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user