1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

more: add test and change error type

This commit is contained in:
tpeters 2023-05-23 18:03:25 +02:00
parent d41777c52c
commit 50bff30c67
2 changed files with 14 additions and 1 deletions

View file

@ -106,7 +106,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
let opened_file = match File::open(file) {
Err(why) => {
return Err(UUsageError::new(
return Err(USimpleError::new(
1,
format!("cannot open {}: {}", file.quote(), why.kind()),
))

View file

@ -1,5 +1,7 @@
use crate::common::util::TestScenario;
use is_terminal::IsTerminal;
use std::fs::{set_permissions, Permissions};
use std::os::unix::fs::PermissionsExt;
#[test]
fn test_more_no_arg() {
@ -32,3 +34,14 @@ fn test_more_dir_arg() {
.usage_error("'.' is a directory.");
}
}
#[test]
fn test_more_invalid_file_perms() {
let (at, mut ucmd) = at_and_ucmd!();
let permissions = Permissions::from_mode(0o244);
at.make_file("invalid-perms.txt").metadata().unwrap();
set_permissions(at.plus("invalid-perms.txt"), permissions).unwrap();
ucmd.arg("invalid-perms.txt").fails();
//.code_is(1)
//.stderr_is("more: cannot open 'invalid-perms.txt': permission denied");
}