mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-28 13:01:30 +02: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
@ -562,10 +562,24 @@ fn test_follow() {
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
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
|
||||
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(
|
||||
&["--full-path", "--max-depth", "2", "^/dev/null$", "/"],
|
||||
"/dev/null",
|
||||
|
Loading…
Reference in New Issue
Block a user