2023-04-02 10:07:08 +00:00
|
|
|
use std::io::Write;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let files = std::fs::read_dir("tests/test_cases").unwrap();
|
|
|
|
let mut output_file = std::fs::File::create("tests/datatests/mod.rs").unwrap();
|
|
|
|
output_file
|
|
|
|
.write_all(
|
|
|
|
b"// This file is generated by build.rs
|
|
|
|
|
|
|
|
use super::common::TestCase;
|
|
|
|
use super::get_library;
|
2023-04-02 10:32:54 +00:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::Read;
|
|
|
|
use std::path::Path;
|
2023-04-02 10:07:08 +00:00
|
|
|
|
|
|
|
fn integration_tests(input: &Path) {
|
|
|
|
let mut str: String = \"\".to_string();
|
|
|
|
let mut file = File::open(input).unwrap();
|
|
|
|
file.read_to_string(&mut str).unwrap();
|
|
|
|
let test_case = serde_yaml::from_str::<TestCase>(&str).unwrap();
|
|
|
|
println!(\"\tRunning integration test {}\", test_case.name);
|
|
|
|
test_case.run_test(get_library());
|
|
|
|
}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
for file in files {
|
|
|
|
let file = file.unwrap();
|
|
|
|
let path = file.path();
|
|
|
|
let path_str = path.to_str().unwrap();
|
|
|
|
if path_str.ends_with(".yaml") {
|
|
|
|
println!("cargo:rerun-if-changed={}", path_str);
|
|
|
|
}
|
|
|
|
let file_name = path.file_stem().unwrap().to_str().unwrap();
|
|
|
|
|
|
|
|
write!(
|
|
|
|
output_file,
|
|
|
|
"
|
|
|
|
#[test]
|
|
|
|
fn {}() {{
|
|
|
|
integration_tests(Path::new(\"{}\"));
|
|
|
|
}}
|
2023-04-02 10:32:54 +00:00
|
|
|
",
|
2023-04-02 10:07:08 +00:00
|
|
|
file_name,
|
|
|
|
path.to_str().unwrap(),
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
}
|