Skip to content

Commit 5fe912a

Browse files
authored
feat: support skip files with regex (#271)
* feat: support regex filter to filter slt files Signed-off-by: MrCroxx <[email protected]> * refactor: replace filter with skip Signed-off-by: MrCroxx <[email protected]> * ci: bump cargo-semver-checks Signed-off-by: MrCroxx <[email protected]> --------- Signed-off-by: MrCroxx <[email protected]>
1 parent dc6c6d4 commit 5fe912a

File tree

5 files changed

+49
-2
lines changed

5 files changed

+49
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
uses: actions-rs/cargo@v1
6969
with:
7070
command: install
71-
args: cargo-semver-checks --version ^0.41 --locked
71+
args: cargo-semver-checks --version ^0.43 --locked
7272
- name: Check semver
7373
run: |
7474
cargo semver-checks check-release -p sqllogictest

Cargo.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqllogictest-bin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ console = { version = "0.15" }
2121
easy-ext = "1"
2222
futures = { version = "0.3", default-features = false }
2323
glob = "0.3"
24+
fancy-regex = "0.16"
2425
itertools = "0.13"
2526
quick-junit = { version = "0.5" }
2627
rand = "0.8"

sqllogictest-bin/src/main.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use chrono::Local;
1111
use clap::{Arg, ArgAction, CommandFactory, FromArgMatches, Parser, ValueEnum};
1212
use console::style;
1313
use engines::{EngineConfig, EngineType};
14+
use fancy_regex::Regex;
1415
use fs_err::{File, OpenOptions};
1516
use futures::StreamExt;
1617
use itertools::Itertools;
@@ -137,6 +138,10 @@ struct Opt {
137138
/// test file is finished. By default, this is unspecified, meaning to wait forever.
138139
#[clap(long = "shutdown-timeout", env = "SLT_SHUTDOWN_TIMEOUT")]
139140
shutdown_timeout_secs: Option<u64>,
141+
142+
/// Skip tests that matches the given regex.
143+
#[clap(long)]
144+
skip: Option<String>,
140145
}
141146

142147
/// Connection configuration.
@@ -247,6 +252,7 @@ pub async fn main() -> Result<()> {
247252
partition_count,
248253
partition_id,
249254
shutdown_timeout_secs,
255+
skip,
250256
} = Opt::from_arg_matches(&matches)
251257
.map_err(|err| err.exit())
252258
.unwrap();
@@ -295,11 +301,24 @@ pub async fn main() -> Result<()> {
295301
let glob_patterns = files;
296302
let mut all_files = Vec::new();
297303

304+
let re = skip
305+
.map(|s| Regex::new(&s))
306+
.transpose()
307+
.context("invalid regex")?;
308+
298309
for glob_pattern in glob_patterns {
299310
let mut files: Vec<PathBuf> = glob::glob(&glob_pattern)
300311
.context("failed to read glob pattern")?
301312
.try_collect()?;
302313

314+
if let Some(re) = &re {
315+
files.retain(|path| {
316+
!re.is_match(&path.to_string_lossy())
317+
.context("invalid regex")
318+
.unwrap()
319+
});
320+
}
321+
303322
// Test against partitioner only if there are multiple files matched, e.g., expanded from an `*`.
304323
if files.len() > 1 {
305324
if let Some(partitioner) = &partitioner {

sqllogictest/src/substitution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) struct Substitution<'a> {
1515
}
1616

1717
impl Substitution<'_> {
18-
pub fn new(runner_locals: &RunnerLocals, subst_env_vars: bool) -> Substitution {
18+
pub fn new(runner_locals: &RunnerLocals, subst_env_vars: bool) -> Substitution<'_> {
1919
Substitution {
2020
runner_locals,
2121
subst_env_vars,

0 commit comments

Comments
 (0)