1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-11-29 05:57:07 +02:00

test: add regression test for fixed bug

It turns out that #2094 was fixed in my `--max-count` refactor a few
commits back. This commit adds a regression test for it.

Closes #2094
This commit is contained in:
Andrew Gallant
2025-10-12 12:45:34 -04:00
parent f0faa91c68
commit 5c42c8c48f
2 changed files with 26 additions and 1 deletions

View File

@@ -29,7 +29,8 @@ Bug fixes:
Fix a bug where the "bytes searched" in `--stats` output could be incorrect.
* [BUG #2990](https://github.com/BurntSushi/ripgrep/issues/2990):
Fix a bug where ripgrep would mishandle globs that ended with a `.`.
* [BUG #3076](https://github.com/BurntSushi/ripgrep/issues/3076):
* [BUG #2094](https://github.com/BurntSushi/ripgrep/issues/2094),
[BUG #3076](https://github.com/BurntSushi/ripgrep/issues/3076):
Fix bug with `-m/--max-count` and `-U/--multiline` showing too many matches.
* [BUG #3100](https://github.com/BurntSushi/ripgrep/pull/3100):
Preserve line terminators when using `-r/--replace` flag.

View File

@@ -1304,6 +1304,30 @@ rgtest!(r1891, |dir: Dir, mut cmd: TestCommand| {
eqnice!("1:\n2:\n2:\n2:\n", cmd.args(&["-won", "", "test"]).stdout());
});
// See: https://github.com/BurntSushi/ripgrep/issues/2094
rgtest!(r2094, |dir: Dir, mut cmd: TestCommand| {
dir.create("haystack", "a\nb\nc\na\nb\nc");
cmd.args(&[
"--no-line-number",
"--no-filename",
"--multiline",
"--max-count=1",
"--passthru",
"--replace=B",
"b",
"haystack",
]);
let expected = "\
a
B
c
a
b
c
";
eqnice!(expected, cmd.stdout());
});
// See: https://github.com/BurntSushi/ripgrep/issues/2095
rgtest!(r2095, |dir: Dir, mut cmd: TestCommand| {
dir.create(