diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 07880d5c0..f4aabff3e 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1029,7 +1029,7 @@ fn test_cp_one_file_system() { at_src.mkdir(TEST_MOUNT_MOUNTPOINT); let mountpoint_path = &at_src.plus_as_string(TEST_MOUNT_MOUNTPOINT); - let _r = scene + scene .cmd("mount") .arg("-t") .arg("tmpfs") @@ -1037,8 +1037,7 @@ fn test_cp_one_file_system() { .arg("size=640k") // ought to be enough .arg("tmpfs") .arg(mountpoint_path) - .run(); - assert!(_r.code == Some(0), "{}", _r.stderr); + .succeeds(); at_src.touch(TEST_MOUNT_OTHER_FILESYSTEM_FILE); @@ -1051,8 +1050,7 @@ fn test_cp_one_file_system() { .run(); // Ditch the mount before the asserts - let _r = scene.cmd("umount").arg(mountpoint_path).run(); - assert!(_r.code == Some(0), "{}", _r.stderr); + scene.cmd("umount").arg(mountpoint_path).succeeds(); assert!(result.success); assert!(!at_dst.file_exists(TEST_MOUNT_OTHER_FILESYSTEM_FILE)); diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index 32df8d460..dfaaabce6 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -443,9 +443,12 @@ fn test_install_failing_omitting_directory() { at.mkdir(dir2); at.touch(file1); - let r = ucmd.arg(dir1).arg(file1).arg(dir2).run(); - assert!(r.code == Some(1)); - assert!(r.stderr.contains("omitting directory")); + ucmd.arg(dir1) + .arg(file1) + .arg(dir2) + .fails() + .code_is(1) + .stderr_contains("omitting directory"); } #[test] @@ -458,9 +461,12 @@ fn test_install_failing_no_such_file() { at.mkdir(dir1); at.touch(file1); - let r = ucmd.arg(file1).arg(file2).arg(dir1).run(); - assert!(r.code == Some(1)); - assert!(r.stderr.contains("No such file or directory")); + ucmd.arg(file1) + .arg(file2) + .arg(dir1) + .fails() + .code_is(1) + .stderr_contains("No such file or directory"); } #[test] diff --git a/tests/common/util.rs b/tests/common/util.rs index b54c8ee39..55e121737 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -71,7 +71,7 @@ pub struct CmdResult { //tmpd is used for convenience functions for asserts against fixtures tmpd: Option>, /// exit status for command (if there is one) - pub code: Option, + code: Option, /// zero-exit from running the Command? /// see [`success`] pub success: bool,