mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
tests: touch up tests on Windows
This fixes warnings and adds an additional invalid UTF-8 test that will run on Windows.
This commit is contained in:
parent
1529ce3341
commit
5b1ce8bdc2
@ -241,6 +241,49 @@ rgtest!(notutf8, |dir: Dir, mut cmd: TestCommand| {
|
||||
);
|
||||
});
|
||||
|
||||
rgtest!(notutf8_file, |dir: Dir, mut cmd: TestCommand| {
|
||||
use std::ffi::OsStr;
|
||||
|
||||
// This test does not work with PCRE2 because PCRE2 does not support the
|
||||
// `u` flag.
|
||||
if dir.is_pcre2() {
|
||||
return;
|
||||
}
|
||||
|
||||
let name = "foo";
|
||||
let contents = &b"quux\xFFbaz"[..];
|
||||
|
||||
// APFS does not support creating files with invalid UTF-8 bytes, so just
|
||||
// skip the test if we can't create our file.
|
||||
if !dir.try_create_bytes(OsStr::new(name), contents).is_ok() {
|
||||
return;
|
||||
}
|
||||
cmd.arg("--json").arg(r"(?-u)\xFF");
|
||||
|
||||
let msgs = json_decode(&cmd.stdout());
|
||||
|
||||
assert_eq!(
|
||||
msgs[0].unwrap_begin(),
|
||||
Begin { path: Some(Data::text("foo")) }
|
||||
);
|
||||
assert_eq!(
|
||||
msgs[1].unwrap_match(),
|
||||
Match {
|
||||
path: Some(Data::text("foo")),
|
||||
lines: Data::bytes("cXV1eP9iYXo="),
|
||||
line_number: Some(1),
|
||||
absolute_offset: 0,
|
||||
submatches: vec![
|
||||
SubMatch {
|
||||
m: Data::bytes("/w=="),
|
||||
start: 4,
|
||||
end: 5,
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/416
|
||||
//
|
||||
// This test in particular checks that our match does _not_ include the `\r`
|
||||
|
@ -103,6 +103,7 @@ impl Dir {
|
||||
|
||||
/// Try to create a new file with the given name and contents in this
|
||||
/// directory.
|
||||
#[allow(dead_code)] // unused on Windows
|
||||
pub fn try_create<P: AsRef<Path>>(
|
||||
&self,
|
||||
name: P,
|
||||
@ -222,6 +223,7 @@ impl Dir {
|
||||
/// Creates a file symlink to the src with the given target name
|
||||
/// in this directory.
|
||||
#[cfg(windows)]
|
||||
#[allow(dead_code)] // unused on Windows
|
||||
pub fn link_file<S: AsRef<Path>, T: AsRef<Path>>(
|
||||
&self,
|
||||
src: S,
|
||||
|
Loading…
Reference in New Issue
Block a user