mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
mktemp: Added tests for checking directory permissions
This commit is contained in:
parent
25ecb81c7f
commit
2383950403
2 changed files with 16 additions and 0 deletions
|
@ -311,6 +311,7 @@ fn exec(dir: &Path, prefix: &str, rand: usize, suffix: &str, make_dir: bool) ->
|
||||||
.1
|
.1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
if make_dir {
|
if make_dir {
|
||||||
fs::set_permissions(&path, fs::Permissions::from_mode(0o700))?;
|
fs::set_permissions(&path, fs::Permissions::from_mode(0o700))?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@ use crate::common::util::*;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
static TEST_TEMPLATE1: &str = "tempXXXXXX";
|
static TEST_TEMPLATE1: &str = "tempXXXXXX";
|
||||||
static TEST_TEMPLATE2: &str = "temp";
|
static TEST_TEMPLATE2: &str = "temp";
|
||||||
static TEST_TEMPLATE3: &str = "tempX";
|
static TEST_TEMPLATE3: &str = "tempX";
|
||||||
|
@ -482,3 +485,15 @@ fn test_respect_template_directory() {
|
||||||
assert_matches_template!(template, filename);
|
assert_matches_template!(template, filename);
|
||||||
assert!(at.file_exists(filename));
|
assert!(at.file_exists(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_directory_permissions() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let result = ucmd.args(&["-d", "XXX"]).succeeds();
|
||||||
|
let dirname = result.no_stderr().stdout_str().trim_end();
|
||||||
|
assert_matches_template!("XXX", dirname);
|
||||||
|
let metadata = at.metadata(dirname);
|
||||||
|
assert!(metadata.is_dir());
|
||||||
|
assert_eq!(metadata.permissions().mode(), 0o40700);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue