1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27: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

@ -396,7 +396,7 @@ fn test_chown_only_user_id() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let result = scene.cmd_keepenv("id").arg("-u").run();
let result = scene.cmd("id").keep_env().arg("-u").run();
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
return;
}
@ -430,7 +430,7 @@ fn test_chown_fail_id() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let result = scene.cmd_keepenv("id").arg("-u").run();
let result = scene.cmd("id").keep_env().arg("-u").run();
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
return;
}
@ -487,7 +487,7 @@ fn test_chown_only_group_id() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let result = scene.cmd_keepenv("id").arg("-g").run();
let result = scene.cmd("id").keep_env().arg("-g").run();
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
return;
}
@ -551,14 +551,14 @@ fn test_chown_owner_group_id() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let result = scene.cmd_keepenv("id").arg("-u").run();
let result = scene.cmd("id").keep_env().arg("-u").run();
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
return;
}
let user_id = String::from(result.stdout_str().trim());
assert!(!user_id.is_empty());
let result = scene.cmd_keepenv("id").arg("-g").run();
let result = scene.cmd("id").keep_env().arg("-g").run();
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
return;
}
@ -612,14 +612,14 @@ fn test_chown_owner_group_mix() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let result = scene.cmd_keepenv("id").arg("-u").run();
let result = scene.cmd("id").keep_env().arg("-u").run();
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
return;
}
let user_id = String::from(result.stdout_str().trim());
assert!(!user_id.is_empty());
let result = scene.cmd_keepenv("id").arg("-gn").run();
let result = scene.cmd("id").keep_env().arg("-gn").run();
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
return;
}