42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
#![feature(custom_test_frameworks)]
|
|
#![feature(once_cell)]
|
|
#![test_runner(datatest::runner)]
|
|
|
|
use std::fs::File;
|
|
use std::io::Read;
|
|
use std::lazy::SyncLazy;
|
|
use std::path::Path;
|
|
|
|
use pkmn_lib::dynamic_data::DynamicLibrary;
|
|
|
|
use crate::common::{library_loader, TestCase};
|
|
|
|
pub mod common;
|
|
|
|
static LIBRARY: SyncLazy<DynamicLibrary> = SyncLazy::new(|| {
|
|
let start_time = chrono::Utc::now();
|
|
let lib = library_loader::load_library();
|
|
let end_time = chrono::Utc::now();
|
|
println!("Built library in {} ms", (end_time - start_time).num_milliseconds());
|
|
lib
|
|
});
|
|
|
|
#[test]
|
|
#[cfg_attr(miri, ignore)]
|
|
fn validate_library_load() {
|
|
SyncLazy::force(&LIBRARY);
|
|
}
|
|
|
|
#[datatest::files("tests/test_cases", {
|
|
input in r"^(.*)\.yaml"
|
|
})]
|
|
#[cfg_attr(miri, ignore)]
|
|
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(&LIBRARY);
|
|
}
|