queryer merger test progress
This commit is contained in:
44
build.rs
44
build.rs
@ -21,22 +21,15 @@ fn to_safe_identifier(name: &str) -> String {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=tests/fixtures");
|
||||
println!("cargo:rerun-if-changed=fixtures");
|
||||
println!("cargo:rerun-if-changed=Cargo.toml");
|
||||
|
||||
// File 1: src/tests/fixtures.rs for #[pg_test]
|
||||
let pg_dest_path = Path::new("src/tests/fixtures.rs");
|
||||
let mut pg_file = File::create(pg_dest_path).unwrap();
|
||||
|
||||
// File 2: tests/fixtures.rs for standard #[test] integration
|
||||
let std_dest_path = Path::new("tests/fixtures.rs");
|
||||
// File: src/tests/fixtures.rs for standard #[test] integration
|
||||
let std_dest_path = Path::new("src/tests/fixtures.rs");
|
||||
let mut std_file = File::create(std_dest_path).unwrap();
|
||||
|
||||
// Write headers
|
||||
writeln!(std_file, "use jspg::validator::util;").unwrap();
|
||||
|
||||
// Walk tests/fixtures directly
|
||||
let fixtures_path = "tests/fixtures";
|
||||
let fixtures_path = "fixtures";
|
||||
if Path::new(fixtures_path).exists() {
|
||||
for entry in fs::read_dir(fixtures_path).unwrap() {
|
||||
let entry = entry.unwrap();
|
||||
@ -72,13 +65,9 @@ fn main() {
|
||||
.expect("Tests must be an array");
|
||||
for (t_idx, test) in tests.iter().enumerate() {
|
||||
let t_obj = test.as_object().expect("Test case must be an object");
|
||||
if !t_obj.contains_key("description")
|
||||
|| !t_obj.contains_key("data")
|
||||
|| !t_obj.contains_key("valid")
|
||||
|| !t_obj.contains_key("schema_id")
|
||||
{
|
||||
if !t_obj.contains_key("description") {
|
||||
panic!(
|
||||
"File {} suite {} test {} is missing required case fields (description, data, valid, schema_id)",
|
||||
"File {} suite {} test {} is missing required case fields (description)",
|
||||
file_name, i, t_idx
|
||||
);
|
||||
}
|
||||
@ -88,29 +77,14 @@ fn main() {
|
||||
let safe_filename = to_safe_identifier(file_name);
|
||||
let fn_name = format!("test_{}_{}", safe_filename, i);
|
||||
|
||||
// Write to src/tests.rs (PG Test)
|
||||
// CARGO_MANIFEST_DIR is used to find the absolute path to fixtures at runtime
|
||||
write!(
|
||||
pg_file,
|
||||
r#"
|
||||
#[pg_test]
|
||||
fn {}() {{
|
||||
let path = format!("{{}}/tests/fixtures/{}.json", env!("CARGO_MANIFEST_DIR"));
|
||||
crate::validator::util::run_test_file_at_index(&path, {}).unwrap();
|
||||
}}
|
||||
"#,
|
||||
fn_name, file_name, i
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Write to tests/tests.rs (Std Test)
|
||||
// Write to src/tests/fixtures.rs (Std Test)
|
||||
write!(
|
||||
std_file,
|
||||
r#"
|
||||
#[test]
|
||||
fn {}() {{
|
||||
let path = format!("{{}}/tests/fixtures/{}.json", env!("CARGO_MANIFEST_DIR"));
|
||||
util::run_test_file_at_index(&path, {}).unwrap();
|
||||
let path = format!("{{}}/fixtures/{}.json", env!("CARGO_MANIFEST_DIR"));
|
||||
crate::tests::runner::run_test_file_at_index(&path, {}).unwrap();
|
||||
}}
|
||||
"#,
|
||||
fn_name, file_name, i
|
||||
|
||||
Reference in New Issue
Block a user