Unit test for --type x

This commit is contained in:
sharkdp 2018-03-25 17:49:47 +02:00 committed by David Peter
parent 2cf8e7b8a5
commit 4f6c43a6dc
1 changed files with 27 additions and 0 deletions

View File

@ -563,6 +563,33 @@ fn test_type() {
te.assert_output(&["--type", "l"], "symlink");
}
/// Test `--type executable`
#[cfg(unix)]
#[test]
fn test_type_executable() {
use std::os::unix::fs::OpenOptionsExt;
let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);
fs::OpenOptions::new()
.create(true)
.write(true)
.mode(0o777)
.open(te.test_root().join("executable-file.sh"))
.unwrap();
te.assert_output(&["--type", "executable"], "executable-file.sh");
te.assert_output(
&["--type", "executable", "--type", "directory"],
"executable-file.sh
one
one/two
one/two/three
one/two/three/directory_foo",
);
}
/// File extension (--extension)
#[test]
fn test_extension() {