summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-02-05 19:22:44 -0500
committerAndrew Gallant <jamslam@gmail.com>2018-02-06 12:07:59 -0500
commit8cb5833ef9fd6c4c351d10a3e950339fa89adf49 (patch)
tree28310d7b592cc453371f06ead06a1d657f241038 /tests
parent85cd3f0a6e72a1d75c37be7b8ee4677a6bcc3f3d (diff)
argv: update clap to 2.29.4
We use the new AppSettings::AllArgsOverrideSelf to permit all flags to be specified multiple times. This removes the need for our previous work-around where we would enable `multiple` for every flag and then just extract the last value when consuming clap's matches. We also add a couple regression tests that ensure repeated switches and flags work as expected.
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index ecc840e7..e88756dc 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1166,6 +1166,49 @@ clean!(regression_493, " 're ", "input.txt", |wd: WorkDir, mut cmd: Command| {
assert_eq!(lines, " 're \n");
});
+// See: https://github.com/BurntSushi/ripgrep/issues/553
+sherlock!(regression_553_switch, "sherlock", ".",
+|wd: WorkDir, mut cmd: Command| {
+ cmd.arg("-i");
+ let lines: String = wd.stdout(&mut cmd);
+ let expected = "\
+sherlock:For the Doctor Watsons of this world, as opposed to the Sherlock
+sherlock:be, to a very large extent, the result of luck. Sherlock Holmes
+";
+ assert_eq!(lines, expected);
+
+ // This repeats the `-i` flag.
+ cmd.arg("-i");
+ let lines: String = wd.stdout(&mut cmd);
+ let expected = "\
+sherlock:For the Doctor Watsons of this world, as opposed to the Sherlock
+sherlock:be, to a very large extent, the result of luck. Sherlock Holmes
+";
+ assert_eq!(lines, expected);
+});
+
+sherlock!(regression_553_flag, "world|attached",
+|wd: WorkDir, mut cmd: Command| {
+ cmd.arg("-C").arg("1");
+ let lines: String = wd.stdout(&mut cmd);
+ let expected = "\
+For the Doctor Watsons of this world, as opposed to the Sherlock
+Holmeses, success in the province of detective work must always
+--
+but Doctor Watson has to have it taken out for him and dusted,
+and exhibited clearly, with a label attached.
+";
+ assert_eq!(lines, expected);
+
+ cmd.arg("-C").arg("0");
+ let lines: String = wd.stdout(&mut cmd);
+ let expected = "\
+For the Doctor Watsons of this world, as opposed to the Sherlock
+and exhibited clearly, with a label attached.
+";
+ assert_eq!(lines, expected);
+});
+
// See: https://github.com/BurntSushi/ripgrep/issues/599
clean!(regression_599, "^$", "input.txt", |wd: WorkDir, mut cmd: Command| {
wd.create("input.txt", "\n\ntest\n");