diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-04-19 07:10:24 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-04-19 07:11:44 -0400 |
commit | e7829c05d3b9234f053e7d480f7e75028831d772 (patch) | |
tree | a6323746ebba4762cc21dca77b6d1e415d4898e7 /tests | |
parent | a6222939f9032b40de6065a71cf06d143dda86a3 (diff) |
cli: fix bug where last byte was stripped
In an effort to strip line terminators, we assumed their existence. But
a pattern file may not end with a line terminator, so we shouldn't
unconditionally strip them.
We fix this by moving to bstr's line handling, which does this for us
automatically.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/regression.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/regression.rs b/tests/regression.rs index 76a7b0b6..40a84654 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -705,3 +705,14 @@ rgtest!(r1203_reverse_suffix_literal, |dir: Dir, _: TestCommand| { let mut cmd = dir.command(); eqnice!("153.230000\n", cmd.arg(r"\d\d\d000").arg("test").stdout()); }); + +// See: https://github.com/BurntSushi/ripgrep/issues/1259 +rgtest!(r1259_drop_last_byte_nonl, |dir: Dir, mut cmd: TestCommand| { + dir.create("patterns-nonl", "[foo]"); + dir.create("patterns-nl", "[foo]\n"); + dir.create("test", "fz"); + + eqnice!("fz\n", cmd.arg("-f").arg("patterns-nonl").arg("test").stdout()); + cmd = dir.command(); + eqnice!("fz\n", cmd.arg("-f").arg("patterns-nl").arg("test").stdout()); +}); |