mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
more: add test and change error type
This commit is contained in:
parent
d41777c52c
commit
50bff30c67
2 changed files with 14 additions and 1 deletions
|
@ -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()),
|
||||
))
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue