From 8373e94dff4ba8cc33123c8e278812745225aca5 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Mon, 21 Oct 2024 14:17:02 -0400 Subject: [PATCH 1/4] Allow using `cargo nextest` for running tests --- datafusion/sqllogictest/bin/sqllogictests.rs | 25 ++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/datafusion/sqllogictest/bin/sqllogictests.rs b/datafusion/sqllogictest/bin/sqllogictests.rs index baa49057e1b9..19335053559f 100644 --- a/datafusion/sqllogictest/bin/sqllogictests.rs +++ b/datafusion/sqllogictest/bin/sqllogictests.rs @@ -62,6 +62,11 @@ async fn run_tests() -> Result<()> { env_logger::init(); let options: Options = clap::Parser::parse(); + // nextest parses stdout + if options.list { + eprintln!("NOTICE: --list option unsupported quitting"); + return Ok(()); + } options.warn_on_ignored(); // Run all tests in parallel, reporting failures at the end @@ -276,7 +281,7 @@ fn read_dir_recursive_impl(dst: &mut Vec, path: &Path) -> Result<()> { /// Parsed command line options /// -/// This structure attempts to mimic the command line options +/// This structure attempts to mimic the command line options of the built in rust test runner /// accepted by IDEs such as CLion that pass arguments /// /// See for more details @@ -320,6 +325,18 @@ struct Options { help = "IGNORED (for compatibility with built in rust test runner)" )] show_output: bool, + + #[clap( + long, + help = "Quits immediately, not listing anything (for compatibility with built in rust test runner)" + )] + list: bool, + + #[clap( + long, + help = "IGNORED (for compatibility with built in rust test runner)" + )] + ignored: bool, } impl Options { @@ -354,15 +371,15 @@ impl Options { /// Logs warning messages to stdout if any ignored options are passed fn warn_on_ignored(&self) { if self.format.is_some() { - println!("WARNING: Ignoring `--format` compatibility option"); + eprintln!("WARNING: Ignoring `--format` compatibility option"); } if self.z_options.is_some() { - println!("WARNING: Ignoring `-Z` compatibility option"); + eprintln!("WARNING: Ignoring `-Z` compatibility option"); } if self.show_output { - println!("WARNING: Ignoring `--show-output` compatibility option"); + eprintln!("WARNING: Ignoring `--show-output` compatibility option"); } } } From ebb1ceaaee9d0e034285c07db171656bbe3858fc Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Tue, 22 Oct 2024 11:23:58 -0400 Subject: [PATCH 2/4] Update datafusion/sqllogictest/bin/sqllogictests.rs Co-authored-by: Piotr Findeisen --- datafusion/sqllogictest/bin/sqllogictests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datafusion/sqllogictest/bin/sqllogictests.rs b/datafusion/sqllogictest/bin/sqllogictests.rs index 19335053559f..2c0d41c70009 100644 --- a/datafusion/sqllogictest/bin/sqllogictests.rs +++ b/datafusion/sqllogictest/bin/sqllogictests.rs @@ -64,7 +64,7 @@ async fn run_tests() -> Result<()> { let options: Options = clap::Parser::parse(); // nextest parses stdout if options.list { - eprintln!("NOTICE: --list option unsupported quitting"); + eprintln!("NOTICE: --list option unsupported, quitting"); return Ok(()); } options.warn_on_ignored(); From fd1552366ba6d6c87113dda983622cb8d9c34264 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Tue, 22 Oct 2024 14:14:14 -0400 Subject: [PATCH 3/4] Clarify rationale for returning OK --- datafusion/sqllogictest/bin/sqllogictests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/datafusion/sqllogictest/bin/sqllogictests.rs b/datafusion/sqllogictest/bin/sqllogictests.rs index 2c0d41c70009..2863b2ffe804 100644 --- a/datafusion/sqllogictest/bin/sqllogictests.rs +++ b/datafusion/sqllogictest/bin/sqllogictests.rs @@ -62,9 +62,13 @@ async fn run_tests() -> Result<()> { env_logger::init(); let options: Options = clap::Parser::parse(); - // nextest parses stdout if options.list { + // nextest parses stdout, so print messages to stderr eprintln!("NOTICE: --list option unsupported, quitting"); + // return Ok, not error so that tools like nextest which are listing all + // workspace tests (by running `cargo test ... --list --format terse`) + // do not fail when they encounter this binary. Instead, print nothing + // to stdout and return OK so they can continue listing other tests. return Ok(()); } options.warn_on_ignored(); From ef159e35b435ab4e613d97110073011443ec0637 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 25 Oct 2024 09:23:30 -0400 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Piotr Findeisen --- datafusion/sqllogictest/bin/sqllogictests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datafusion/sqllogictest/bin/sqllogictests.rs b/datafusion/sqllogictest/bin/sqllogictests.rs index 2863b2ffe804..501fd3517a17 100644 --- a/datafusion/sqllogictest/bin/sqllogictests.rs +++ b/datafusion/sqllogictest/bin/sqllogictests.rs @@ -332,13 +332,13 @@ struct Options { #[clap( long, - help = "Quits immediately, not listing anything (for compatibility with built in rust test runner)" + help = "Quits immediately, not listing anything (for compatibility with built-in rust test runner)" )] list: bool, #[clap( long, - help = "IGNORED (for compatibility with built in rust test runner)" + help = "IGNORED (for compatibility with built-in rust test runner)" )] ignored: bool, }