mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 14:07:46 +00:00
Refactor method to auto-convert into byte array.
When creating tests, we could pass a String, &str, or [u8] to the standard input. Previously, all arguments had to be manually converted to a reference to a [u8]. This update makes it more ergonomic.
This commit is contained in:
parent
505060107c
commit
62b9dc0326
1 changed files with 2 additions and 2 deletions
|
@ -30,7 +30,7 @@ pub fn run(cmd: &mut Command) -> CmdResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_piped_stdin(cmd: &mut Command, input: &[u8])-> CmdResult {
|
pub fn run_piped_stdin<T: AsRef<[u8]>>(cmd: &mut Command, input: T)-> CmdResult {
|
||||||
let mut command = cmd
|
let mut command = cmd
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
@ -41,7 +41,7 @@ pub fn run_piped_stdin(cmd: &mut Command, input: &[u8])-> CmdResult {
|
||||||
command.stdin
|
command.stdin
|
||||||
.take()
|
.take()
|
||||||
.unwrap_or_else(|| panic!("Could not take child process stdin"))
|
.unwrap_or_else(|| panic!("Could not take child process stdin"))
|
||||||
.write_all(input)
|
.write_all(input.as_ref())
|
||||||
.unwrap_or_else(|e| panic!("{}", e));
|
.unwrap_or_else(|e| panic!("{}", e));
|
||||||
|
|
||||||
let prog = command.wait_with_output().unwrap();
|
let prog = command.wait_with_output().unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue