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

@@ -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(