Skip to content

Commit

Permalink
Can test on all .json files too
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorHansen committed Dec 29, 2023
1 parent 2ebffd7 commit f7a3a54
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
24 changes: 19 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -245,6 +241,24 @@ fn check_optimal_results2<I: Iterator<Item = EGraph>>(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() {
Expand Down

0 comments on commit f7a3a54

Please sign in to comment.