mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tests: Simplify logic of UCommand::run.
This commit is contained in:
parent
b3b8a1ea54
commit
fe5bc47971
1 changed files with 17 additions and 21 deletions
|
@ -486,29 +486,25 @@ impl UCommand {
|
|||
}
|
||||
self.has_run = true;
|
||||
log_info("run", &self.comm_string);
|
||||
let prog = match self.stdin {
|
||||
Some(ref input) => {
|
||||
let mut result = self.raw
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap();
|
||||
let mut result = self.raw
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
result.stdin
|
||||
.take()
|
||||
.unwrap_or_else(
|
||||
|| panic!(
|
||||
"Could not take child process stdin"))
|
||||
.write_all(&input)
|
||||
.unwrap_or_else(|e| panic!("{}", e));
|
||||
if let Some(ref input) = self.stdin {
|
||||
result.stdin
|
||||
.take()
|
||||
.unwrap_or_else(
|
||||
|| panic!(
|
||||
"Could not take child process stdin"))
|
||||
.write_all(&input)
|
||||
.unwrap_or_else(|e| panic!("{}", e));
|
||||
}
|
||||
|
||||
let prog = result.wait_with_output().unwrap();
|
||||
|
||||
result.wait_with_output().unwrap()
|
||||
}
|
||||
None => {
|
||||
self.raw.output().unwrap()
|
||||
}
|
||||
};
|
||||
CmdResult {
|
||||
success: prog.status.success(),
|
||||
stdout: from_utf8(&prog.stdout).unwrap().to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue