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

tests/util: Restructure UCommand to run in shell per default. Introduce constant TESTS_BINARY.

Summary of changes in tests/util:

* Introduce global constant TESTS_BINARY holding the path to `coreutils`
* Implement running an arbitrary command in a sh or cmd shell per default.
* Implement std::fmt::Display for UCommand.
* Change usages of UCommand::util_name from &Option<OsStr> to Option<OsStr>
* `UCommand::new_from_tmp`: Use OsStr directly instead of TempDir -> String -> OsStr
* Collect arguments in `UCommand::args` field
* Build environment variables in `UCommand` itself instead of `std::process::Command`
* Move building of std::process:Command from fields in UCommand to own method `build`
* Remove assertions of UCommand::has_run in arg, args and env.

Summary of changes in tests/by-util:

* Remove usages of UCommand::raw. Fix tests to use UCommand::to_string.
* test_test: Adjust test_invalid_utf8_integer_compare to use `UCommand::args`
* test_chmod: run_single_test
* test_pwd: symlinked_env
* test_cp:
    Fix the usage of &Option<OsStr> in `test_src_base_dot`
    Refactor test_src_base_dot to not use UCommand::new but ts.ucmd() instead
This commit is contained in:
Joining7943 2023-01-22 17:46:25 +01:00
parent 2b5b0c82c1
commit fdf0f96a01
5 changed files with 178 additions and 111 deletions

View file

@ -300,19 +300,15 @@ fn test_invalid_utf8_integer_compare() {
let source = [0x66, 0x6f, 0x80, 0x6f];
let arg = OsStr::from_bytes(&source[..]);
let mut cmd = new_ucmd!();
cmd.arg("123").arg("-ne");
cmd.raw.arg(arg);
cmd.run()
new_ucmd!()
.args(&[OsStr::new("123"), OsStr::new("-ne"), arg])
.run()
.code_is(2)
.stderr_is("test: invalid integer $'fo\\x80o'\n");
let mut cmd = new_ucmd!();
cmd.raw.arg(arg);
cmd.arg("-eq").arg("456");
cmd.run()
new_ucmd!()
.args(&[arg, OsStr::new("-eq"), OsStr::new("456")])
.run()
.code_is(2)
.stderr_is("test: invalid integer $'fo\\x80o'\n");
}