diff options
author | Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com> | 2019-09-26 14:50:40 +0300 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2020-02-17 17:16:28 -0500 |
commit | e71eedf0eb802c27541292f06676aa782be9bd21 (patch) | |
tree | ea54ad6eceeee6e08aa85f23809132c9780d8ceb /tests/feature.rs | |
parent | 88f46d12f1f3f7c2eac925ecb0b1c816ffddb943 (diff) |
cli: add --no-context-separator flag
--context-separator='' still adds a new line separator, which could
still potentially be useful. So we add a new `--no-context-separator`
flag that completely disables context separators even when the -A/-B/-C
context flags are used.
Closes #1390
Diffstat (limited to 'tests/feature.rs')
-rw-r--r-- | tests/feature.rs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/feature.rs b/tests/feature.rs index 13e87535..4d918163 100644 --- a/tests/feature.rs +++ b/tests/feature.rs @@ -727,3 +727,70 @@ rgtest!(f1207_ignore_encoding, |dir: Dir, mut cmd: TestCommand| { cmd.arg("--encoding").arg("none").arg("-a").arg("\\x00").arg("foo"); eqnice!("\u{FFFD}\u{FFFD}\x00b\n", cmd.stdout()); }); + +rgtest!(no_context_sep, |dir: Dir, mut cmd: TestCommand| { + dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); + cmd.args(&[ + "-A1", + "--no-context-separator", + "foo", + "test", + ]); + eqnice!("foo\nctx\nfoo\nctx\n", cmd.stdout()); +}); + +rgtest!(no_context_sep_overrides, |dir: Dir, mut cmd: TestCommand| { + dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); + cmd.args(&[ + "-A1", + "--context-separator", "AAA", + "--no-context-separator", + "foo", + "test", + ]); + eqnice!("foo\nctx\nfoo\nctx\n", cmd.stdout()); +}); + +rgtest!(no_context_sep_overridden, |dir: Dir, mut cmd: TestCommand| { + dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); + cmd.args(&[ + "-A1", + "--no-context-separator", + "--context-separator", "AAA", + "foo", + "test", + ]); + eqnice!("foo\nctx\nAAA\nfoo\nctx\n", cmd.stdout()); +}); + +rgtest!(context_sep, |dir: Dir, mut cmd: TestCommand| { + dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); + cmd.args(&[ + "-A1", + "--context-separator", "AAA", + "foo", + "test", + ]); + eqnice!("foo\nctx\nAAA\nfoo\nctx\n", cmd.stdout()); +}); + +rgtest!(context_sep_default, |dir: Dir, mut cmd: TestCommand| { + dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); + cmd.args(&[ + "-A1", + "foo", + "test", + ]); + eqnice!("foo\nctx\n--\nfoo\nctx\n", cmd.stdout()); +}); + +rgtest!(context_sep_empty, |dir: Dir, mut cmd: TestCommand| { + dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); + cmd.args(&[ + "-A1", + "--context-separator", "", + "foo", + "test", + ]); + eqnice!("foo\nctx\n\nfoo\nctx\n", cmd.stdout()); +}); |