mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-14 08:41:06 +00:00
Allow for files to be specified in the corpus file
This commit is contained in:
+34
-20
@@ -35,33 +35,47 @@ impl Corpus {
|
|||||||
///
|
///
|
||||||
/// `path` is expected to be a directory.
|
/// `path` is expected to be a directory.
|
||||||
pub fn collect_metadata(path: &Path, tests: &mut Vec<MetadataFile>) {
|
pub fn collect_metadata(path: &Path, tests: &mut Vec<MetadataFile>) {
|
||||||
let dir_entry = match std::fs::read_dir(path) {
|
if path.is_dir() {
|
||||||
Ok(dir_entry) => dir_entry,
|
let dir_entry = match std::fs::read_dir(path) {
|
||||||
Err(error) => {
|
Ok(dir_entry) => dir_entry,
|
||||||
tracing::error!("failed to read dir '{}': {error}", path.display());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for entry in dir_entry {
|
|
||||||
let entry = match entry {
|
|
||||||
Ok(entry) => entry,
|
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
tracing::error!("error reading dir entry: {error}");
|
tracing::error!("failed to read dir '{}': {error}", path.display());
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = entry.path();
|
for entry in dir_entry {
|
||||||
if path.is_dir() {
|
let entry = match entry {
|
||||||
collect_metadata(&path, tests);
|
Ok(entry) => entry,
|
||||||
continue;
|
Err(error) => {
|
||||||
}
|
tracing::error!("error reading dir entry: {error}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if path.is_file() {
|
let path = entry.path();
|
||||||
if let Some(metadata) = MetadataFile::try_from_file(&path) {
|
if path.is_dir() {
|
||||||
|
collect_metadata(&path, tests);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if path.is_file() {
|
||||||
|
if let Some(metadata) = MetadataFile::try_from_file(&path) {
|
||||||
|
tests.push(metadata)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let Some(extension) = path.extension() else {
|
||||||
|
tracing::error!("Failed to get file extension");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
if extension.eq_ignore_ascii_case("sol") || extension.eq_ignore_ascii_case("json") {
|
||||||
|
if let Some(metadata) = MetadataFile::try_from_file(path) {
|
||||||
tests.push(metadata)
|
tests.push(metadata)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tracing::error!(?extension, "Unsupported file extension");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user