summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2017-05-29 09:51:58 -0400
committerAndrew Gallant <jamslam@gmail.com>2017-05-29 09:51:58 -0400
commit112b3c5e0ae232fdbce90cd505c57f2c4abc4a22 (patch)
tree747eb52e25a0633349f83d560587365fd6e7bd8c /tests
parent4c78ca8b70e2c434ecaab3f175525aae81229f9d (diff)
Fix another bug in -o/--only-matching.
The handling of the -o/--only-matching was incorrect. We cannot ever re-run regexes on a *subset* of a matched line, because it doesn't take into account zero width assertions on the edges of the regex. This occurs whenever an end user uses an assertion explicity, but also occurs when one is used implicitly, e.g., with the `-w` flag. This instead reuses the initial matched range from the first regex match. We also apply this fix to coloring. Fixes #493
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index 930aa165..d9c843ad 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1079,7 +1079,8 @@ clean!(regression_428_color_context_path, "foo", ".", |wd: WorkDir, mut cmd: Com
});
// See: https://github.com/BurntSushi/ripgrep/issues/428
-clean!(regression_428_unrecognized_style, "Sherlok", ".", |wd: WorkDir, mut cmd: Command| {
+clean!(regression_428_unrecognized_style, "Sherlok", ".",
+|wd: WorkDir, mut cmd: Command| {
cmd.arg("--colors=match:style:");
wd.assert_err(&mut cmd);
@@ -1091,6 +1092,15 @@ Unrecognized style attribute ''. Choose from: nobold, bold, nointense, intense.
assert_eq!(err, expected);
});
+// See: https://github.com/BurntSushi/ripgrep/issues/493
+clean!(regression_493, " 're ", "input.txt", |wd: WorkDir, mut cmd: Command| {
+ wd.create("input.txt", "peshwaship 're seminomata");
+ cmd.arg("-o").arg("-w");
+
+ let lines: String = wd.stdout(&mut cmd);
+ assert_eq!(lines, " 're \n");
+});
+
// See: https://github.com/BurntSushi/ripgrep/issues/1
clean!(feature_1_sjis, "Шерлок Холмс", ".", |wd: WorkDir, mut cmd: Command| {
let sherlock =