forked from oflatt/egglog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
69 lines (61 loc) · 1.93 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=src/ast/parse.lalrpop");
lalrpop::process_root().unwrap();
let mdir = std::env!("CARGO_MANIFEST_DIR");
let out_dir = env::var("OUT_DIR").unwrap();
let test_file = &mut File::create(format!("{out_dir}/files.rs")).unwrap();
generate_tests(test_file, &format!("{mdir}/tests/**/*.egg"));
}
fn generate_tests(file: &mut File, glob: &str) {
let paths: Vec<PathBuf> = glob::glob(glob)
.unwrap()
.collect::<Result<_, glob::GlobError>>()
.unwrap();
writeln!(file, "const N_TEST_FILES: usize = {};", paths.len()).unwrap();
for f in paths {
let name = f
.file_stem()
.unwrap()
.to_string_lossy()
.replace(['.', '-', ' '], "_");
let should_fail = f.to_string_lossy().contains("fail-typecheck");
// write a normal test
writeln!(
file,
r#" #[test]
fn {name}() {{
Run {{
path: {f:?},
should_fail: {should_fail},
test_proofs: false,
}}.run();
}}"#,
)
.unwrap();
// write a test with proofs enabled
// TODO: re-enable herbie, unsound, and eqsolve when proof extraction is faster
if !(name == "herbie"
|| name == "repro_unsound"
|| name == "eqsolve"
|| name == "before_proofs"
|| name == "lambda")
{
writeln!(
file,
r#" #[test]
fn {name}_with_proofs() {{
Run {{
path: {f:?},
should_fail: {should_fail},
test_proofs: true,
}}.run();
}}"#,
)
.unwrap();
}
}
}