From b9a0cbecf5ed7f2ed3b5515bd9d24576da558998 Mon Sep 17 00:00:00 2001 From: Alex Chi Date: Tue, 29 Mar 2022 15:18:07 +0800 Subject: [PATCH] fix: return code should be non-zero if test case failed (#33) Signed-off-by: Alex Chi --- Cargo.toml | 2 +- src/main.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3a8b3fd..1bbf83e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqllogictest" -version = "0.3.1" +version = "0.3.2" edition = "2021" description = "Sqllogictest parser and runner." license = "MIT OR Apache-2.0" diff --git a/src/main.rs b/src/main.rs index 230ffd8..5e09aa2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,15 +71,25 @@ async fn main() -> Result<()> { engine_name: opt.engine, }; + let mut has_failed = false; + + let mut failed_case = vec![]; + for file in files { let file = file?; if let Err(e) = run_test_file(pg.clone(), &file).await { println!("{}\n\n{:?}", style("[FAILED]").red().bold(), e); println!(); + has_failed = true; + failed_case.push(file.to_string_lossy().to_string()); } } - Ok(()) + if has_failed { + Err(anyhow!("some test case failed:\n{:#?}", failed_case)) + } else { + Ok(()) + } } async fn flush_stdout() -> std::io::Result<()> {