From f7a3a54d1d065b46b9e8a90426c778225ba6334e Mon Sep 17 00:00:00 2001 From: Trevor Hansen Date: Fri, 29 Dec 2023 11:31:45 +1100 Subject: [PATCH] Can test on all .json files too --- Cargo.toml | 1 + src/main.rs | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5a042fc..24a0550 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ log = "0.4.19" ordered-float = "3" pico-args = { version = "0.5.0", features = ["eq-separator"] } rand = "0.8.5" +walkdir = "2.4.0" anyhow = "1.0.71" coin_cbc = { version = "0.1.6", optional = true } diff --git a/src/main.rs b/src/main.rs index 74b1041..9191646 100644 --- a/src/main.rs +++ b/src/main.rs @@ -148,11 +148,7 @@ fn main() { */ fn check_optimal_results() { - let optimal_dag_found = extractors() - .into_iter() - .filter(|(_, ed)| ed.is_dag_optimal) - .count() - != 0; + let optimal_dag_found = extractors().into_iter().any(|(_, ed)| ed.is_dag_optimal); let iterations = if optimal_dag_found { 100 } else { 10000 }; @@ -245,6 +241,24 @@ fn check_optimal_results2>(egraphs: I) { } } +// Run on all the .json files in the data directory +#[test] +#[ignore = "too slow to run all the time"] +fn run_files() { + use walkdir::WalkDir; + + let egraphs = WalkDir::new("./data") + .into_iter() + .filter_map(Result::ok) + .filter(|e| { + e.file_type().is_file() + && e.path().extension().and_then(std::ffi::OsStr::to_str) == Some("json") + }) + .map(|e| e.path().to_string_lossy().into_owned()) + .map(|e| EGraph::from_json_file(&e).unwrap()); + check_optimal_results2(egraphs); +} + #[test] #[should_panic] fn check_assert_enabled() {