mirror of
https://github.com/nushell/nushell
synced 2024-12-26 04:53:09 +00:00
[umkdir][tests] get umask instead of assuming it (#14046)
# Description Contributors to this projects will have a test failure if their `umask` is not set to `0022`. Apparently on Debian (at least on my install), it is set to `0002` which makes my test fail. While `0022` is safer than the value I have, I want to reduce the amount if issue new contributors could have. I am making this test not assuming anything and instead, reading the user umask. # Related discussion I see that the `umask` command implementation has been discussed in #12256 . We could use this and enforce a umask for tests who rely on this. I believe however (let me know what you think) that hard coded values are harder to read in the test. # User-Facing Changes N/A # Tests + Formatting All green on my side after this MR 👍 # After Submitting Documentation is not impacted --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
parent
a95c2198a6
commit
9f714e62cb
1 changed files with 9 additions and 3 deletions
|
@ -2,6 +2,9 @@ use nu_test_support::fs::files_exist_at;
|
|||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[cfg(not(windows))]
|
||||
use uucore::mode;
|
||||
|
||||
#[test]
|
||||
fn creates_directory() {
|
||||
Playground::setup("mkdir_test_1", |dirs, _| {
|
||||
|
@ -145,10 +148,13 @@ fn mkdir_umask_permission() {
|
|||
.permissions()
|
||||
.mode();
|
||||
|
||||
let umask = mode::get_umask();
|
||||
let default_mode = 0o40777;
|
||||
let expected: u32 = default_mode & !umask;
|
||||
|
||||
assert_eq!(
|
||||
actual, 0o40755,
|
||||
"Most *nix systems have 0o00022 as the umask. \
|
||||
So directory permission should be 0o40755 = 0o40777 & (!0o00022)"
|
||||
actual, expected,
|
||||
"Umask should have been applied to created folder"
|
||||
);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue