-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
mktemp: change directory permission after creation #3471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
please add a test :) |
Writing one |
I tried writing a test, unfortunately that does't work |
could you please give more detail on "that does't work" ? :) |
@sylvestre I'm unable to get the permission of the newly created directory and compare with the |
@353fc443 here is a test case you can add to the #[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
#[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(), 0o700);
} |
@jfinkels Thanks I'll add the test and push it again! |
@jfinkels The test doesn't seem to work failures:
---- test_mktemp::test_directory_permissions stdout ----
current_directory_resolved:
run: /Users/user/coreutils/target/debug/coreutils mktemp -d XXX
thread 'test_mktemp::test_directory_permissions' panicked at 'assertion failed: `(left == right)`
left: `16832`,
right: `448`', /Users/user/coreutils/tests/by-util/test_mktemp.rs:498:5 Tested on Macos Edit: Can we use assert_eq!(metadata.permissions().mode(), 0o40700); instead of assert_eq!(metadata.permissions().mode(), 0o700); |
1dc0281
to
b84c1b2
Compare
04bedd2
to
2086d04
Compare
Yes, looks like you were able to fix up the test that way. Great, thanks. |
1 similar comment
Yes, looks like you were able to fix up the test that way. Great, thanks. |
@sylvestre any suggestions? |
nope, this is great, thanks for the ping :) |
Closes #3466