Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/feature-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
# Common library usage pattern (issue #595): consumer enables
# std + arc + rvm and relies on indexmap/std propagation.
- name: library (std + arc + rvm)
features: std,arc,rvm
features: std,arc,rvm,test-utils

# New default after removing mimalloc from full-opa.
# Ensures all builtins compile without the allocator.
Expand All @@ -45,12 +45,12 @@ jobs:
# Selective builtins without full-opa: validates that popular
# features can be cherry-picked independently.
- name: cherry-picked builtins
features: std,arc,rvm,regex,time,semver,cache
features: std,arc,rvm,regex,time,semver,cache,test-utils

# Observability features only: coverage + cache without the
# heavier builtins (regex, time, etc.).
- name: observability
features: std,arc,rvm,coverage,cache
features: std,arc,rvm,coverage,cache,test-utils

# Azure Policy adds jsonschema + dashmap; test it compiles
# and runs on top of full-opa.
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ time = ["dep:chrono", "dep:chrono-tz"]
uuid = ["dep:uuid"]
urlquery = ["dep:url"]
yaml = ["serde_yaml"]
test-utils = []
full-opa = [
"base64",
"base64url",
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ mod scheduler;
mod schema;
#[cfg(feature = "azure_policy")]
pub mod target;
#[cfg(any(test, all(feature = "yaml", feature = "std")))]
#[cfg(any(test, feature = "test-utils", all(feature = "yaml", feature = "std")))]
pub mod test_utils;
pub mod utils;
mod value;
Expand Down
6 changes: 3 additions & 3 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ pub fn process_value(v: &Value) -> Result<Value> {
/// Diff-friendly equality helper used by multiple YAML suites.
pub fn match_values(computed: &Value, expected: &Value) -> Result<()> {
if computed != expected {
let expected_yaml = serde_yaml::to_string(expected)?;
let computed_yaml = serde_yaml::to_string(computed)?;
bail!("expected:\n{}computed:\n{}", expected_yaml, computed_yaml);
let expected_str = serde_json::to_string_pretty(expected)?;
let computed_str = serde_json::to_string_pretty(computed)?;
bail!("expected:\n{expected_str}\ncomputed:\n{computed_str}");
Comment on lines 93 to +98
}
Ok(())
}
Expand Down
55 changes: 55 additions & 0 deletions src/tests/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,61 @@ fn yaml_test_impl(file: &str) -> Result<()> {
}
}
}
#[cfg(not(feature = "time"))]
{
let skip = [
"add_date.yaml",
"date.yaml",
"clock.yaml",
"diff.yaml",
"format.yaml",
"now_ns.yaml",
"parse_duration_ns.yaml",
"parse_ns.yaml",
"parse_rfc3339_ns.yaml",
"weekday.yaml",
];
for s in skip {
if file.contains(s) {
std::println!("skipped {file} without time feature.");
return Ok(());
}
}
}
#[cfg(not(feature = "semver"))]
{
let skip = ["semver/compare.yaml", "semver/is_valid.yaml"];
for s in skip {
if file.contains(s) {
std::println!("skipped {file} without semver feature.");
return Ok(());
}
}
}
#[cfg(not(feature = "glob"))]
{
if file.contains("globmatch.yaml") {
std::println!("skipped {file} without glob feature.");
return Ok(());
}
Comment on lines +647 to +650
}
#[cfg(not(feature = "uuid"))]
{
let skip = ["uuid/generate.yaml", "uuid/parse.yaml"];
for s in skip {
if file.contains(s) {
std::println!("skipped {file} without uuid feature.");
return Ok(());
}
}
}
#[cfg(not(feature = "regex"))]
{
if file.contains("regex/") {
std::println!("skipped {file} without regex feature.");
return Ok(());
}
Comment on lines +664 to +667
}
Comment on lines +614 to +668
#[cfg(not(feature = "graph"))]
{
// Skip tests that depend on graph builtin that need graph feature.
Expand Down
Loading