summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2016-11-12 21:48:11 -0500
committerAndrew Gallant <jamslam@gmail.com>2016-11-17 19:53:41 -0500
commit92dc402f7f598c3d0045f94df9988bbe1c0c79cf (patch)
tree1ef3aef6c86ecb41bcf4d72c4d97bfd720f6fa52 /tests
parenta3f5e0c3d5f5c5088979a768765f988bf73dbf69 (diff)
Switch from Docopt to Clap.
There were two important reasons for the switch: 1. Performance. Docopt does poorly when the argv becomes large, which is a reasonable common use case for search tools. (e.g., use with xargs) 2. Better failure modes. Clap knows a lot more about how a particular argv might be invalid, and can therefore provide much clearer error messages. While both were important, (1) made it urgent. Note that since Clap requires at least Rust 1.11, this will in turn increase the minimum Rust version supported by ripgrep from Rust 1.9 to Rust 1.11. It is therefore a breaking change, so the soonest release of ripgrep with Clap will have to be 0.3. There is also at least one subtle breaking change in real usage. Previous to this commit, this used to work: rg -e -foo Where this would cause ripgrep to search for the string `-foo`. Clap currently has problems supporting this use case (see: https://github.com/kbknapp/clap-rs/issues/742), but it can be worked around by using this instead: rg -e [-]foo or even rg [-]foo and this still works: rg -- -foo This commit also adds Bash, Fish and PowerShell completion files to the release, fixes a bug that prevented ripgrep from working on file paths containing invalid UTF-8 and shows short descriptions in the output of `-h` but longer descriptions in the output of `--help`. Fixes #136, Fixes #189, Fixes #210, Fixes #230
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs22
-rw-r--r--tests/workdir.rs23
2 files changed, 42 insertions, 3 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index 3481121b..2d6f2d31 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -895,13 +895,31 @@ clean!(regression_206, "test", ".", |wd: WorkDir, mut cmd: Command| {
assert_eq!(lines, format!("{}:test\n", path("foo/bar.txt")));
});
-// See: https://github.com/BurntSushi/ripgrep/issues/228
-clean!(regression_228, "test", ".", |wd: WorkDir, mut cmd: Command| {
+// See: https://github.com/BurntSushi/ripgrep/issues/210
+clean!(regression_210, "test", ".", |wd: WorkDir, mut cmd: Command| {
wd.create_dir("foo");
cmd.arg("--ignore-file").arg("foo");
wd.assert_err(&mut cmd);
});
+// See: https://github.com/BurntSushi/ripgrep/issues/228
+#[cfg(unix)]
+#[test]
+fn regression_228() {
+ use std::ffi::OsStr;
+ use std::os::unix::ffi::OsStrExt;
+
+ let badutf8 = OsStr::from_bytes(&b"foo\xffbar"[..]);
+
+ let wd = WorkDir::new("regression_228");
+ let mut cmd = wd.command();
+ wd.create(badutf8, "test");
+ cmd.arg("-H").arg("test").arg(badutf8);
+
+ let out = wd.output(&mut cmd);
+ assert_eq!(out.stdout, b"foo\xffbar:test\n".to_vec());
+}
+
// See: https://github.com/BurntSushi/ripgrep/issues/7
sherlock!(feature_7, "-fpat", "sherlock", |wd: WorkDir, mut cmd: Command| {
wd.create("pat", "Sherlock\nHolmes");
diff --git a/tests/workdir.rs b/tests/workdir.rs
index d9de0f8a..7ae56d2c 100644
--- a/tests/workdir.rs
+++ b/tests/workdir.rs
@@ -76,8 +76,29 @@ impl WorkDir {
}
/// Returns the path to the ripgrep executable.
+ #[cfg(not(windows))]
+ pub fn bin(&self) -> PathBuf {
+ let path = self.root.join("rg");
+ if !path.is_file() {
+ // Looks like a recent version of Cargo changed the cwd or the
+ // location of the test executable.
+ self.root.join("../rg")
+ } else {
+ path
+ }
+ }
+
+ /// Returns the path to the ripgrep executable.
+ #[cfg(windows)]
pub fn bin(&self) -> PathBuf {
- self.root.join("rg")
+ let path = self.root.join("rg.exe");
+ if !path.is_file() {
+ // Looks like a recent version of Cargo changed the cwd or the
+ // location of the test executable.
+ self.root.join("../rg.exe")
+ } else {
+ path
+ }
}
/// Returns the path to this directory.