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

Make CmdResult::code private

This commit is contained in:
Gilad Naaman 2021-04-17 16:48:23 +03:00
parent 600bab52ff
commit c5d7f63b3c
3 changed files with 16 additions and 12 deletions

View file

@ -1029,7 +1029,7 @@ fn test_cp_one_file_system() {
at_src.mkdir(TEST_MOUNT_MOUNTPOINT); at_src.mkdir(TEST_MOUNT_MOUNTPOINT);
let mountpoint_path = &at_src.plus_as_string(TEST_MOUNT_MOUNTPOINT); let mountpoint_path = &at_src.plus_as_string(TEST_MOUNT_MOUNTPOINT);
let _r = scene scene
.cmd("mount") .cmd("mount")
.arg("-t") .arg("-t")
.arg("tmpfs") .arg("tmpfs")
@ -1037,8 +1037,7 @@ fn test_cp_one_file_system() {
.arg("size=640k") // ought to be enough .arg("size=640k") // ought to be enough
.arg("tmpfs") .arg("tmpfs")
.arg(mountpoint_path) .arg(mountpoint_path)
.run(); .succeeds();
assert!(_r.code == Some(0), "{}", _r.stderr);
at_src.touch(TEST_MOUNT_OTHER_FILESYSTEM_FILE); at_src.touch(TEST_MOUNT_OTHER_FILESYSTEM_FILE);
@ -1051,8 +1050,7 @@ fn test_cp_one_file_system() {
.run(); .run();
// Ditch the mount before the asserts // Ditch the mount before the asserts
let _r = scene.cmd("umount").arg(mountpoint_path).run(); scene.cmd("umount").arg(mountpoint_path).succeeds();
assert!(_r.code == Some(0), "{}", _r.stderr);
assert!(result.success); assert!(result.success);
assert!(!at_dst.file_exists(TEST_MOUNT_OTHER_FILESYSTEM_FILE)); assert!(!at_dst.file_exists(TEST_MOUNT_OTHER_FILESYSTEM_FILE));

View file

@ -443,9 +443,12 @@ fn test_install_failing_omitting_directory() {
at.mkdir(dir2); at.mkdir(dir2);
at.touch(file1); at.touch(file1);
let r = ucmd.arg(dir1).arg(file1).arg(dir2).run(); ucmd.arg(dir1)
assert!(r.code == Some(1)); .arg(file1)
assert!(r.stderr.contains("omitting directory")); .arg(dir2)
.fails()
.code_is(1)
.stderr_contains("omitting directory");
} }
#[test] #[test]
@ -458,9 +461,12 @@ fn test_install_failing_no_such_file() {
at.mkdir(dir1); at.mkdir(dir1);
at.touch(file1); at.touch(file1);
let r = ucmd.arg(file1).arg(file2).arg(dir1).run(); ucmd.arg(file1)
assert!(r.code == Some(1)); .arg(file2)
assert!(r.stderr.contains("No such file or directory")); .arg(dir1)
.fails()
.code_is(1)
.stderr_contains("No such file or directory");
} }
#[test] #[test]

View file

@ -71,7 +71,7 @@ pub struct CmdResult {
//tmpd is used for convenience functions for asserts against fixtures //tmpd is used for convenience functions for asserts against fixtures
tmpd: Option<Rc<TempDir>>, tmpd: Option<Rc<TempDir>>,
/// exit status for command (if there is one) /// exit status for command (if there is one)
pub code: Option<i32>, code: Option<i32>,
/// zero-exit from running the Command? /// zero-exit from running the Command?
/// see [`success`] /// see [`success`]
pub success: bool, pub success: bool,