Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support complete for sqllogictest #9337

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/sqllogictests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ regex = "1"
reqwest = { version = "0.11.13", features = ["json"] }
serde = "1.0.150"
serde_json = "1.0.89"
sqllogictest = "0.9.0"
sqllogictest = { git = "https://github.com/xudong963/sqllogictest-rs", branch = "runner" }
thiserror = "1.0.37"
tokio = { version = "1.21.1", features = ["full"] }
walkdir = "2.3.2"
5 changes: 5 additions & 0 deletions tests/sqllogictests/README.md
Original file line number Diff line number Diff line change
@@ -26,6 +26,11 @@ Run tests under specific file. This is the most commonly used command because us
cargo run -p sqllogictests -- --run_file <file_name>
```
---
Auto complete test file which is very convenient. What you need to do is just a final check to see if the generated results meet expectations.
```
cargo run -p sqllogictests -- --run_file <file_name> --complete
```
---
For more information, run help command:
```shell
cargo run -p sqllogictests -- --help
11 changes: 10 additions & 1 deletion tests/sqllogictests/src/arg.rs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ pub struct SqlLogicTestArgs {

// Set handler to run tests
#[arg(
short = 'c',
short = 'l',
long = "handlers",
use_value_delimiter = true,
value_delimiter = ',',
@@ -59,4 +59,13 @@ pub struct SqlLogicTestArgs {
default_value = "tests/sqllogictests/suites"
)]
pub suites: String,

// If enable complete mode
#[arg(
short = 'c',
long = "complete",
default_missing_value = "true",
help = "The arg is used to enable auto complete mode"
)]
pub complete: bool,
}
14 changes: 12 additions & 2 deletions tests/sqllogictests/src/main.rs
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ use std::path::PathBuf;

use clap::Parser;
use client::ClickhouseHttpClient;
use sqllogictest::default_validator;
use sqllogictest::update_test_file;
use sqllogictest::DBOutput;
use walkdir::DirEntry;
use walkdir::WalkDir;
@@ -174,8 +176,16 @@ async fn run_suits(suits: ReadDir, databend: Databend) -> Result<()> {
continue;
}
}
println!("test file: [{}] is running", file_name,);
runner.run_file_async(file.unwrap().path()).await?;
if args.complete {
let col_separator = " ";
let validator = default_validator;
update_test_file(file.unwrap().path(), &mut runner, col_separator, validator)
.await
.unwrap();
} else {
println!("test file: [{}] is running", file_name,);
runner.run_file_async(file.unwrap().path()).await?;
}
}
}