mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
more: add test and change error type
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user