Skip to content

Commit

Permalink
date: bugfix test_date_for_no_permission_file (#4544)
Browse files Browse the repository at this point in the history
  • Loading branch information
leon3s authored May 10, 2023
1 parent af58532 commit d8f1f1c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/by-util/test_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,27 @@ fn test_date_for_invalid_file() {
}

#[test]
#[cfg(unix)]
fn test_date_for_no_permission_file() {
let (at, mut ucmd) = at_and_ucmd!();
const FILE: &str = "file-no-perm-1";

use std::os::unix::fs::PermissionsExt;
let file = std::fs::OpenOptions::new()
.create(true)
.write(true)
.open(at.plus(FILE))
.unwrap();
file.set_permissions(std::fs::Permissions::from_mode(0o222))
.unwrap();
let result = ucmd.arg("--file").arg(FILE).fails();
result.no_stdout();
assert_eq!(
result.stderr_str().trim(),
format!("date: {FILE}: Permission denied")
);
}

fn test_date_for_dir_as_file() {
let result = new_ucmd!().arg("--file").arg("/").fails();
result.no_stdout();
Expand Down

0 comments on commit d8f1f1c

Please sign in to comment.