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

tests/util: Refactor UCommand and TestScenario.

Summary of changes in UCommand:
* Extend UCommand by builder methods and simplify methods in TestScenario
* Simplify code structures where possible. Add documentation.
* Store bin_path as PathBuf and util_name as String in all structs
* Remove UCommand::util and make bin_path, temp_dir private
* Rename UCommand::with_limit -> UCommand::limit

Summary of changes in TestScenario:
* Rename some parameters in TestScenario methods to be more descriptive
* Remove ucmd_keepenv, cmd_keepenv from TestScenario. Use UCommand::keep_env instead.
This commit is contained in:
Joining7943 2023-01-25 03:40:39 +01:00
parent fdf0f96a01
commit 1c230fd779
12 changed files with 276 additions and 185 deletions

View file

@ -1545,7 +1545,7 @@ fn test_closes_file_descriptors() {
.arg("--reflink=auto")
.arg("dir_with_10_files/")
.arg("dir_with_10_files_new/")
.with_limit(Resource::NOFILE, limit_fd, limit_fd)
.limit(Resource::NOFILE, limit_fd, limit_fd)
.succeeds();
}
@ -1692,7 +1692,8 @@ fn test_cp_reflink_always_override() {
.succeeds();
if !scene
.cmd_keepenv("env")
.cmd("env")
.keep_env()
.args(&["mkfs.btrfs", "--rootdir", ROOTDIR, DISK])
.run()
.succeeded()
@ -1704,7 +1705,8 @@ fn test_cp_reflink_always_override() {
scene.fixtures.mkdir(MOUNTPOINT);
let mount = scene
.cmd_keepenv("sudo")
.cmd("sudo")
.keep_env()
.args(&["-E", "--non-interactive", "mount", DISK, MOUNTPOINT])
.run();
@ -1730,7 +1732,8 @@ fn test_cp_reflink_always_override() {
.succeeds();
scene
.cmd_keepenv("sudo")
.cmd("sudo")
.keep_env()
.args(&["-E", "--non-interactive", "umount", MOUNTPOINT])
.succeeds();
}