From a8b75ad2ba2ec04ac9ec0f317f87659e15cb4a78 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 20 Oct 2019 12:25:13 +0200 Subject: [PATCH] Refactor out helper function to simply get stdout of a command Signed-off-by: Matthias Beyer --- tests/ui/src/imag.rs | 2 +- tests/ui/src/imag_ids.rs | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/ui/src/imag.rs b/tests/ui/src/imag.rs index 094a0dfe..3c517ce2 100644 --- a/tests/ui/src/imag.rs +++ b/tests/ui/src/imag.rs @@ -42,7 +42,7 @@ pub fn binary(tempdir: &TempDir, binary_name: &str) -> Command { /// Run the passed command and get the stdout of it. /// /// This function does _not_ ensure that stdin is inherited. -pub fn stdout_of_command(command: Command) -> Vec { +pub fn stdout_of_command(mut command: Command) -> Vec { let assert = command.assert(); let lines = String::from_utf8(assert.get_output().stdout.clone()) .unwrap() diff --git a/tests/ui/src/imag_ids.rs b/tests/ui/src/imag_ids.rs index 2c38906e..f6351eb6 100644 --- a/tests/ui/src/imag_ids.rs +++ b/tests/ui/src/imag_ids.rs @@ -29,15 +29,7 @@ pub fn call(tempdir: &TempDir) -> Vec { // ensure that stdin is not used by the child process binary.stdin(std::process::Stdio::inherit()); - - let assert = binary.assert(); - let lines = String::from_utf8(assert.get_output().stdout.clone()) - .unwrap() - .lines() - .map(String::from) - .collect(); - assert.success(); - lines + crate::imag::stdout_of_command(binary) } pub fn binary(tempdir: &TempDir) -> Command {