mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Policy Coverage (#149)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
f3d9652a73
commit
d3d5367fd4
+4
-17
@@ -17,6 +17,9 @@ fn rego_eval(
|
||||
|
||||
engine.set_strict_builtin_errors(!non_strict);
|
||||
|
||||
#[cfg(feature = "coverage")]
|
||||
engine.set_enable_coverage(coverage);
|
||||
|
||||
// Load files from given bundles.
|
||||
for dir in bundles.iter() {
|
||||
let entries =
|
||||
@@ -73,24 +76,8 @@ fn rego_eval(
|
||||
|
||||
#[cfg(feature = "coverage")]
|
||||
if coverage {
|
||||
println!("\n\nCOVERAGE REPORT");
|
||||
// Fetch coverage report.
|
||||
let report = engine.get_coverage_report()?;
|
||||
for file in report.files.into_iter() {
|
||||
if file.uncovered.is_empty() {
|
||||
println!("{} has full coverage", file.path);
|
||||
continue;
|
||||
}
|
||||
|
||||
println!("{}:", file.path);
|
||||
for (line, code) in file.code.split('\n').enumerate() {
|
||||
if file.uncovered.contains(&(line as u32 + 1)) {
|
||||
println!("\x1b[31m {line:4} {code}\x1b[0m");
|
||||
} else {
|
||||
println!(" {line:4} {code}");
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("{}", report.to_colored_string()?);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user