Skip to content
Myr

Don't assume that /dev/null exists in test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by Simon Engmann · committed by David Peter · parent ed6c184 · Browse files · 1 file+15 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−1 removed

  • tests:+15 added−1 removed

1 file+15 added−1 removed

modified:tests/tests.rs+15 added-1 removed
560 unmodified lines
561// Not limiting depth causes massive delay under Darwin, see BurntSushi/ripgrep#1429562#[test]563#[cfg(unix)]564fn test_file_system_boundaries() {565 // Helper function to get the device ID for a given path566 fn device_num(path: impl AsRef<Path>) -> u64 {567 use std::os::unix::fs::MetadataExt;568569 path.as_ref().metadata().map(|md| md.dev()).unwrap()570 }571572 // Can't simulate file system boundaries573 let te = TestEnv::new(&[], &[]);574575 let dev_null = Path::new("/dev/null");576568 // /dev/null should exist in all sane Unixes577 // /dev/null should exist in all sane Unixes. Skip if it doesn't exist for some reason.578 // Also skip should it be on the same device as the root partition for some reason.579 if !dev_null.is_file() || device_num(dev_null) == device_num("/") {580 return;581 }582583 te.assert_output(584 &["--full-path", "--max-depth", "2", "^/dev/null$", "/"],585 "/dev/null",586 );
858 unmodified lines