From 559b70cf0a2ce3baa9a507db804cc67987a4a8cf Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 27 Feb 2020 11:56:10 +0000 Subject: [PATCH] tests: Make output capture optional Only some tests require the output for the tests to be captured so default to not capturing the output to a pipe and instead make it controllable. Signed-off-by: Rob Bradford --- tests/integration.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 14fd95d7c..cf7806fc9 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -716,6 +716,7 @@ mod tests { struct GuestCommand<'a> { command: Command, guest: &'a Guest<'a>, + capture_output: bool, } impl<'a> GuestCommand<'a> { @@ -723,14 +724,24 @@ mod tests { Self { command: Command::new("target/release/cloud-hypervisor"), guest, + capture_output: false, } } + fn capture_output(&mut self) -> &mut Self { + self.capture_output = true; + self + } + fn spawn(&mut self) -> io::Result { - self.command - .stderr(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() + if self.capture_output { + self.command + .stderr(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + } else { + self.command.spawn() + } } fn args(&mut self, args: I) -> &mut Self @@ -1991,6 +2002,7 @@ mod tests { .default_net() .args(&["--serial", "null"]) .args(&["--console", "off"]) + .capture_output() .spawn() .unwrap(); @@ -2038,6 +2050,7 @@ mod tests { .default_net() .args(&["--serial", "tty"]) .args(&["--console", "off"]) + .capture_output() .spawn() .unwrap(); @@ -2137,6 +2150,7 @@ mod tests { .default_disks() .default_net() .args(&["--console", "tty"]) + .capture_output() .spawn() .unwrap();