From fcfa89d523f88ea2f6c0b5aa3178449faf93f52e Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Thu, 13 Apr 2023 17:53:57 +0000 Subject: [PATCH 1/2] Check query outputs metadata in the test suite. --- trustfall_core/src/interpreter/execution.rs | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/trustfall_core/src/interpreter/execution.rs b/trustfall_core/src/interpreter/execution.rs index 7cf5d1f4..366b84a5 100644 --- a/trustfall_core/src/interpreter/execution.rs +++ b/trustfall_core/src/interpreter/execution.rs @@ -1230,11 +1230,29 @@ mod tests { use crate::{ interpreter::{error::QueryArgumentsError, InterpretedQuery}, ir::{FieldValue, IndexedQuery}, - util::TestIRQueryResult, + util::{TestIRQueryResult, TestInterpreterOutputData}, }; + #[parameterize("trustfall_core/test_data/tests/valid_queries")] + fn parameterized_output_metadata_tester(base: &Path, stem: &str) { + let mut input_path = PathBuf::from(base); + input_path.push(format!("{stem}.ir.ron")); + + let input_data = fs::read_to_string(input_path).unwrap(); + let test_query: TestIRQueryResult = ron::from_str(&input_data).unwrap(); + let test_query = test_query.unwrap(); + + let mut check_path = PathBuf::from(base); + check_path.push(format!("{stem}.output.ron")); + let check_data = fs::read_to_string(check_path).unwrap(); + let expected_output_data: TestInterpreterOutputData = ron::from_str(&check_data).unwrap(); + + let indexed_query: IndexedQuery = test_query.ir_query.try_into().expect("failed to create IndexedQuery"); + assert_eq!(expected_output_data.outputs, indexed_query.outputs); + } + #[parameterize("trustfall_core/test_data/tests/execution_errors")] - fn parameterizable_tester(base: &Path, stem: &str) { + fn parameterized_execution_error_tester(base: &Path, stem: &str) { let mut input_path = PathBuf::from(base); input_path.push(format!("{stem}.ir.ron")); From d89511424869ed5f34daf8be7be8a51617024e76 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Thu, 13 Apr 2023 18:03:01 +0000 Subject: [PATCH 2/2] Delint. --- trustfall_core/src/interpreter/execution.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trustfall_core/src/interpreter/execution.rs b/trustfall_core/src/interpreter/execution.rs index 366b84a5..2dfeadde 100644 --- a/trustfall_core/src/interpreter/execution.rs +++ b/trustfall_core/src/interpreter/execution.rs @@ -1247,7 +1247,10 @@ mod tests { let check_data = fs::read_to_string(check_path).unwrap(); let expected_output_data: TestInterpreterOutputData = ron::from_str(&check_data).unwrap(); - let indexed_query: IndexedQuery = test_query.ir_query.try_into().expect("failed to create IndexedQuery"); + let indexed_query: IndexedQuery = test_query + .ir_query + .try_into() + .expect("failed to create IndexedQuery"); assert_eq!(expected_output_data.outputs, indexed_query.outputs); }