mirror of
https://github.com/sharkdp/fd
synced 2024-09-05 00:03:20 +00:00
Remove code duplication, add feature gate
This commit is contained in:
parent
6c9e743d43
commit
ed024ceb54
|
@ -209,9 +209,11 @@ impl TestEnv {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Similar to assert_output, but able to handle non-utf8 output
|
/// Similar to assert_output, but able to handle non-utf8 output
|
||||||
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
pub fn assert_output_raw(&self, args: &[&str], expected: &[u8]) {
|
pub fn assert_output_raw(&self, args: &[&str], expected: &[u8]) {
|
||||||
let actual = self.raw_output_subdirectory(".", args);
|
let output = self.assert_success_and_get_output(".", args);
|
||||||
assert_eq!(expected, actual.as_ref());
|
|
||||||
|
assert_eq!(expected, &output.stdout[..]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Assert that calling *fd* in the specified path under the root working directory,
|
/// Assert that calling *fd* in the specified path under the root working directory,
|
||||||
|
@ -238,23 +240,6 @@ impl TestEnv {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn raw_output_subdirectory<P: AsRef<Path>>(&self, path: P, args: &[&str]) -> Box<[u8]> {
|
|
||||||
// Setup *fd* command.
|
|
||||||
let mut cmd = process::Command::new(&self.fd_exe);
|
|
||||||
cmd.current_dir(self.temp_dir.path().join(path));
|
|
||||||
cmd.args(args);
|
|
||||||
|
|
||||||
// Run *fd*.
|
|
||||||
let output = cmd.output().expect("fd output");
|
|
||||||
|
|
||||||
// Check for exit status.
|
|
||||||
if !output.status.success() {
|
|
||||||
panic!(format_exit_error(args, &output));
|
|
||||||
}
|
|
||||||
|
|
||||||
output.stdout.into_boxed_slice()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Assert that calling *fd* with the specified arguments produces the expected error.
|
/// Assert that calling *fd* with the specified arguments produces the expected error.
|
||||||
pub fn assert_error(&self, args: &[&str], expected: &str) {
|
pub fn assert_error(&self, args: &[&str], expected: &str) {
|
||||||
self.assert_error_subdirectory(".", args, expected)
|
self.assert_error_subdirectory(".", args, expected)
|
||||||
|
|
Loading…
Reference in a new issue