alamb commented on code in PR #20656:
URL: https://github.com/apache/datafusion/pull/20656#discussion_r2874227911
##########
datafusion/sqllogictest/bin/sqllogictests.rs:
##########
@@ -832,91 +782,35 @@ async fn run_complete_file_with_postgres(
plan_err!("Can not run with postgres as postgres feature is not enabled")
}
-/// Represents a parsed test file
-#[derive(Debug)]
-struct TestFile {
- /// The absolute path to the file
- pub path: PathBuf,
- /// The relative path of the file (used for display)
- pub relative_path: PathBuf,
-}
-
-impl TestFile {
- fn new(path: PathBuf) -> Self {
- let p = path.to_string_lossy();
- let relative_path = PathBuf::from(if p.starts_with(TEST_DIRECTORY) {
- p.strip_prefix(TEST_DIRECTORY).unwrap()
- } else if p.starts_with(DATAFUSION_TESTING_TEST_DIRECTORY) {
- p.strip_prefix(DATAFUSION_TESTING_TEST_DIRECTORY).unwrap()
- } else {
- ""
- });
-
- Self {
- path,
- relative_path,
- }
- }
-
- fn is_slt_file(&self) -> bool {
- self.path.extension() == Some(OsStr::new("slt"))
- }
-
- fn check_sqlite(&self, options: &Options) -> bool {
- if !self.relative_path.starts_with(SQLITE_PREFIX) {
- return true;
- }
-
- options.include_sqlite
- }
-
- fn check_tpch(&self, options: &Options) -> bool {
- if !self.relative_path.starts_with("tpch") {
- return true;
- }
+fn read_test_files(options: &Options) -> Result<Vec<TestFile>> {
+ let prefixes: &[&str] = if options.include_sqlite {
+ &[TEST_DIRECTORY, DATAFUSION_TESTING_TEST_DIRECTORY]
+ } else {
+ &[TEST_DIRECTORY]
+ };
- options.include_tpch
- }
-}
+ let directories = prefixes
+ .iter()
+ .map(|prefix| {
+ read_dir_recursive(prefix).map_err(|e| {
+ exec_datafusion_err!("Error reading test directory {prefix}:
{e}")
+ })
+ })
+ .collect::<Result<Vec<_>>>()?;
-fn read_test_files(options: &Options) -> Result<Vec<TestFile>> {
- let mut paths = read_dir_recursive(TEST_DIRECTORY)?
+ let mut paths = directories
.into_iter()
- .map(TestFile::new)
+ .flatten()
+ .map(|p| TestFile::new(p, prefixes))
.filter(|f| options.check_test_file(&f.path))
.filter(|f| f.is_slt_file())
- .filter(|f| f.check_tpch(options))
- .filter(|f| f.check_sqlite(options))
+ .filter(|f| !f.relative_path_starts_with(TPCH_PREFIX) ||
options.include_tpch)
Review Comment:
I separate the Options out of here as they aren't logically part of the Test
file
##########
datafusion/sqllogictest/bin/sqllogictests.rs:
##########
@@ -77,55 +76,6 @@ struct FileTiming {
elapsed: Duration,
}
-/// TEST PRIORITY
Review Comment:
I refactored all this code and other TestFile logic into a new `test_file`
module
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]