Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b65db0a

Browse files
committedDec 22, 2022
feat: support complete for sqllogictest
1 parent 3ab2ba0 commit b65db0a

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed
 

‎Cargo.lock

+22-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/sqllogictests/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ regex = "1"
1717
reqwest = { version = "0.11.13", features = ["json"] }
1818
serde = "1.0.150"
1919
serde_json = "1.0.89"
20-
sqllogictest = "0.9.0"
20+
sqllogictest = { git = "https://github.com/xudong963/sqllogictest-rs", branch = "runner" }
2121
thiserror = "1.0.37"
2222
tokio = { version = "1.21.1", features = ["full"] }
2323
walkdir = "2.3.2"

‎tests/sqllogictests/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ Run tests under specific file. This is the most commonly used command because us
2626
cargo run -p sqllogictests -- --run_file <file_name>
2727
```
2828
---
29+
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.
30+
```
31+
cargo run -p sqllogictests -- --run_file <file_name> --complete
32+
```
33+
---
2934
For more information, run help command:
3035
```shell
3136
cargo run -p sqllogictests -- --help

‎tests/sqllogictests/src/arg.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct SqlLogicTestArgs {
4343

4444
// Set handler to run tests
4545
#[arg(
46-
short = 'c',
46+
short = 'l',
4747
long = "handlers",
4848
use_value_delimiter = true,
4949
value_delimiter = ',',
@@ -59,4 +59,14 @@ pub struct SqlLogicTestArgs {
5959
default_value = "tests/sqllogictests/suites"
6060
)]
6161
pub suites: String,
62+
63+
// If enable complete mode
64+
#[arg(
65+
short = 'c',
66+
long = "complete",
67+
default_missing_value = "true",
68+
default_value = "false",
69+
help = "The arg is used to enable auto complete mode"
70+
)]
71+
pub complete: bool,
6272
}

‎tests/sqllogictests/src/main.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use std::path::PathBuf;
1717

1818
use clap::Parser;
1919
use client::ClickhouseHttpClient;
20+
use sqllogictest::default_validator;
21+
use sqllogictest::update_test_file;
2022
use sqllogictest::DBOutput;
2123
use walkdir::DirEntry;
2224
use walkdir::WalkDir;
@@ -174,8 +176,16 @@ async fn run_suits(suits: ReadDir, databend: Databend) -> Result<()> {
174176
continue;
175177
}
176178
}
177-
println!("test file: [{}] is running", file_name,);
178-
runner.run_file_async(file.unwrap().path()).await?;
179+
if args.complete {
180+
let col_separator = " ";
181+
let validator = default_validator;
182+
update_test_file(file.unwrap().path(), &mut runner, col_separator, validator)
183+
.await
184+
.unwrap();
185+
} else {
186+
println!("test file: [{}] is running", file_name,);
187+
runner.run_file_async(file.unwrap().path()).await?;
188+
}
179189
}
180190
}
181191

0 commit comments

Comments
 (0)
Please sign in to comment.