mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
feat: Reject with keyword usage
RVM does not plan to support the `with` keyword which is mainly used for testing. - introduce CompilerError::WithKeywordUnsupported and fail query compilation when any literal carries with_mods - skip OPA test cases that hit the error The "withkeyword" folder is retained in the TODO list to indicate its lack of support. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
19
tests/opa.rs
19
tests/opa.rs
@@ -32,10 +32,9 @@ const OPA_TODO_FOLDERS: &[&str] = &[
|
||||
"partialobjectdoc",
|
||||
"planner-ir",
|
||||
"refheads",
|
||||
"sets",
|
||||
"type",
|
||||
"virtualdocs",
|
||||
"walkbuiltin",
|
||||
// RVM Compiler does not support 'with' keyword yet.
|
||||
"withkeyword",
|
||||
];
|
||||
|
||||
@@ -267,6 +266,14 @@ fn is_not_valid_rule_path_error(err: &anyhow::Error) -> bool {
|
||||
.any(|cause| cause.to_string().contains("not a valid rule path"))
|
||||
}
|
||||
|
||||
fn is_with_keyword_unsupported_error(err: &anyhow::Error) -> bool {
|
||||
err.chain().any(|cause| {
|
||||
cause
|
||||
.to_string()
|
||||
.contains("`with` keyword is not supported")
|
||||
})
|
||||
}
|
||||
|
||||
fn maybe_verify_rvm_case(case: &TestCase, is_rego_v0_test: bool, actual: &Value) -> Result<()> {
|
||||
if case.note == "defaultkeyword/function with var arg, ref head query" {
|
||||
println!(
|
||||
@@ -292,6 +299,14 @@ fn maybe_verify_rvm_case(case: &TestCase, is_rego_v0_test: bool, actual: &Value)
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if is_with_keyword_unsupported_error(&err) {
|
||||
println!(
|
||||
" skipping RVM check for '{}' (with keyword unsupported)",
|
||||
case.note
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user