summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2017-04-12 17:21:07 -0400
committerAndrew Gallant <jamslam@gmail.com>2017-04-12 18:14:23 -0400
commit7ad23e5565e9dca308c52929571c0609c28291c6 (patch)
treefa8dc70184775a7538a602d2f677f4e53608050f /tests
parent66efbad871620fe2dbe675438fdc8d9922e72826 (diff)
Use for_label_no_replacement.
This will cause certain unsupported legacy encodings to act as if they don't exist, in order to avoid using an unhelpful (in the context of file searching) "replacement" encoding. Kudos to @hsivonen for chirping about this!
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs15
-rw-r--r--tests/workdir.rs17
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index ef332ae7..38812c4e 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1137,6 +1137,21 @@ clean!(feature_1_eucjp, "Шерлок Холмс", ".",
assert_eq!(lines, "foo:Шерлок Холмс\n");
});
+// See: https://github.com/BurntSushi/ripgrep/issues/1
+sherlock!(feature_1_unknown_encoding, "Sherlock", ".",
+|wd: WorkDir, mut cmd: Command| {
+ cmd.arg("-Efoobar");
+ wd.assert_non_empty_stderr(&mut cmd);
+});
+
+// See: https://github.com/BurntSushi/ripgrep/issues/1
+// Specific: https://github.com/BurntSushi/ripgrep/pull/398/files#r111109265
+sherlock!(feature_1_replacement_encoding, "Sherlock", ".",
+|wd: WorkDir, mut cmd: Command| {
+ cmd.arg("-Ecsiso2022kr");
+ wd.assert_non_empty_stderr(&mut cmd);
+});
+
// 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 a5fe9e54..06621532 100644
--- a/tests/workdir.rs
+++ b/tests/workdir.rs
@@ -256,6 +256,23 @@ impl WorkDir {
String::from_utf8_lossy(&o.stderr));
}
}
+
+ /// Runs the given command and asserts that something was printed to
+ /// stderr.
+ pub fn assert_non_empty_stderr(&self, cmd: &mut process::Command) {
+ let o = cmd.output().unwrap();
+ if o.status.success() || o.stderr.is_empty() {
+ panic!("\n\n===== {:?} =====\n\
+ command succeeded but expected failure!\
+ \n\ncwd: {}\
+ \n\nstatus: {}\
+ \n\nstdout: {}\n\nstderr: {}\
+ \n\n=====\n",
+ cmd, self.dir.display(), o.status,
+ String::from_utf8_lossy(&o.stdout),
+ String::from_utf8_lossy(&o.stderr));
+ }
+ }
}
fn nice_err<P: AsRef<Path>, T, E: error::Error>(