Skip to content

Commit e060e43

Browse files
authored
test: OPA RVM validation (microsoft#514)
- fixes: - ensure loop hoist lookups reserve query capacity and keep loop-var tables sized when compiling default rules - rebuild hoisting tables with the analyzer’s schedule when available so statement order matches evaluation - OPA test - Also test using RVM workflow in OPA suite - Maintain a list of test folders that don't yet pass and skip them Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
1 parent 12c083e commit e060e43

3 files changed

Lines changed: 299 additions & 8 deletions

File tree

src/compiler/hoist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ impl LoopHoister {
510510
query: &Query,
511511
parent_context: &ScopeContext,
512512
) -> Result<ScopeContext> {
513+
self.lookup.ensure_query_capacity(module_idx, query.qidx);
513514
let mut context = parent_context.clone();
514515
context.current_scope_bound_vars = parent_context.current_scope_bound_vars.clone();
515516

src/interpreter.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3375,6 +3375,7 @@ impl Interpreter {
33753375
pub fn eval_default_rule_for_compiler(&mut self, rule_path: &str) -> Result<Value> {
33763376
self.input = Value::Undefined;
33773377
self.data = Value::Undefined;
3378+
self.ensure_loop_var_values_capacity();
33783379

33793380
let default_rules = self.compiled_policy.default_rules.get(rule_path).cloned();
33803381

@@ -4088,7 +4089,12 @@ impl Interpreter {
40884089

40894090
// Populate loop hoisting lookup table
40904091
use crate::compiler::hoist::LoopHoister;
4091-
let hoister = LoopHoister::new();
4092+
// Re-run hoisting with the analyzer's schedule so statement order is preserved.
4093+
let hoister = if let Some(schedule) = compiled_policy.schedule.clone() {
4094+
LoopHoister::new_with_schedule(schedule)
4095+
} else {
4096+
LoopHoister::new()
4097+
};
40924098
let loop_lookup = hoister.populate(compiled_policy.modules.as_ref())?;
40934099
compiled_policy.loop_hoisting_table = loop_lookup;
40944100

0 commit comments

Comments
 (0)