Skip to content

Commit

Permalink
Factor out progress code
Browse files Browse the repository at this point in the history
  • Loading branch information
emk committed Oct 16, 2023
1 parent 6a4780a commit d1fb002
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/cmd/sql_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,20 @@ pub async fn cmd_sql_test(opt: &SqlTestOpt) -> Result<()> {
if let Some(pending_test_info) =
PendingTestInfo::for_target(driver.target(), short_path, &query)
{
progress('P');
pending.push(pending_test_info);
print!("P");
let _ = io::stdout().flush();
continue;
}
}

// Test query.
match run_test(&mut *driver, &path, &query).await {
Ok(_) => {
print!(".");
let _ = io::stdout().flush();
progress('.');
test_ok_count += 1;
}
Err(e) => {
print!("E");
let _ = io::stdout().flush();
progress('E');
test_failures.push((path, e));
}
}
Expand Down Expand Up @@ -129,6 +126,12 @@ pub async fn cmd_sql_test(opt: &SqlTestOpt) -> Result<()> {
result
}

/// Print a progress indicator for a single test.
fn progress(c: char) {
print!("{}", c);
let _ = io::stdout().flush();
}

#[instrument(skip_all, fields(path = %path.display()))]
async fn run_test(
driver: &mut dyn Driver,
Expand Down

0 comments on commit d1fb002

Please sign in to comment.