From 79369d73bb8e116314b528c632046605b152e28f Mon Sep 17 00:00:00 2001 From: Georgy Moshkin <gmoshkin@picodata.io> Date: Tue, 20 Sep 2022 14:42:41 +0300 Subject: [PATCH] test: picodata test --nocapture & PICODATA_TEST_* variables --- src/args.rs | 6 +++++- src/main.rs | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/args.rs b/src/args.rs index 09d301dde0..0d9469215d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -229,9 +229,13 @@ impl Expel { #[derive(Debug, Parser, tlua::Push)] #[clap(about = "Run picodata integration tests")] pub struct Test { - #[clap()] + #[clap(env = "PICODATA_TEST_FILTER")] /// Only run tests matching the filter. pub filter: Option<String>, + + #[clap(long = "nocapture", env = "PICODATA_TEST_NOCAPTURE")] + /// Do not capture test output. + pub nocapture: bool, } impl Test { diff --git a/src/main.rs b/src/main.rs index 3c45ee7825..84c3a0511d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -942,8 +942,10 @@ fn main_test(args: args::Test) -> ! { ForkResult::Child => { drop(rx); unistd::close(0).ok(); // stdin - unistd::dup2(*tx, 1).ok(); // stdout - unistd::dup2(*tx, 2).ok(); // stderr + if !args.nocapture { + unistd::dup2(*tx, 1).ok(); // stdout + unistd::dup2(*tx, 2).ok(); // stderr + } drop(tx); let rc = tarantool_main!( @@ -959,9 +961,11 @@ fn main_test(args: args::Test) -> ! { let log = { let mut buf = Vec::new(); use std::io::Read; - rx.read_to_end(&mut buf) - .map_err(|e| println!("error reading ipc pipe: {e}")) - .ok(); + if !args.nocapture { + rx.read_to_end(&mut buf) + .map_err(|e| println!("error reading ipc pipe: {e}")) + .ok(); + } buf }; @@ -981,6 +985,10 @@ fn main_test(args: args::Test) -> ! { println!("{FAILED}"); cnt_failed += 1; + if args.nocapture { + continue; + } + use std::io::Write; println!(); std::io::stderr() -- GitLab