mirror of
https://github.com/sharkdp/fd
synced 2024-11-02 13:06:48 +00:00
Don't assume that /dev/null exists in test
If `/dev/null` doesn't exist or is not on a different partition during the test for `--one-file-system`, the test is skipped instead of mistakenly failing.
This commit is contained in:
parent
ed6c184020
commit
2828d90f99
1 changed files with 15 additions and 1 deletions
|
@ -562,10 +562,24 @@ fn test_follow() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn test_file_system_boundaries() {
|
fn test_file_system_boundaries() {
|
||||||
|
// Helper function to get the device ID for a given path
|
||||||
|
fn device_num(path: impl AsRef<Path>) -> u64 {
|
||||||
|
use std::os::unix::fs::MetadataExt;
|
||||||
|
|
||||||
|
path.as_ref().metadata().map(|md| md.dev()).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
// Can't simulate file system boundaries
|
// Can't simulate file system boundaries
|
||||||
let te = TestEnv::new(&[], &[]);
|
let te = TestEnv::new(&[], &[]);
|
||||||
|
|
||||||
// /dev/null should exist in all sane Unixes
|
let dev_null = Path::new("/dev/null");
|
||||||
|
|
||||||
|
// /dev/null should exist in all sane Unixes. Skip if it doesn't exist for some reason.
|
||||||
|
// Also skip should it be on the same device as the root partition for some reason.
|
||||||
|
if !dev_null.is_file() || device_num(dev_null) == device_num("/") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
te.assert_output(
|
te.assert_output(
|
||||||
&["--full-path", "--max-depth", "2", "^/dev/null$", "/"],
|
&["--full-path", "--max-depth", "2", "^/dev/null$", "/"],
|
||||||
"/dev/null",
|
"/dev/null",
|
||||||
|
|
Loading…
Reference in a new issue