mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 19:56:17 +00:00
remove needless pass by value
This commit is contained in:
parent
f4c6ea0ee8
commit
a2d5f06be4
55 changed files with 332 additions and 331 deletions
|
@ -92,9 +92,9 @@ fn test_zero_param() {
|
|||
}
|
||||
}
|
||||
|
||||
fn expect_error(input: Vec<&str>) {
|
||||
fn expect_error(input: &[&str]) {
|
||||
assert!(!new_ucmd!()
|
||||
.args(&input)
|
||||
.args(input)
|
||||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_str()
|
||||
|
@ -104,12 +104,12 @@ fn expect_error(input: Vec<&str>) {
|
|||
#[test]
|
||||
fn test_invalid_option() {
|
||||
let path = "/foo/bar/baz";
|
||||
expect_error(vec!["-q", path]);
|
||||
expect_error(&["-q", path]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_args() {
|
||||
expect_error(vec![]);
|
||||
expect_error(&[]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -119,7 +119,7 @@ fn test_no_args_output() {
|
|||
|
||||
#[test]
|
||||
fn test_too_many_args() {
|
||||
expect_error(vec!["a", "b", "c"]);
|
||||
expect_error(&["a", "b", "c"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -33,7 +33,7 @@ fn make_file(file: &str, mode: u32) {
|
|||
set_permissions(file, perms).unwrap();
|
||||
}
|
||||
|
||||
fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) {
|
||||
fn run_single_test(test: &TestCase, at: &AtPath, mut ucmd: UCommand) {
|
||||
make_file(&at.plus_as_string(TEST_FILE), test.before);
|
||||
let perms = at.metadata(TEST_FILE).permissions().mode();
|
||||
if perms != test.before {
|
||||
|
@ -64,7 +64,7 @@ fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) {
|
|||
fn run_tests(tests: Vec<TestCase>) {
|
||||
for test in tests {
|
||||
let (at, ucmd) = at_and_ucmd!();
|
||||
run_single_test(&test, at, ucmd);
|
||||
run_single_test(&test, &at, ucmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ fn test_chmod_reference_file() {
|
|||
];
|
||||
let (at, ucmd) = at_and_ucmd!();
|
||||
make_file(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS);
|
||||
run_single_test(&tests[0], at, ucmd);
|
||||
run_single_test(&tests[0], &at, ucmd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -553,7 +553,7 @@ fn test_mode_after_dash_dash() {
|
|||
before: 0o100777,
|
||||
after: 0o100333,
|
||||
},
|
||||
at,
|
||||
&at,
|
||||
ucmd,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ impl CmdResult {
|
|||
}
|
||||
|
||||
/// like `stdout_is`, but succeeds if any elements of `expected` matches stdout.
|
||||
pub fn stdout_is_any<T: AsRef<str> + std::fmt::Debug>(&self, expected: Vec<T>) -> &CmdResult {
|
||||
pub fn stdout_is_any<T: AsRef<str> + std::fmt::Debug>(&self, expected: &[T]) -> &CmdResult {
|
||||
if !expected.iter().any(|msg| self.stdout_str() == msg.as_ref()) {
|
||||
panic!(
|
||||
"stdout was {}\nExpected any of {:#?}",
|
||||
|
@ -294,7 +294,7 @@ impl CmdResult {
|
|||
}
|
||||
contents
|
||||
});
|
||||
self.stdout_is_any(possible_values.collect());
|
||||
self.stdout_is_any(&possible_values.collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
/// asserts that the command resulted in stderr stream output that equals the
|
||||
|
@ -816,13 +816,13 @@ impl TestScenario {
|
|||
util_name: T,
|
||||
env_clear: bool,
|
||||
) -> UCommand {
|
||||
UCommand::new_from_tmp(bin, Some(util_name), self.tmpd.clone(), env_clear)
|
||||
UCommand::new_from_tmp(bin, &Some(util_name), self.tmpd.clone(), env_clear)
|
||||
}
|
||||
|
||||
/// Returns builder for invoking any system command. Paths given are treated
|
||||
/// relative to the environment's unique temporary test directory.
|
||||
pub fn cmd<S: AsRef<OsStr>>(&self, bin: S) -> UCommand {
|
||||
UCommand::new_from_tmp::<S, S>(bin, None, self.tmpd.clone(), true)
|
||||
UCommand::new_from_tmp::<S, S>(bin, &None, self.tmpd.clone(), true)
|
||||
}
|
||||
|
||||
/// Returns builder for invoking any uutils command. Paths given are treated
|
||||
|
@ -842,7 +842,7 @@ impl TestScenario {
|
|||
/// Differs from the builder returned by `cmd` in that `cmd_keepenv` does not call
|
||||
/// `Command::env_clear` (Clears the entire environment map for the child process.)
|
||||
pub fn cmd_keepenv<S: AsRef<OsStr>>(&self, bin: S) -> UCommand {
|
||||
UCommand::new_from_tmp::<S, S>(bin, None, self.tmpd.clone(), false)
|
||||
UCommand::new_from_tmp::<S, S>(bin, &None, self.tmpd.clone(), false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -872,7 +872,7 @@ pub struct UCommand {
|
|||
impl UCommand {
|
||||
pub fn new<T: AsRef<OsStr>, S: AsRef<OsStr>, U: AsRef<OsStr>>(
|
||||
bin_path: T,
|
||||
util_name: Option<S>,
|
||||
util_name: &Option<S>,
|
||||
curdir: U,
|
||||
env_clear: bool,
|
||||
) -> UCommand {
|
||||
|
@ -924,7 +924,7 @@ impl UCommand {
|
|||
|
||||
pub fn new_from_tmp<T: AsRef<OsStr>, S: AsRef<OsStr>>(
|
||||
bin_path: T,
|
||||
util_name: Option<S>,
|
||||
util_name: &Option<S>,
|
||||
tmpd: Rc<TempDir>,
|
||||
env_clear: bool,
|
||||
) -> UCommand {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue