From 4f6c43a6dc15e69ae659ab3ac0495d7f23287943 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sun, 25 Mar 2018 17:49:47 +0200 Subject: [PATCH] Unit test for --type x --- tests/tests.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/tests.rs b/tests/tests.rs index 7e0e8dc..0529e80 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -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() {