Runs roundtrip tests for a collection of queries and reports results. Iterates through all queries, running each through [`collect_results`]. Prints colored status (green checkmark for success, red X for failure) and panics at the end if any tests failed, with detailed error messages. # Type Parameters `F` - Factory function that creates fresh session contexts `Fut` - Future type returned by th
(
suite_name: &str,
queries: Vec<TestQuery>,
create_context: F,
)
| 416 | /// |
| 417 | /// Panics if any query fails the roundtrip test, displaying all failures. |
| 418 | async fn run_roundtrip_tests<F, Fut>( |
| 419 | suite_name: &str, |
| 420 | queries: Vec<TestQuery>, |
| 421 | create_context: F, |
| 422 | ) where |
| 423 | F: Fn() -> Fut, |
| 424 | Fut: Future<Output = Result<SessionContext>>, |
| 425 | { |
| 426 | let mut errors: Vec<String> = vec![]; |
| 427 | for sql in queries { |
| 428 | let ctx = match create_context().await { |
| 429 | Ok(ctx) => ctx, |
| 430 | Err(e) => { |
| 431 | println!("\x1b[31m✗\x1b[0m {} query: {}", suite_name, sql.name); |
| 432 | errors.push(format!("Failed to create context for {}: {}", sql.name, e)); |
| 433 | continue; |
| 434 | } |
| 435 | }; |
| 436 | let result = collect_results(&ctx, &sql.sql).await; |
| 437 | if result.is_failure() { |
| 438 | println!("\x1b[31m✗\x1b[0m {} query: {}", suite_name, sql.name); |
| 439 | errors.push(result.format_error(&sql.name)); |
| 440 | } else { |
| 441 | println!("\x1b[32m✓\x1b[0m {} query: {}", suite_name, sql.name); |
| 442 | } |
| 443 | } |
| 444 | if !errors.is_empty() { |
| 445 | panic!( |
| 446 | "{} {} test(s) failed:\n\n{}", |
| 447 | errors.len(), |
| 448 | suite_name, |
| 449 | errors.join("\n\n---\n\n") |
| 450 | ); |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | #[tokio::test] |
| 455 | async fn test_clickbench_unparser_roundtrip() { |
no test coverage detected
searching dependent graphs…