Skip to content

Commit 940272e

Browse files
def-patrickwwbutler
authored andcommitted
SLT: Print errors by default, introduce -q (MaterializeInc#35081)
You can either set -v or -q to make it less or more verbose. I prefer the default of printing where an error happened, would have saved me a bunch of rountrips of having to rerun with `-v`
1 parent 7a265e7 commit 940272e

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/sqllogictest/src/bin/sqllogictest.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ use walkdir::WalkDir;
3232
/// Runs sqllogictest scripts to verify database engine correctness.
3333
#[derive(clap::Parser)]
3434
struct Args {
35-
/// Increase verbosity.
36-
///
37-
/// If specified once, print summary for each source file.
38-
/// If specified twice, also show descriptions of each error.
39-
/// If specified thrice, also print each query before it is executed.
40-
#[clap(short = 'v', long = "verbose", action = ArgAction::Count)]
41-
verbosity: u8,
35+
/// By default, prints summary for each source file and shows descriptions of each error.
36+
/// If specified, also print each query before it is executed.
37+
#[clap(short = 'v', long = "verbose", action = ArgAction::SetTrue, conflicts_with = "quiet")]
38+
verbose: bool,
39+
/// Suppress summary output unless a file has failures.
40+
#[clap(short = 'q', long = "quiet", action = ArgAction::SetTrue, conflicts_with = "verbose")]
41+
quiet: bool,
4242
/// Don't exit with a failing code if not all queries are successful.
4343
#[clap(long)]
4444
no_fail: bool,
@@ -170,7 +170,8 @@ async fn main() -> ExitCode {
170170
let config = RunConfig {
171171
stdout: &OutputStream::new(io::stdout(), args.timestamps),
172172
stderr: &OutputStream::new(io::stderr(), args.timestamps),
173-
verbosity: args.verbosity,
173+
verbose: args.verbose,
174+
quiet: args.quiet,
174175
postgres_url: args.postgres_url.clone(),
175176
prefix: args.prefix.clone(),
176177
no_fail: args.no_fail,
@@ -230,7 +231,7 @@ async fn main() -> ExitCode {
230231
let start_time = Instant::now();
231232
match runner::run_file(&mut runner, entry.path()).await {
232233
Ok(o) => {
233-
if o.any_failed() || config.verbosity >= 1 {
234+
if o.any_failed() || !config.quiet {
234235
writeln!(
235236
config.stdout,
236237
"{}",

src/sqllogictest/src/runner.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ pub struct RunnerInner<'a> {
443443
auto_index_selects: bool,
444444
auto_transactions: bool,
445445
enable_table_keys: bool,
446-
verbosity: u8,
446+
verbose: bool,
447447
stdout: &'a dyn WriteFmt,
448448
_shutdown_trigger: trigger::Trigger,
449449
_server_thread: JoinOnDropHandle<()>,
@@ -1307,7 +1307,7 @@ impl<'a> RunnerInner<'a> {
13071307
auto_index_selects: config.auto_index_selects,
13081308
auto_transactions: config.auto_transactions,
13091309
enable_table_keys: config.enable_table_keys,
1310-
verbosity: config.verbosity,
1310+
verbose: config.verbose,
13111311
stdout: config.stdout,
13121312
};
13131313
inner.ensure_fixed_features().await?;
@@ -1696,7 +1696,7 @@ impl<'a> RunnerInner<'a> {
16961696
output: &'r Result<QueryOutput<'_>, &'r str>,
16971697
location: Location,
16981698
) -> Result<Option<Outcome<'r>>, anyhow::Error> {
1699-
print_sql_if(self.stdout, sql, self.verbosity >= 2);
1699+
print_sql_if(self.stdout, sql, self.verbose);
17001700
let sql_result = self.client.execute(sql, &[]).await;
17011701

17021702
// Evaluate if we already reached an outcome or not.
@@ -1763,14 +1763,14 @@ impl<'a> RunnerInner<'a> {
17631763
if let Some(outcome) = tentative_outcome {
17641764
view_outcome = outcome;
17651765
} else {
1766-
print_sql_if(self.stdout, view_sql.as_str(), self.verbosity >= 2);
1766+
print_sql_if(self.stdout, view_sql.as_str(), self.verbose);
17671767
view_outcome = self
17681768
.execute_query(view_sql.as_str(), output, location.clone())
17691769
.await?;
17701770
}
17711771

17721772
// Remember to clean up after ourselves by dropping the view.
1773-
print_sql_if(self.stdout, drop_view.as_str(), self.verbosity >= 2);
1773+
print_sql_if(self.stdout, drop_view.as_str(), self.verbose);
17741774
self.client.execute(drop_view.as_str(), &[]).await?;
17751775

17761776
Ok(view_outcome)
@@ -1986,7 +1986,8 @@ pub trait WriteFmt {
19861986
pub struct RunConfig<'a> {
19871987
pub stdout: &'a dyn WriteFmt,
19881988
pub stderr: &'a dyn WriteFmt,
1989-
pub verbosity: u8,
1989+
pub verbose: bool,
1990+
pub quiet: bool,
19901991
pub postgres_url: String,
19911992
pub prefix: String,
19921993
pub no_fail: bool,
@@ -2120,10 +2121,10 @@ pub async fn run_string(
21202121
writeln!(runner.config.stdout, "--- {}", source);
21212122

21222123
for record in parser.parse_records()? {
2123-
// In maximal-verbosity mode, print the query before attempting to run
2124+
// In maximal-verbose mode, print the query before attempting to run
21242125
// it. Running the query might panic, so it is important to print out
21252126
// what query we are trying to run *before* we panic.
2126-
if runner.config.verbosity >= 2 {
2127+
if runner.config.verbose {
21272128
print_record(runner.config, &record);
21282129
}
21292130

@@ -2134,9 +2135,9 @@ pub async fn run_string(
21342135
.unwrap();
21352136

21362137
// Print warnings and failures in verbose mode.
2137-
if runner.config.verbosity >= 1 && !outcome.success() {
2138-
if runner.config.verbosity < 2 {
2139-
// If `verbosity >= 2`, we'll already have printed the record,
2138+
if !runner.config.quiet && !outcome.success() {
2139+
if !runner.config.verbose {
2140+
// If `verbose` is enabled, we'll already have printed the record,
21402141
// so don't print it again. Yes, this is an ugly bit of logic.
21412142
// Please don't try to consolidate it with the `print_record`
21422143
// call above, as it's important to have a mode in which records
@@ -2151,7 +2152,7 @@ pub async fn run_string(
21512152
}
21522153
print_record(runner.config, &record);
21532154
}
2154-
if runner.config.verbosity >= 2 || outcome.failure() {
2155+
if runner.config.verbose || outcome.failure() {
21552156
writeln!(
21562157
runner.config.stdout,
21572158
"{}",

test/sqllogictest/mzcompose.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ def to_command(
238238
]
239239
command = [
240240
"sqllogictest",
241-
"-v",
242241
*([] if rewrite_results else self.flags),
243242
*sqllogictest_config,
244243
file,

0 commit comments

Comments
 (0)