Skip to content

Commit a13c085

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 a13c085

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

datafusion/sqllogictest/bin/sqllogictests.rs

Lines changed: 6 additions & 5 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()))
@@ -546,7 +546,7 @@ struct Options {
546546

547547
#[clap(
548548
action,
549-
help = "regex like arguments passed to the program which are treated as cargo test filter (substring match on filenames)"
549+
help = "test filter (substring match on filenames)"
550550
)]
551551
filters: Vec<String>,
552552

@@ -594,15 +594,16 @@ impl Options {
594594
/// To be compatible with this, treat the command line arguments as a
595595
/// filter and that does a substring match on each input. returns
596596
/// true f this path should be run
597-
fn check_test_file(&self, relative_path: &Path) -> bool {
597+
fn check_test_file(&self, path: &Path) -> bool {
598598
if self.filters.is_empty() {
599599
return true;
600600
}
601601

602602
// otherwise check if any filter matches
603+
let path_string = path.to_string_lossy();
603604
self.filters
604605
.iter()
605-
.any(|filter| relative_path.to_string_lossy().contains(filter))
606+
.any(|filter| path_string.contains(filter))
606607
}
607608

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

0 commit comments

Comments
 (0)