1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 20:17:45 +00:00

Merge pull request #2277 from ycd/refactor-error-macro

uucore: refactor show_error! macro
This commit is contained in:
Sylvestre Ledru 2021-05-26 13:13:24 +02:00 committed by GitHub
commit 2f58f92b06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 176 additions and 190 deletions

View file

@ -347,7 +347,7 @@ fn cat_files(files: Vec<String>, options: &OutputOptions) -> Result<(), u32> {
for path in &files { for path in &files {
if let Err(err) = cat_path(path, &options, &mut state) { if let Err(err) = cat_path(path, &options, &mut state) {
show_info!("{}: {}", path, err); show_error!("{}: {}", path, err);
error_count += 1; error_count += 1;
} }
} }

View file

@ -97,7 +97,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
if recursive { if recursive {
if bit_flag == FTS_PHYSICAL { if bit_flag == FTS_PHYSICAL {
if derefer == 1 { if derefer == 1 {
show_info!("-R --dereference requires -H or -L"); show_error!("-R --dereference requires -H or -L");
return 1; return 1;
} }
derefer = 0; derefer = 0;
@ -132,7 +132,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
dest_gid = meta.gid(); dest_gid = meta.gid();
} }
Err(e) => { Err(e) => {
show_info!("failed to get attributes of '{}': {}", file, e); show_error!("failed to get attributes of '{}': {}", file, e);
return 1; return 1;
} }
} }
@ -143,7 +143,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
dest_gid = g; dest_gid = g;
} }
_ => { _ => {
show_info!("invalid group: {}", matches.free[0].as_str()); show_error!("invalid group: {}", matches.free[0].as_str());
return 1; return 1;
} }
} }
@ -235,8 +235,8 @@ impl Chgrper {
if let Some(p) = may_exist { if let Some(p) = may_exist {
if p.parent().is_none() || self.is_bind_root(p) { if p.parent().is_none() || self.is_bind_root(p) {
show_info!("it is dangerous to operate recursively on '/'"); show_error!("it is dangerous to operate recursively on '/'");
show_info!("use --no-preserve-root to override this failsafe"); show_error!("use --no-preserve-root to override this failsafe");
return 1; return 1;
} }
} }
@ -250,12 +250,12 @@ impl Chgrper {
self.verbosity.clone(), self.verbosity.clone(),
) { ) {
Ok(n) => { Ok(n) => {
show_info!("{}", n); show_error!("{}", n);
0 0
} }
Err(e) => { Err(e) => {
if self.verbosity != Verbosity::Silent { if self.verbosity != Verbosity::Silent {
show_info!("{}", e); show_error!("{}", e);
} }
1 1
} }
@ -275,7 +275,7 @@ impl Chgrper {
for entry in WalkDir::new(root).follow_links(follow).min_depth(1) { for entry in WalkDir::new(root).follow_links(follow).min_depth(1) {
let entry = unwrap!(entry, e, { let entry = unwrap!(entry, e, {
ret = 1; ret = 1;
show_info!("{}", e); show_error!("{}", e);
continue; continue;
}); });
let path = entry.path(); let path = entry.path();
@ -290,13 +290,13 @@ impl Chgrper {
ret = match wrap_chgrp(path, &meta, self.dest_gid, follow, self.verbosity.clone()) { ret = match wrap_chgrp(path, &meta, self.dest_gid, follow, self.verbosity.clone()) {
Ok(n) => { Ok(n) => {
if !n.is_empty() { if !n.is_empty() {
show_info!("{}", n); show_error!("{}", n);
} }
0 0
} }
Err(e) => { Err(e) => {
if self.verbosity != Verbosity::Silent { if self.verbosity != Verbosity::Silent {
show_info!("{}", e); show_error!("{}", e);
} }
1 1
} }
@ -313,7 +313,7 @@ impl Chgrper {
unwrap!(path.metadata(), e, { unwrap!(path.metadata(), e, {
match self.verbosity { match self.verbosity {
Silent => (), Silent => (),
_ => show_info!("cannot access '{}': {}", path.display(), e), _ => show_error!("cannot access '{}': {}", path.display(), e),
} }
return None; return None;
}) })
@ -321,7 +321,7 @@ impl Chgrper {
unwrap!(path.symlink_metadata(), e, { unwrap!(path.symlink_metadata(), e, {
match self.verbosity { match self.verbosity {
Silent => (), Silent => (),
_ => show_info!("cannot dereference '{}': {}", path.display(), e), _ => show_error!("cannot dereference '{}': {}", path.display(), e),
} }
return None; return None;
}) })

View file

@ -316,7 +316,7 @@ impl Chmoder {
show_error!("{}", err); show_error!("{}", err);
} }
if self.verbose { if self.verbose {
show_info!( show_error!(
"failed to change mode of file '{}' from {:o} ({}) to {:o} ({})", "failed to change mode of file '{}' from {:o} ({}) to {:o} ({})",
file.display(), file.display(),
fperm, fperm,
@ -328,7 +328,7 @@ impl Chmoder {
Err(1) Err(1)
} else { } else {
if self.verbose || self.changes { if self.verbose || self.changes {
show_info!( show_error!(
"mode of '{}' changed from {:o} ({}) to {:o} ({})", "mode of '{}' changed from {:o} ({}) to {:o} ({})",
file.display(), file.display(),
fperm, fperm,

View file

@ -199,7 +199,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
if recursive { if recursive {
if bit_flag == FTS_PHYSICAL { if bit_flag == FTS_PHYSICAL {
if derefer == 1 { if derefer == 1 {
show_info!("-R --dereference requires -H or -L"); show_error!("-R --dereference requires -H or -L");
return 1; return 1;
} }
derefer = 0; derefer = 0;
@ -227,7 +227,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
Ok((Some(uid), Some(gid))) => IfFrom::UserGroup(uid, gid), Ok((Some(uid), Some(gid))) => IfFrom::UserGroup(uid, gid),
Ok((None, None)) => IfFrom::All, Ok((None, None)) => IfFrom::All,
Err(e) => { Err(e) => {
show_info!("{}", e); show_error!("{}", e);
return 1; return 1;
} }
} }
@ -244,7 +244,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
dest_uid = Some(meta.uid()); dest_uid = Some(meta.uid());
} }
Err(e) => { Err(e) => {
show_info!("failed to get attributes of '{}': {}", file, e); show_error!("failed to get attributes of '{}': {}", file, e);
return 1; return 1;
} }
} }
@ -255,7 +255,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
dest_gid = g; dest_gid = g;
} }
Err(e) => { Err(e) => {
show_info!("{}", e); show_error!("{}", e);
return 1; return 1;
} }
} }
@ -377,8 +377,8 @@ impl Chowner {
if let Some(p) = may_exist { if let Some(p) = may_exist {
if p.parent().is_none() { if p.parent().is_none() {
show_info!("it is dangerous to operate recursively on '/'"); show_error!("it is dangerous to operate recursively on '/'");
show_info!("use --no-preserve-root to override this failsafe"); show_error!("use --no-preserve-root to override this failsafe");
return 1; return 1;
} }
} }
@ -395,13 +395,13 @@ impl Chowner {
) { ) {
Ok(n) => { Ok(n) => {
if !n.is_empty() { if !n.is_empty() {
show_info!("{}", n); show_error!("{}", n);
} }
0 0
} }
Err(e) => { Err(e) => {
if self.verbosity != Verbosity::Silent { if self.verbosity != Verbosity::Silent {
show_info!("{}", e); show_error!("{}", e);
} }
1 1
} }
@ -424,7 +424,7 @@ impl Chowner {
for entry in WalkDir::new(root).follow_links(follow).min_depth(1) { for entry in WalkDir::new(root).follow_links(follow).min_depth(1) {
let entry = unwrap!(entry, e, { let entry = unwrap!(entry, e, {
ret = 1; ret = 1;
show_info!("{}", e); show_error!("{}", e);
continue; continue;
}); });
let path = entry.path(); let path = entry.path();
@ -450,13 +450,13 @@ impl Chowner {
) { ) {
Ok(n) => { Ok(n) => {
if !n.is_empty() { if !n.is_empty() {
show_info!("{}", n); show_error!("{}", n);
} }
0 0
} }
Err(e) => { Err(e) => {
if self.verbosity != Verbosity::Silent { if self.verbosity != Verbosity::Silent {
show_info!("{}", e); show_error!("{}", e);
} }
1 1
} }
@ -472,7 +472,7 @@ impl Chowner {
unwrap!(path.metadata(), e, { unwrap!(path.metadata(), e, {
match self.verbosity { match self.verbosity {
Silent => (), Silent => (),
_ => show_info!("cannot access '{}': {}", path.display(), e), _ => show_error!("cannot access '{}': {}", path.display(), e),
} }
return None; return None;
}) })
@ -480,7 +480,7 @@ impl Chowner {
unwrap!(path.symlink_metadata(), e, { unwrap!(path.symlink_metadata(), e, {
match self.verbosity { match self.verbosity {
Silent => (), Silent => (),
_ => show_info!("cannot dereference '{}': {}", path.display(), e), _ => show_error!("cannot dereference '{}': {}", path.display(), e),
} }
return None; return None;
}) })

View file

@ -105,7 +105,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
if out_format == OutputFmt::Unknown { if out_format == OutputFmt::Unknown {
match guess_syntax() { match guess_syntax() {
OutputFmt::Unknown => { OutputFmt::Unknown => {
show_info!("no SHELL environment variable, and no shell type option given"); show_error!("no SHELL environment variable, and no shell type option given");
return 1; return 1;
} }
fmt => out_format = fmt, fmt => out_format = fmt,
@ -130,7 +130,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
) )
} }
Err(e) => { Err(e) => {
show_info!("{}: {}", matches.free[0], e); show_error!("{}: {}", matches.free[0], e);
return 1; return 1;
} }
} }
@ -141,7 +141,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
0 0
} }
Err(s) => { Err(s) => {
show_info!("{}", s); show_error!("{}", s);
1 1
} }
} }

View file

@ -370,13 +370,13 @@ fn directory(paths: Vec<String>, b: Behavior) -> i32 {
// created ancestor directories will have the default mode. Hence it is safe to use // created ancestor directories will have the default mode. Hence it is safe to use
// fs::create_dir_all and then only modify the target's dir mode. // fs::create_dir_all and then only modify the target's dir mode.
if let Err(e) = fs::create_dir_all(path) { if let Err(e) = fs::create_dir_all(path) {
show_info!("{}: {}", path.display(), e); show_error!("{}: {}", path.display(), e);
all_successful = false; all_successful = false;
continue; continue;
} }
if b.verbose { if b.verbose {
show_info!("creating directory '{}'", path.display()); show_error!("creating directory '{}'", path.display());
} }
} }
@ -461,7 +461,7 @@ fn copy_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i3
let mut all_successful = true; let mut all_successful = true;
for sourcepath in files.iter() { for sourcepath in files.iter() {
if !sourcepath.exists() { if !sourcepath.exists() {
show_info!( show_error!(
"cannot stat '{}': No such file or directory", "cannot stat '{}': No such file or directory",
sourcepath.display() sourcepath.display()
); );
@ -471,7 +471,7 @@ fn copy_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i3
} }
if sourcepath.is_dir() { if sourcepath.is_dir() {
show_info!("omitting directory '{}'", sourcepath.display()); show_error!("omitting directory '{}'", sourcepath.display());
all_successful = false; all_successful = false;
continue; continue;
} }
@ -588,10 +588,10 @@ fn copy(from: &Path, to: &Path, b: &Behavior) -> Result<(), ()> {
) { ) {
Ok(n) => { Ok(n) => {
if !n.is_empty() { if !n.is_empty() {
show_info!("{}", n); show_error!("{}", n);
} }
} }
Err(e) => show_info!("{}", e), Err(e) => show_error!("{}", e),
} }
} }
@ -608,10 +608,10 @@ fn copy(from: &Path, to: &Path, b: &Behavior) -> Result<(), ()> {
match wrap_chgrp(to, &meta, group_id, false, Verbosity::Normal) { match wrap_chgrp(to, &meta, group_id, false, Verbosity::Normal) {
Ok(n) => { Ok(n) => {
if !n.is_empty() { if !n.is_empty() {
show_info!("{}", n); show_error!("{}", n);
} }
} }
Err(e) => show_info!("{}", e), Err(e) => show_error!("{}", e),
} }
} }
@ -626,12 +626,12 @@ fn copy(from: &Path, to: &Path, b: &Behavior) -> Result<(), ()> {
match set_file_times(to, accessed_time, modified_time) { match set_file_times(to, accessed_time, modified_time) {
Ok(_) => {} Ok(_) => {}
Err(e) => show_info!("{}", e), Err(e) => show_error!("{}", e),
} }
} }
if b.verbose { if b.verbose {
show_info!("'{}' -> '{}'", from.display(), to.display()); show_error!("'{}' -> '{}'", from.display(), to.display());
} }
Ok(()) Ok(())

View file

@ -23,7 +23,7 @@ pub fn parse(mode_string: &str, considering_dir: bool) -> Result<u32, String> {
pub fn chmod(path: &Path, mode: u32) -> Result<(), ()> { pub fn chmod(path: &Path, mode: u32) -> Result<(), ()> {
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
fs::set_permissions(path, fs::Permissions::from_mode(mode)).map_err(|err| { fs::set_permissions(path, fs::Permissions::from_mode(mode)).map_err(|err| {
show_info!("{}: chmod failed with error {}", path.display(), err); show_error!("{}: chmod failed with error {}", path.display(), err);
}) })
} }

View file

@ -101,7 +101,7 @@ fn exec(dirs: Vec<String>, recursive: bool, mode: u16, verbose: bool) -> i32 {
if !recursive { if !recursive {
if let Some(parent) = path.parent() { if let Some(parent) = path.parent() {
if parent != empty && !parent.exists() { if parent != empty && !parent.exists() {
show_info!( show_error!(
"cannot create directory '{}': No such file or directory", "cannot create directory '{}': No such file or directory",
path.display() path.display()
); );
@ -125,7 +125,7 @@ fn mkdir(path: &Path, recursive: bool, mode: u16, verbose: bool) -> i32 {
fs::create_dir fs::create_dir
}; };
if let Err(e) = create_dir(path) { if let Err(e) = create_dir(path) {
show_info!("{}: {}", path.display(), e.to_string()); show_error!("{}: {}", path.display(), e.to_string());
return 1; return 1;
} }

View file

@ -136,7 +136,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
let mode = match get_mode(&matches) { let mode = match get_mode(&matches) {
Ok(mode) => mode, Ok(mode) => mode,
Err(err) => { Err(err) => {
show_info!("{}", err); show_error!("{}", err);
return 1; return 1;
} }
}; };

View file

@ -157,7 +157,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
} }
if matches.is_present(OPT_TMPDIR) && PathBuf::from(prefix).is_absolute() { if matches.is_present(OPT_TMPDIR) && PathBuf::from(prefix).is_absolute() {
show_info!( show_error!(
"invalid template, {}; with --tmpdir, it may not be absolute", "invalid template, {}; with --tmpdir, it may not be absolute",
template template
); );
@ -229,7 +229,7 @@ fn exec(
} }
Err(e) => { Err(e) => {
if !quiet { if !quiet {
show_info!("{}: {}", e, tmpdir.display()); show_error!("{}: {}", e, tmpdir.display());
} }
return 1; return 1;
} }
@ -244,7 +244,7 @@ fn exec(
Ok(f) => f, Ok(f) => f,
Err(e) => { Err(e) => {
if !quiet { if !quiet {
show_info!("failed to create tempfile: {}", e); show_error!("failed to create tempfile: {}", e);
} }
return 1; return 1;
} }

View file

@ -122,13 +122,13 @@ fn find_stdout() -> File {
.open(Path::new(NOHUP_OUT)) .open(Path::new(NOHUP_OUT))
{ {
Ok(t) => { Ok(t) => {
show_info!("ignoring input and appending output to '{}'", NOHUP_OUT); show_error!("ignoring input and appending output to '{}'", NOHUP_OUT);
t t
} }
Err(e1) => { Err(e1) => {
let home = match env::var("HOME") { let home = match env::var("HOME") {
Err(_) => { Err(_) => {
show_info!("failed to open '{}': {}", NOHUP_OUT, e1); show_error!("failed to open '{}': {}", NOHUP_OUT, e1);
exit!(internal_failure_code) exit!(internal_failure_code)
} }
Ok(h) => h, Ok(h) => h,
@ -143,12 +143,12 @@ fn find_stdout() -> File {
.open(&homeout) .open(&homeout)
{ {
Ok(t) => { Ok(t) => {
show_info!("ignoring input and appending output to '{}'", homeout_str); show_error!("ignoring input and appending output to '{}'", homeout_str);
t t
} }
Err(e2) => { Err(e2) => {
show_info!("failed to open '{}': {}", NOHUP_OUT, e1); show_error!("failed to open '{}': {}", NOHUP_OUT, e1);
show_info!("failed to open '{}': {}", homeout_str, e2); show_error!("failed to open '{}': {}", homeout_str, e2);
exit!(internal_failure_code) exit!(internal_failure_code)
} }
} }

View file

@ -216,7 +216,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
match result { match result {
Err(e) => { Err(e) => {
std::io::stdout().flush().expect("error flushing stdout"); std::io::stdout().flush().expect("error flushing stdout");
show_info!("{}", e); show_error!("{}", e);
1 1
} }
_ => 0, _ => 0,

View file

@ -749,7 +749,7 @@ impl Stater {
} }
} }
Err(e) => { Err(e) => {
show_info!("cannot stat '{}': {}", file, e); show_error!("cannot stat '{}': {}", file, e);
return 1; return 1;
} }
} }
@ -842,7 +842,7 @@ impl Stater {
} }
} }
Err(e) => { Err(e) => {
show_info!("cannot read file system information for '{}': {}", file, e); show_error!("cannot read file system information for '{}': {}", file, e);
return 1; return 1;
} }
} }
@ -1001,7 +1001,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
match Stater::new(matches) { match Stater::new(matches) {
Ok(stater) => stater.exec(), Ok(stater) => stater.exec(),
Err(e) => { Err(e) => {
show_info!("{}", e); show_error!("{}", e);
1 1
} }
} }

View file

@ -166,7 +166,7 @@ impl Write for MultiWriter {
let result = writer.write_all(buf); let result = writer.write_all(buf);
match result { match result {
Err(f) => { Err(f) => {
show_info!("{}: {}", writer.name, f.to_string()); show_error!("{}: {}", writer.name, f.to_string());
false false
} }
_ => true, _ => true,
@ -180,7 +180,7 @@ impl Write for MultiWriter {
let result = writer.flush(); let result = writer.flush();
match result { match result {
Err(f) => { Err(f) => {
show_info!("{}: {}", writer.name, f.to_string()); show_error!("{}: {}", writer.name, f.to_string());
false false
} }
_ => true, _ => true,
@ -213,7 +213,7 @@ impl Read for NamedReader {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> { fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
match self.inner.read(buf) { match self.inner.read(buf) {
Err(f) => { Err(f) => {
show_info!("{}: {}", Path::new("stdin").display(), f.to_string()); show_error!("{}: {}", Path::new("stdin").display(), f.to_string());
Err(f) Err(f)
} }
okay => okay, okay => okay,

View file

@ -25,7 +25,7 @@ macro_rules! executable(
#[macro_export] #[macro_export]
macro_rules! show_error( macro_rules! show_error(
($($args:tt)+) => ({ ($($args:tt)+) => ({
eprint!("{}: error: ", executable!()); eprint!("{}: ", executable!());
eprintln!($($args)+); eprintln!($($args)+);
}) })
); );
@ -47,15 +47,6 @@ macro_rules! show_warning(
}) })
); );
/// Show an info message to stderr in a silimar style to GNU coreutils.
#[macro_export]
macro_rules! show_info(
($($args:tt)+) => ({
eprint!("{}: ", executable!());
eprintln!($($args)+);
})
);
/// Show a bad inocation help message in a similar style to GNU coreutils. /// Show a bad inocation help message in a similar style to GNU coreutils.
#[macro_export] #[macro_export]
macro_rules! show_usage_error( macro_rules! show_usage_error(

View file

@ -98,7 +98,7 @@ fn test_wrap_bad_arg() {
.arg(wrap_param) .arg(wrap_param)
.arg("b") .arg("b")
.fails() .fails()
.stderr_only("base32: error: Invalid wrap size: b: invalid digit found in string\n"); .stderr_only("base32: Invalid wrap size: b: invalid digit found in string\n");
} }
} }
@ -109,7 +109,7 @@ fn test_base32_extra_operand() {
.arg("a.txt") .arg("a.txt")
.arg("a.txt") .arg("a.txt")
.fails() .fails()
.stderr_only("base32: error: extra operand a.txt"); .stderr_only("base32: extra operand a.txt");
} }
#[test] #[test]
@ -117,5 +117,5 @@ fn test_base32_file_not_found() {
new_ucmd!() new_ucmd!()
.arg("a.txt") .arg("a.txt")
.fails() .fails()
.stderr_only("base32: error: a.txt: No such file or directory"); .stderr_only("base32: a.txt: No such file or directory");
} }

View file

@ -88,7 +88,7 @@ fn test_wrap_bad_arg() {
.arg(wrap_param) .arg(wrap_param)
.arg("b") .arg("b")
.fails() .fails()
.stderr_only("base64: error: Invalid wrap size: b: invalid digit found in string\n"); .stderr_only("base64: Invalid wrap size: b: invalid digit found in string\n");
} }
} }
@ -99,7 +99,7 @@ fn test_base64_extra_operand() {
.arg("a.txt") .arg("a.txt")
.arg("a.txt") .arg("a.txt")
.fails() .fails()
.stderr_only("base64: error: extra operand a.txt"); .stderr_only("base64: extra operand a.txt");
} }
#[test] #[test]
@ -107,5 +107,5 @@ fn test_base64_file_not_found() {
new_ucmd!() new_ucmd!()
.arg("a.txt") .arg("a.txt")
.fails() .fails()
.stderr_only("base64: error: a.txt: No such file or directory"); .stderr_only("base64: a.txt: No such file or directory");
} }

View file

@ -109,7 +109,7 @@ fn test_no_args() {
fn test_no_args_output() { fn test_no_args_output() {
new_ucmd!() new_ucmd!()
.fails() .fails()
.stderr_is("basename: error: missing operand\nTry 'basename --help' for more information."); .stderr_is("basename: missing operand\nTry 'basename --help' for more information.");
} }
#[test] #[test]
@ -119,9 +119,10 @@ fn test_too_many_args() {
#[test] #[test]
fn test_too_many_args_output() { fn test_too_many_args_output() {
new_ucmd!().args(&["a", "b", "c"]).fails().stderr_is( new_ucmd!()
"basename: error: extra operand 'c'\nTry 'basename --help' for more information.", .args(&["a", "b", "c"])
); .fails()
.stderr_is("basename: extra operand 'c'\nTry 'basename --help' for more information.");
} }
#[cfg(any(unix, target_os = "redox"))] #[cfg(any(unix, target_os = "redox"))]

View file

@ -338,7 +338,7 @@ fn test_chmod_preserve_root() {
.arg("755") .arg("755")
.arg("/") .arg("/")
.fails() .fails()
.stderr_contains(&"chmod: error: it is dangerous to operate recursively on '/'"); .stderr_contains(&"chmod: it is dangerous to operate recursively on '/'");
} }
#[test] #[test]

View file

@ -21,7 +21,7 @@ fn test_enter_chroot_fails() {
assert!(result assert!(result
.stderr_str() .stderr_str()
.starts_with("chroot: error: cannot chroot to jail: Operation not permitted (os error 1)")); .starts_with("chroot: cannot chroot to jail: Operation not permitted (os error 1)"));
} }
#[test] #[test]
@ -32,7 +32,7 @@ fn test_no_such_directory() {
ucmd.arg("a") ucmd.arg("a")
.fails() .fails()
.stderr_is("chroot: error: cannot change root directory to `a`: no such directory"); .stderr_is("chroot: cannot change root directory to `a`: no such directory");
} }
#[test] #[test]
@ -43,9 +43,7 @@ fn test_invalid_user_spec() {
let result = ucmd.arg("a").arg("--userspec=ARABA:").fails(); let result = ucmd.arg("a").arg("--userspec=ARABA:").fails();
assert!(result assert!(result.stderr_str().starts_with("chroot: invalid userspec"));
.stderr_str()
.starts_with("chroot: error: invalid userspec"));
} }
#[test] #[test]

View file

@ -66,7 +66,7 @@ fn test_invalid_file() {
.arg(folder_name) .arg(folder_name)
.fails() .fails()
.no_stdout() .no_stdout()
.stderr_contains("cksum: error: 'asdf' No such file or directory"); .stderr_contains("cksum: 'asdf' No such file or directory");
// Then check when the file is of an invalid type // Then check when the file is of an invalid type
at.mkdir(folder_name); at.mkdir(folder_name);
@ -74,7 +74,7 @@ fn test_invalid_file() {
.arg(folder_name) .arg(folder_name)
.fails() .fails()
.no_stdout() .no_stdout()
.stderr_contains("cksum: error: 'asdf' Is a directory"); .stderr_contains("cksum: 'asdf' Is a directory");
} }
// Make sure crc is correct for files larger than 32 bytes // Make sure crc is correct for files larger than 32 bytes

View file

@ -208,7 +208,7 @@ fn test_up_to_match_repeat_over() {
ucmd.args(&["numbers50.txt", "/9$/", "{50}"]) ucmd.args(&["numbers50.txt", "/9$/", "{50}"])
.fails() .fails()
.stdout_is("16\n29\n30\n30\n30\n6\n") .stdout_is("16\n29\n30\n30\n30\n6\n")
.stderr_is("csplit: error: '/9$/': match not found on repetition 5"); .stderr_is("csplit: '/9$/': match not found on repetition 5");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -219,7 +219,7 @@ fn test_up_to_match_repeat_over() {
ucmd.args(&["numbers50.txt", "/9$/", "{50}", "-k"]) ucmd.args(&["numbers50.txt", "/9$/", "{50}", "-k"])
.fails() .fails()
.stdout_is("16\n29\n30\n30\n30\n6\n") .stdout_is("16\n29\n30\n30\n30\n6\n")
.stderr_is("csplit: error: '/9$/': match not found on repetition 5"); .stderr_is("csplit: '/9$/': match not found on repetition 5");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -365,7 +365,7 @@ fn test_option_keep() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-k", "numbers50.txt", "/20/", "/nope/"]) ucmd.args(&["-k", "numbers50.txt", "/20/", "/nope/"])
.fails() .fails()
.stderr_is("csplit: error: '/nope/': match not found") .stderr_is("csplit: '/nope/': match not found")
.stdout_is("48\n93\n"); .stdout_is("48\n93\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -541,7 +541,7 @@ fn test_up_to_match_context_overflow() {
ucmd.args(&["numbers50.txt", "/45/+10"]) ucmd.args(&["numbers50.txt", "/45/+10"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/45/+10': line number out of range"); .stderr_is("csplit: '/45/+10': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -552,7 +552,7 @@ fn test_up_to_match_context_overflow() {
ucmd.args(&["numbers50.txt", "/45/+10", "-k"]) ucmd.args(&["numbers50.txt", "/45/+10", "-k"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/45/+10': line number out of range"); .stderr_is("csplit: '/45/+10': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -567,7 +567,7 @@ fn test_skip_to_match_context_underflow() {
ucmd.args(&["numbers50.txt", "%5%-10"]) ucmd.args(&["numbers50.txt", "%5%-10"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '%5%-10': line number out of range"); .stderr_is("csplit: '%5%-10': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -578,7 +578,7 @@ fn test_skip_to_match_context_underflow() {
ucmd.args(&["numbers50.txt", "%5%-10", "-k"]) ucmd.args(&["numbers50.txt", "%5%-10", "-k"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '%5%-10': line number out of range"); .stderr_is("csplit: '%5%-10': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -592,7 +592,7 @@ fn test_skip_to_match_context_overflow() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%45%+10"]) ucmd.args(&["numbers50.txt", "%45%+10"])
.fails() .fails()
.stderr_only("csplit: error: '%45%+10': line number out of range"); .stderr_only("csplit: '%45%+10': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -602,7 +602,7 @@ fn test_skip_to_match_context_overflow() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%45%+10", "-k"]) ucmd.args(&["numbers50.txt", "%45%+10", "-k"])
.fails() .fails()
.stderr_only("csplit: error: '%45%+10': line number out of range"); .stderr_only("csplit: '%45%+10': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -616,7 +616,7 @@ fn test_up_to_no_match1() {
ucmd.args(&["numbers50.txt", "/4/", "/nope/"]) ucmd.args(&["numbers50.txt", "/4/", "/nope/"])
.fails() .fails()
.stdout_is("6\n135\n") .stdout_is("6\n135\n")
.stderr_is("csplit: error: '/nope/': match not found"); .stderr_is("csplit: '/nope/': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -627,7 +627,7 @@ fn test_up_to_no_match1() {
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "-k"]) ucmd.args(&["numbers50.txt", "/4/", "/nope/", "-k"])
.fails() .fails()
.stdout_is("6\n135\n") .stdout_is("6\n135\n")
.stderr_is("csplit: error: '/nope/': match not found"); .stderr_is("csplit: '/nope/': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -643,7 +643,7 @@ fn test_up_to_no_match2() {
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}"]) ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}"])
.fails() .fails()
.stdout_is("6\n135\n") .stdout_is("6\n135\n")
.stderr_is("csplit: error: '/nope/': match not found"); .stderr_is("csplit: '/nope/': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -654,7 +654,7 @@ fn test_up_to_no_match2() {
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}", "-k"]) ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}", "-k"])
.fails() .fails()
.stdout_is("6\n135\n") .stdout_is("6\n135\n")
.stderr_is("csplit: error: '/nope/': match not found"); .stderr_is("csplit: '/nope/': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -670,7 +670,7 @@ fn test_up_to_no_match3() {
ucmd.args(&["numbers50.txt", "/0$/", "{50}"]) ucmd.args(&["numbers50.txt", "/0$/", "{50}"])
.fails() .fails()
.stdout_is("18\n30\n30\n30\n30\n3\n") .stdout_is("18\n30\n30\n30\n30\n3\n")
.stderr_is("csplit: error: '/0$/': match not found on repetition 5"); .stderr_is("csplit: '/0$/': match not found on repetition 5");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -681,7 +681,7 @@ fn test_up_to_no_match3() {
ucmd.args(&["numbers50.txt", "/0$/", "{50}", "-k"]) ucmd.args(&["numbers50.txt", "/0$/", "{50}", "-k"])
.fails() .fails()
.stdout_is("18\n30\n30\n30\n30\n3\n") .stdout_is("18\n30\n30\n30\n30\n3\n")
.stderr_is("csplit: error: '/0$/': match not found on repetition 5"); .stderr_is("csplit: '/0$/': match not found on repetition 5");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -701,7 +701,7 @@ fn test_up_to_no_match4() {
ucmd.args(&["numbers50.txt", "/nope/", "/4/"]) ucmd.args(&["numbers50.txt", "/nope/", "/4/"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/nope/': match not found"); .stderr_is("csplit: '/nope/': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -712,7 +712,7 @@ fn test_up_to_no_match4() {
ucmd.args(&["numbers50.txt", "/nope/", "/4/", "-k"]) ucmd.args(&["numbers50.txt", "/nope/", "/4/", "-k"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/nope/': match not found"); .stderr_is("csplit: '/nope/': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -741,7 +741,7 @@ fn test_up_to_no_match6() {
ucmd.args(&["numbers50.txt", "/nope/-5"]) ucmd.args(&["numbers50.txt", "/nope/-5"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/nope/-5': match not found"); .stderr_is("csplit: '/nope/-5': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -752,7 +752,7 @@ fn test_up_to_no_match6() {
ucmd.args(&["numbers50.txt", "/nope/-5", "-k"]) ucmd.args(&["numbers50.txt", "/nope/-5", "-k"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/nope/-5': match not found"); .stderr_is("csplit: '/nope/-5': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -767,7 +767,7 @@ fn test_up_to_no_match7() {
ucmd.args(&["numbers50.txt", "/nope/+5"]) ucmd.args(&["numbers50.txt", "/nope/+5"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/nope/+5': match not found"); .stderr_is("csplit: '/nope/+5': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -778,7 +778,7 @@ fn test_up_to_no_match7() {
ucmd.args(&["numbers50.txt", "/nope/+5", "-k"]) ucmd.args(&["numbers50.txt", "/nope/+5", "-k"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/nope/+5': match not found"); .stderr_is("csplit: '/nope/+5': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -792,7 +792,7 @@ fn test_skip_to_no_match1() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%"]) ucmd.args(&["numbers50.txt", "%nope%"])
.fails() .fails()
.stderr_only("csplit: error: '%nope%': match not found"); .stderr_only("csplit: '%nope%': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -805,7 +805,7 @@ fn test_skip_to_no_match2() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%", "{50}"]) ucmd.args(&["numbers50.txt", "%nope%", "{50}"])
.fails() .fails()
.stderr_only("csplit: error: '%nope%': match not found"); .stderr_only("csplit: '%nope%': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -818,7 +818,7 @@ fn test_skip_to_no_match3() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%0$%", "{50}"]) ucmd.args(&["numbers50.txt", "%0$%", "{50}"])
.fails() .fails()
.stderr_only("csplit: error: '%0$%': match not found on repetition 5"); .stderr_only("csplit: '%0$%': match not found on repetition 5");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -831,7 +831,7 @@ fn test_skip_to_no_match4() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%", "/4/"]) ucmd.args(&["numbers50.txt", "%nope%", "/4/"])
.fails() .fails()
.stderr_only("csplit: error: '%nope%': match not found"); .stderr_only("csplit: '%nope%': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -858,7 +858,7 @@ fn test_skip_to_no_match6() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%-5"]) ucmd.args(&["numbers50.txt", "%nope%-5"])
.fails() .fails()
.stderr_only("csplit: error: '%nope%-5': match not found"); .stderr_only("csplit: '%nope%-5': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -871,7 +871,7 @@ fn test_skip_to_no_match7() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%+5"]) ucmd.args(&["numbers50.txt", "%nope%+5"])
.fails() .fails()
.stderr_only("csplit: error: '%nope%+5': match not found"); .stderr_only("csplit: '%nope%+5': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -884,7 +884,7 @@ fn test_no_match() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%"]) ucmd.args(&["numbers50.txt", "%nope%"])
.fails() .fails()
.stderr_only("csplit: error: '%nope%': match not found"); .stderr_only("csplit: '%nope%': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -895,7 +895,7 @@ fn test_no_match() {
ucmd.args(&["numbers50.txt", "/nope/"]) ucmd.args(&["numbers50.txt", "/nope/"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '/nope/': match not found"); .stderr_is("csplit: '/nope/': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -992,7 +992,7 @@ fn test_too_small_linenum_repeat() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}"]) ucmd.args(&["numbers50.txt", "/20/", "10", "{*}"])
.fails() .fails()
.stderr_is("csplit: error: '10': line number out of range on repetition 5") .stderr_is("csplit: '10': line number out of range on repetition 5")
.stdout_is("48\n0\n0\n30\n30\n30\n3\n"); .stdout_is("48\n0\n0\n30\n30\n30\n3\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -1003,7 +1003,7 @@ fn test_too_small_linenum_repeat() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}", "-k"]) ucmd.args(&["numbers50.txt", "/20/", "10", "{*}", "-k"])
.fails() .fails()
.stderr_is("csplit: error: '10': line number out of range on repetition 5") .stderr_is("csplit: '10': line number out of range on repetition 5")
.stdout_is("48\n0\n0\n30\n30\n30\n3\n"); .stdout_is("48\n0\n0\n30\n30\n30\n3\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -1025,7 +1025,7 @@ fn test_linenum_out_of_range1() {
ucmd.args(&["numbers50.txt", "100"]) ucmd.args(&["numbers50.txt", "100"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '100': line number out of range"); .stderr_is("csplit: '100': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1036,7 +1036,7 @@ fn test_linenum_out_of_range1() {
ucmd.args(&["numbers50.txt", "100", "-k"]) ucmd.args(&["numbers50.txt", "100", "-k"])
.fails() .fails()
.stdout_is("141\n") .stdout_is("141\n")
.stderr_is("csplit: error: '100': line number out of range"); .stderr_is("csplit: '100': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1051,7 +1051,7 @@ fn test_linenum_out_of_range2() {
ucmd.args(&["numbers50.txt", "10", "100"]) ucmd.args(&["numbers50.txt", "10", "100"])
.fails() .fails()
.stdout_is("18\n123\n") .stdout_is("18\n123\n")
.stderr_is("csplit: error: '100': line number out of range"); .stderr_is("csplit: '100': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1062,7 +1062,7 @@ fn test_linenum_out_of_range2() {
ucmd.args(&["numbers50.txt", "10", "100", "-k"]) ucmd.args(&["numbers50.txt", "10", "100", "-k"])
.fails() .fails()
.stdout_is("18\n123\n") .stdout_is("18\n123\n")
.stderr_is("csplit: error: '100': line number out of range"); .stderr_is("csplit: '100': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1078,7 +1078,7 @@ fn test_linenum_out_of_range3() {
ucmd.args(&["numbers50.txt", "40", "{2}"]) ucmd.args(&["numbers50.txt", "40", "{2}"])
.fails() .fails()
.stdout_is("108\n33\n") .stdout_is("108\n33\n")
.stderr_is("csplit: error: '40': line number out of range on repetition 1"); .stderr_is("csplit: '40': line number out of range on repetition 1");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1089,7 +1089,7 @@ fn test_linenum_out_of_range3() {
ucmd.args(&["numbers50.txt", "40", "{2}", "-k"]) ucmd.args(&["numbers50.txt", "40", "{2}", "-k"])
.fails() .fails()
.stdout_is("108\n33\n") .stdout_is("108\n33\n")
.stderr_is("csplit: error: '40': line number out of range on repetition 1"); .stderr_is("csplit: '40': line number out of range on repetition 1");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1105,7 +1105,7 @@ fn test_linenum_out_of_range4() {
ucmd.args(&["numbers50.txt", "40", "{*}"]) ucmd.args(&["numbers50.txt", "40", "{*}"])
.fails() .fails()
.stdout_is("108\n33\n") .stdout_is("108\n33\n")
.stderr_is("csplit: error: '40': line number out of range on repetition 1"); .stderr_is("csplit: '40': line number out of range on repetition 1");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1116,7 +1116,7 @@ fn test_linenum_out_of_range4() {
ucmd.args(&["numbers50.txt", "40", "{*}", "-k"]) ucmd.args(&["numbers50.txt", "40", "{*}", "-k"])
.fails() .fails()
.stdout_is("108\n33\n") .stdout_is("108\n33\n")
.stderr_is("csplit: error: '40': line number out of range on repetition 1"); .stderr_is("csplit: '40': line number out of range on repetition 1");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1132,7 +1132,7 @@ fn test_skip_to_match_negative_offset_before_a_match() {
ucmd.args(&["numbers50.txt", "/20/-10", "/15/"]) ucmd.args(&["numbers50.txt", "/20/-10", "/15/"])
.fails() .fails()
.stdout_is("18\n123\n") .stdout_is("18\n123\n")
.stderr_is("csplit: error: '/15/': match not found"); .stderr_is("csplit: '/15/': match not found");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created") .expect("there should be splits created")
@ -1177,7 +1177,7 @@ fn test_corner_case2() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/10/-5", "/10/"]) ucmd.args(&["numbers50.txt", "/10/-5", "/10/"])
.fails() .fails()
.stderr_is("csplit: error: '/10/': match not found") .stderr_is("csplit: '/10/': match not found")
.stdout_is("8\n133\n"); .stdout_is("8\n133\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -1191,7 +1191,7 @@ fn test_corner_case3() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/15/-3", "14", "/15/"]) ucmd.args(&["numbers50.txt", "/15/-3", "14", "/15/"])
.fails() .fails()
.stderr_is("csplit: error: '/15/': match not found") .stderr_is("csplit: '/15/': match not found")
.stdout_is("24\n6\n111\n"); .stdout_is("24\n6\n111\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -1223,7 +1223,7 @@ fn test_up_to_match_context_underflow() {
ucmd.args(&["numbers50.txt", "/5/-10"]) ucmd.args(&["numbers50.txt", "/5/-10"])
.fails() .fails()
.stdout_is("0\n141\n") .stdout_is("0\n141\n")
.stderr_is("csplit: error: '/5/-10': line number out of range"); .stderr_is("csplit: '/5/-10': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -1234,7 +1234,7 @@ fn test_up_to_match_context_underflow() {
ucmd.args(&["numbers50.txt", "/5/-10", "-k"]) ucmd.args(&["numbers50.txt", "/5/-10", "-k"])
.fails() .fails()
.stdout_is("0\n141\n") .stdout_is("0\n141\n")
.stderr_is("csplit: error: '/5/-10': line number out of range"); .stderr_is("csplit: '/5/-10': line number out of range");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits") .expect("counting splits")
@ -1251,7 +1251,7 @@ fn test_linenum_range_with_up_to_match1() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-5"]) ucmd.args(&["numbers50.txt", "10", "/12/-5"])
.fails() .fails()
.stderr_is("csplit: error: '/12/-5': line number out of range") .stderr_is("csplit: '/12/-5': line number out of range")
.stdout_is("18\n0\n123\n"); .stdout_is("18\n0\n123\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -1262,7 +1262,7 @@ fn test_linenum_range_with_up_to_match1() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-5", "-k"]) ucmd.args(&["numbers50.txt", "10", "/12/-5", "-k"])
.fails() .fails()
.stderr_is("csplit: error: '/12/-5': line number out of range") .stderr_is("csplit: '/12/-5': line number out of range")
.stdout_is("18\n0\n123\n"); .stdout_is("18\n0\n123\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -1281,7 +1281,7 @@ fn test_linenum_range_with_up_to_match2() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-15"]) ucmd.args(&["numbers50.txt", "10", "/12/-15"])
.fails() .fails()
.stderr_is("csplit: error: '/12/-15': line number out of range") .stderr_is("csplit: '/12/-15': line number out of range")
.stdout_is("18\n0\n123\n"); .stdout_is("18\n0\n123\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -1292,7 +1292,7 @@ fn test_linenum_range_with_up_to_match2() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-15", "-k"]) ucmd.args(&["numbers50.txt", "10", "/12/-15", "-k"])
.fails() .fails()
.stderr_is("csplit: error: '/12/-15': line number out of range") .stderr_is("csplit: '/12/-15': line number out of range")
.stdout_is("18\n0\n123\n"); .stdout_is("18\n0\n123\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))
@ -1310,7 +1310,7 @@ fn test_linenum_range_with_up_to_match3() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/10/", "-k"]) ucmd.args(&["numbers50.txt", "10", "/10/", "-k"])
.fails() .fails()
.stderr_is("csplit: error: '/10/': match not found") .stderr_is("csplit: '/10/': match not found")
.stdout_is("18\n123\n"); .stdout_is("18\n123\n");
let count = glob(&at.plus_as_string("xx*")) let count = glob(&at.plus_as_string("xx*"))

View file

@ -149,11 +149,11 @@ fn test_directory_and_no_such_file() {
ucmd.arg("-b1") ucmd.arg("-b1")
.arg("some") .arg("some")
.run() .run()
.stderr_is("cut: error: some: Is a directory\n"); .stderr_is("cut: some: Is a directory\n");
new_ucmd!() new_ucmd!()
.arg("-b1") .arg("-b1")
.arg("some") .arg("some")
.run() .run()
.stderr_is("cut: error: some: No such file or directory\n"); .stderr_is("cut: some: No such file or directory\n");
} }

View file

@ -76,7 +76,7 @@ fn test_du_basics_bad_name() {
new_ucmd!() new_ucmd!()
.arg("bad_name") .arg("bad_name")
.succeeds() // TODO: replace with ".fails()" once `du` is fixed .succeeds() // TODO: replace with ".fails()" once `du` is fixed
.stderr_only("du: error: bad_name: No such file or directory\n"); .stderr_only("du: bad_name: No such file or directory\n");
} }
#[test] #[test]

View file

@ -17,11 +17,11 @@ fn test_complex_arithmetic() {
.args(&["9223372036854775807", "+", "9223372036854775807"]) .args(&["9223372036854775807", "+", "9223372036854775807"])
.run(); .run();
run.stdout_is(""); run.stdout_is("");
run.stderr_is("expr: error: +: Numerical result out of range"); run.stderr_is("expr: +: Numerical result out of range");
let run = new_ucmd!().args(&["9", "/", "0"]).run(); let run = new_ucmd!().args(&["9", "/", "0"]).run();
run.stdout_is(""); run.stdout_is("");
run.stderr_is("expr: error: division by zero"); run.stderr_is("expr: division by zero");
} }
#[test] #[test]

View file

@ -30,7 +30,7 @@ fn test_fmt_w_too_big() {
//.stdout_is_fixture("call_graph.expected"); //.stdout_is_fixture("call_graph.expected");
assert_eq!( assert_eq!(
result.stderr_str().trim(), result.stderr_str().trim(),
"fmt: error: invalid width: '2501': Numerical result out of range" "fmt: invalid width: '2501': Numerical result out of range"
); );
} }
#[test] #[test]

View file

@ -7,7 +7,7 @@ use crate::common::util::*;
// From the Logs: "Build (ubuntu-18.04, x86_64-unknown-linux-gnu, feat_os_unix, use-cross)" // From the Logs: "Build (ubuntu-18.04, x86_64-unknown-linux-gnu, feat_os_unix, use-cross)"
// stderr: "whoami: cannot find name for user ID 1001" // stderr: "whoami: cannot find name for user ID 1001"
// Maybe: "adduser --uid 1001 username" can put things right? // Maybe: "adduser --uid 1001 username" can put things right?
// stderr = id: error: Could not find uid 1001: No such id: 1001 // stderr = id: Could not find uid 1001: No such id: 1001
fn skipping_test_is_okay(result: &CmdResult, needle: &str) -> bool { fn skipping_test_is_okay(result: &CmdResult, needle: &str) -> bool {
if !result.succeeded() { if !result.succeeded() {
println!("result.stdout = {}", result.stdout_str()); println!("result.stdout = {}", result.stdout_str());

View file

@ -301,7 +301,7 @@ fn test_install_target_new_file_with_group() {
.arg(format!("{}/{}", dir, file)) .arg(format!("{}/{}", dir, file))
.run(); .run();
if is_ci() && result.stderr_str().contains("error: no such group:") { if is_ci() && result.stderr_str().contains("no such group:") {
// In the CI, some server are failing to return the group. // In the CI, some server are failing to return the group.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;
@ -328,7 +328,7 @@ fn test_install_target_new_file_with_owner() {
.arg(format!("{}/{}", dir, file)) .arg(format!("{}/{}", dir, file))
.run(); .run();
if is_ci() && result.stderr_str().contains("error: no such user:") { if is_ci() && result.stderr_str().contains("no such user:") {
// In the CI, some server are failing to return the user id. // In the CI, some server are failing to return the user id.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;

View file

@ -148,7 +148,7 @@ fn multitab_character() {
.arg("-t") .arg("-t")
.arg("э") .arg("э")
.fails() .fails()
.stderr_is("join: error: multi-character tab э"); .stderr_is("join: multi-character tab э");
} }
#[test] #[test]
@ -211,7 +211,7 @@ fn empty_format() {
.arg("-o") .arg("-o")
.arg("") .arg("")
.fails() .fails()
.stderr_is("join: error: invalid file number in field spec: ''"); .stderr_is("join: invalid file number in field spec: ''");
} }
#[test] #[test]

View file

@ -23,7 +23,7 @@ fn test_link_no_circular() {
ucmd.args(&[link, link]) ucmd.args(&[link, link])
.fails() .fails()
.stderr_is("link: error: No such file or directory (os error 2)\n"); .stderr_is("link: No such file or directory (os error 2)\n");
assert!(!at.file_exists(link)); assert!(!at.file_exists(link));
} }
@ -35,7 +35,7 @@ fn test_link_nonexistent_file() {
ucmd.args(&[file, link]) ucmd.args(&[file, link])
.fails() .fails()
.stderr_is("link: error: No such file or directory (os error 2)\n"); .stderr_is("link: No such file or directory (os error 2)\n");
assert!(!at.file_exists(file)); assert!(!at.file_exists(file));
assert!(!at.file_exists(link)); assert!(!at.file_exists(link));
} }

View file

@ -409,7 +409,7 @@ fn test_symlink_missing_destination() {
at.touch(file); at.touch(file);
ucmd.args(&["-s", "-T", file]).fails().stderr_is(format!( ucmd.args(&["-s", "-T", file]).fails().stderr_is(format!(
"ln: error: missing destination file operand after '{}'", "ln: missing destination file operand after '{}'",
file file
)); ));
} }

View file

@ -9,7 +9,7 @@ fn test_normal() {
for (key, value) in env::vars() { for (key, value) in env::vars() {
println!("{}: {}", key, value); println!("{}: {}", key, value);
} }
if (is_ci() || uucore::os::is_wsl_1()) && result.stderr_str().contains("error: no login name") { if (is_ci() || uucore::os::is_wsl_1()) && result.stderr_str().contains("no login name") {
// ToDO: investigate WSL failure // ToDO: investigate WSL failure
// In the CI, some server are failing to return logname. // In the CI, some server are failing to return logname.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it

View file

@ -167,7 +167,7 @@ fn test_ls_width() {
.ucmd() .ucmd()
.args(&option.split(" ").collect::<Vec<_>>()) .args(&option.split(" ").collect::<Vec<_>>())
.fails() .fails()
.stderr_only("ls: error: invalid line width: 1a"); .stderr_only("ls: invalid line width: 1a");
} }
} }
@ -875,7 +875,7 @@ fn test_ls_files_dirs() {
.ucmd() .ucmd()
.arg("doesntexist") .arg("doesntexist")
.fails() .fails()
.stderr_contains(&"error: 'doesntexist': No such file or directory"); .stderr_contains(&"'doesntexist': No such file or directory");
// One exists, the other doesn't // One exists, the other doesn't
scene scene
@ -883,7 +883,7 @@ fn test_ls_files_dirs() {
.arg("a") .arg("a")
.arg("doesntexist") .arg("doesntexist")
.fails() .fails()
.stderr_contains(&"error: 'doesntexist': No such file or directory") .stderr_contains(&"'doesntexist': No such file or directory")
.stdout_contains(&"a:"); .stdout_contains(&"a:");
} }

View file

@ -2,9 +2,7 @@ use crate::common::util::*;
#[test] #[test]
fn test_create_fifo_missing_operand() { fn test_create_fifo_missing_operand() {
new_ucmd!() new_ucmd!().fails().stderr_is("mkfifo: missing operand");
.fails()
.stderr_is("mkfifo: error: missing operand");
} }
#[test] #[test]
@ -43,5 +41,5 @@ fn test_create_one_fifo_already_exists() {
.arg("abcdef") .arg("abcdef")
.arg("abcdef") .arg("abcdef")
.fails() .fails()
.stderr_is("mkfifo: error: cannot create fifo 'abcdef': File exists"); .stderr_is("mkfifo: cannot create fifo 'abcdef': File exists");
} }

View file

@ -120,7 +120,7 @@ fn test_mktemp_mktemp_t() {
.arg(TEST_TEMPLATE8) .arg(TEST_TEMPLATE8)
.fails() .fails()
.no_stdout() .no_stdout()
.stderr_contains("error: suffix cannot contain any path separators"); .stderr_contains("suffix cannot contain any path separators");
} }
#[test] #[test]

View file

@ -472,7 +472,7 @@ fn test_mv_overwrite_nonempty_dir() {
at.touch(dummy); at.touch(dummy);
// Not same error as GNU; the error message is a rust builtin // Not same error as GNU; the error message is a rust builtin
// TODO: test (and implement) correct error message (or at least decide whether to do so) // TODO: test (and implement) correct error message (or at least decide whether to do so)
// Current: "mv: error: couldn't rename path (Directory not empty; from=a; to=b)" // Current: "mv: couldn't rename path (Directory not empty; from=a; to=b)"
// GNU: "mv: cannot move a to b: Directory not empty" // GNU: "mv: cannot move a to b: Directory not empty"
// Verbose output for the move should not be shown on failure // Verbose output for the move should not be shown on failure
@ -539,7 +539,7 @@ fn test_mv_errors() {
.arg(dir) .arg(dir)
.fails() .fails()
.stderr_is(format!( .stderr_is(format!(
"mv: error: cannot overwrite directory {} with non-directory\n", "mv: cannot overwrite directory {} with non-directory\n",
dir dir
)); ));

View file

@ -25,7 +25,7 @@ fn test_adjustment_with_no_command_should_error() {
new_ucmd!() new_ucmd!()
.args(&["-n", "19"]) .args(&["-n", "19"])
.run() .run()
.stderr_is("nice: error: A command must be given with an adjustment.\nTry \"nice --help\" for more information.\n"); .stderr_is("nice: A command must be given with an adjustment.\nTry \"nice --help\" for more information.\n");
} }
#[test] #[test]

View file

@ -258,7 +258,7 @@ fn test_rm_no_operand() {
let mut ucmd = new_ucmd!(); let mut ucmd = new_ucmd!();
ucmd.fails() ucmd.fails()
.stderr_is("rm: error: missing an argument\nrm: error: for help, try 'rm --help'\n"); .stderr_is("rm: missing an argument\nrm: for help, try 'rm --help'\n");
} }
#[test] #[test]

View file

@ -39,7 +39,7 @@ fn test_rmdir_nonempty_directory_no_parents() {
assert!(at.file_exists(file)); assert!(at.file_exists(file));
ucmd.arg(dir).fails().stderr_is( ucmd.arg(dir).fails().stderr_is(
"rmdir: error: failed to remove 'test_rmdir_nonempty_no_parents': Directory not \ "rmdir: failed to remove 'test_rmdir_nonempty_no_parents': Directory not \
empty\n", empty\n",
); );
@ -59,9 +59,9 @@ fn test_rmdir_nonempty_directory_with_parents() {
assert!(at.file_exists(file)); assert!(at.file_exists(file));
ucmd.arg("-p").arg(dir).fails().stderr_is( ucmd.arg("-p").arg(dir).fails().stderr_is(
"rmdir: error: failed to remove 'test_rmdir_nonempty/with/parents': Directory not \ "rmdir: failed to remove 'test_rmdir_nonempty/with/parents': Directory not \
empty\nrmdir: error: failed to remove 'test_rmdir_nonempty/with': Directory not \ empty\nrmdir: failed to remove 'test_rmdir_nonempty/with': Directory not \
empty\nrmdir: error: failed to remove 'test_rmdir_nonempty': Directory not \ empty\nrmdir: failed to remove 'test_rmdir_nonempty': Directory not \
empty\n", empty\n",
); );

View file

@ -42,7 +42,7 @@ fn test_invalid_buffer_size() {
.arg(invalid_buffer_size) .arg(invalid_buffer_size)
.fails() .fails()
.stderr_only(format!( .stderr_only(format!(
"sort: error: failed to parse buffer size `{}`: invalid digit found in string", "sort: failed to parse buffer size `{}`: invalid digit found in string",
invalid_buffer_size invalid_buffer_size
)); ));
} }
@ -471,7 +471,7 @@ fn test_keys_invalid_field() {
new_ucmd!() new_ucmd!()
.args(&["-k", "1."]) .args(&["-k", "1."])
.fails() .fails()
.stderr_only("sort: error: failed to parse character index for key `1.`: cannot parse integer from empty string"); .stderr_only("sort: failed to parse character index for key `1.`: cannot parse integer from empty string");
} }
#[test] #[test]
@ -479,7 +479,7 @@ fn test_keys_invalid_field_option() {
new_ucmd!() new_ucmd!()
.args(&["-k", "1.1x"]) .args(&["-k", "1.1x"])
.fails() .fails()
.stderr_only("sort: error: invalid option for key: `x`"); .stderr_only("sort: invalid option for key: `x`");
} }
#[test] #[test]
@ -487,14 +487,15 @@ fn test_keys_invalid_field_zero() {
new_ucmd!() new_ucmd!()
.args(&["-k", "0.1"]) .args(&["-k", "0.1"])
.fails() .fails()
.stderr_only("sort: error: field index was 0"); .stderr_only("sort: field index was 0");
} }
#[test] #[test]
fn test_keys_invalid_char_zero() { fn test_keys_invalid_char_zero() {
new_ucmd!().args(&["-k", "1.0"]).fails().stderr_only( new_ucmd!()
"sort: error: invalid character index 0 in `1.0` for the start position of a field", .args(&["-k", "1.0"])
); .fails()
.stderr_only("sort: invalid character index 0 in `1.0` for the start position of a field");
} }
#[test] #[test]

View file

@ -49,10 +49,9 @@ fn test_stdbuf_trailing_var_arg() {
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
#[test] #[test]
fn test_stdbuf_line_buffering_stdin_fails() { fn test_stdbuf_line_buffering_stdin_fails() {
new_ucmd!() new_ucmd!().args(&["-i", "L", "head"]).fails().stderr_is(
.args(&["-i", "L", "head"]) "stdbuf: line buffering stdin is meaningless\nTry 'stdbuf --help' for more information.",
.fails() );
.stderr_is("stdbuf: error: line buffering stdin is meaningless\nTry 'stdbuf --help' for more information.");
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
@ -61,5 +60,5 @@ fn test_stdbuf_invalid_mode_fails() {
new_ucmd!() new_ucmd!()
.args(&["-i", "1024R", "head"]) .args(&["-i", "1024R", "head"])
.fails() .fails()
.stderr_is("stdbuf: error: invalid mode 1024R\nTry 'stdbuf --help' for more information."); .stderr_is("stdbuf: invalid mode 1024R\nTry 'stdbuf --help' for more information.");
} }

View file

@ -59,9 +59,7 @@ fn test_invalid_file() {
at.mkdir("a"); at.mkdir("a");
ucmd.arg("a") ucmd.arg("a").fails().stderr_is("sum: 'a' Is a directory");
.fails()
.stderr_is("sum: error: 'a' Is a directory");
} }
#[test] #[test]
@ -70,5 +68,5 @@ fn test_invalid_metadata() {
ucmd.arg("b") ucmd.arg("b")
.fails() .fails()
.stderr_is("sum: error: 'b' No such file or directory"); .stderr_is("sum: 'b' No such file or directory");
} }

View file

@ -37,5 +37,5 @@ fn test_sync_no_existing_files() {
.arg("--data") .arg("--data")
.arg("do-no-exist") .arg("do-no-exist")
.fails() .fails()
.stderr_contains("error: cannot stat"); .stderr_contains("cannot stat");
} }

View file

@ -145,7 +145,7 @@ fn test_invalid_utf8() {
.arg("not-utf8-sequence.txt") .arg("not-utf8-sequence.txt")
.run() .run()
.failure() .failure()
.stderr_only("uniq: error: invalid utf-8 sequence of 1 bytes from index 0"); .stderr_only("uniq: invalid utf-8 sequence of 1 bytes from index 0");
} }
#[test] #[test]

View file

@ -22,7 +22,7 @@ fn test_unlink_multiple_files() {
at.touch(file_b); at.touch(file_b);
ucmd.arg(file_a).arg(file_b).fails().stderr_is( ucmd.arg(file_a).arg(file_b).fails().stderr_is(
"unlink: error: extra operand: 'test_unlink_multiple_file_b'\nTry 'unlink --help' \ "unlink: extra operand: 'test_unlink_multiple_file_b'\nTry 'unlink --help' \
for more information.\n", for more information.\n",
); );
} }
@ -35,7 +35,7 @@ fn test_unlink_directory() {
at.mkdir(dir); at.mkdir(dir);
ucmd.arg(dir).fails().stderr_is( ucmd.arg(dir).fails().stderr_is(
"unlink: error: cannot unlink 'test_unlink_empty_directory': Not a regular file \ "unlink: cannot unlink 'test_unlink_empty_directory': Not a regular file \
or symlink\n", or symlink\n",
); );
} }
@ -45,7 +45,7 @@ fn test_unlink_nonexistent() {
let file = "test_unlink_nonexistent"; let file = "test_unlink_nonexistent";
new_ucmd!().arg(file).fails().stderr_is( new_ucmd!().arg(file).fails().stderr_is(
"unlink: error: Cannot stat 'test_unlink_nonexistent': No such file or directory \ "unlink: Cannot stat 'test_unlink_nonexistent': No such file or directory \
(os error 2)\n", (os error 2)\n",
); );
} }

View file

@ -5,7 +5,7 @@ use crate::common::util::*;
// considered okay. If we are not inside the CI this calls assert!(result.success). // considered okay. If we are not inside the CI this calls assert!(result.success).
// //
// From the Logs: "Build (ubuntu-18.04, x86_64-unknown-linux-gnu, feat_os_unix, use-cross)" // From the Logs: "Build (ubuntu-18.04, x86_64-unknown-linux-gnu, feat_os_unix, use-cross)"
// stderr: "whoami: error: failed to get username" // stderr: "whoami: failed to get username"
// Maybe: "adduser --uid 1001 username" can put things right? // Maybe: "adduser --uid 1001 username" can put things right?
fn skipping_test_is_okay(result: &CmdResult, needle: &str) -> bool { fn skipping_test_is_okay(result: &CmdResult, needle: &str) -> bool {
if !result.succeeded() { if !result.succeeded() {