Skip to content

Commit b0acc30

Browse files
committed
Restore ability to run single SLT file
Make it possible again to run single SLT file, even if it's name is a substring of other file(s). For example, after the change, this command: cargo test --test sqllogictests -- test_files/union.slt runs `union.slt` file, but does not run `pg_compat_union.slt`.
1 parent 66b4da2 commit b0acc30

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

datafusion/sqllogictest/bin/sqllogictests.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ fn read_test_files<'a>(
497497
let mut paths = read_dir_recursive(TEST_DIRECTORY)?
498498
.into_iter()
499499
.map(TestFile::new)
500-
.filter(|f| options.check_test_file(&f.relative_path))
500+
.filter(|f| options.check_test_file(&f.path))
501501
.filter(|f| f.is_slt_file())
502502
.filter(|f| f.check_tpch(options))
503503
.filter(|f| f.check_sqlite(options))
@@ -507,7 +507,7 @@ fn read_test_files<'a>(
507507
let mut sqlite_paths = read_dir_recursive(DATAFUSION_TESTING_TEST_DIRECTORY)?
508508
.into_iter()
509509
.map(TestFile::new)
510-
.filter(|f| options.check_test_file(&f.relative_path))
510+
.filter(|f| options.check_test_file(&f.path))
511511
.filter(|f| f.is_slt_file())
512512
.filter(|f| f.check_sqlite(options))
513513
.filter(|f| options.check_pg_compat_file(f.path.as_path()))
@@ -544,10 +544,7 @@ struct Options {
544544
#[clap(long, env = "INCLUDE_TPCH", help = "Include tpch files")]
545545
include_tpch: bool,
546546

547-
#[clap(
548-
action,
549-
help = "regex like arguments passed to the program which are treated as cargo test filter (substring match on filenames)"
550-
)]
547+
#[clap(action, help = "test filter (substring match on filenames)")]
551548
filters: Vec<String>,
552549

553550
#[clap(
@@ -594,15 +591,16 @@ impl Options {
594591
/// To be compatible with this, treat the command line arguments as a
595592
/// filter and that does a substring match on each input. returns
596593
/// true f this path should be run
597-
fn check_test_file(&self, relative_path: &Path) -> bool {
594+
fn check_test_file(&self, path: &Path) -> bool {
598595
if self.filters.is_empty() {
599596
return true;
600597
}
601598

602599
// otherwise check if any filter matches
600+
let path_string = path.to_string_lossy();
603601
self.filters
604602
.iter()
605-
.any(|filter| relative_path.to_string_lossy().contains(filter))
603+
.any(|filter| path_string.contains(filter))
606604
}
607605

608606
/// Postgres runner executes only tests in files with specific names or in

0 commit comments

Comments
 (0)