Commit Graph

14 Commits

Author SHA1 Message Date
Johan Fylling a179a24c48 v1 API
All packages, except for `cmd` and `internal`, have been moved into a new `v1` root package.

Old packages are kept for backwards-compatibility reasons. All contained code is replaced with simple type aliases and proxy functions to `v1` implementations.

Old packages default to the Rego v0 syntax, new `v1` packages default to the Rego v1 syntax.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:27:34 +01:00
Johan Fylling 7bb6dbe36b Preparing for v1 API
Moving (most) source to v1 root package to prepare for v0/v1 API separation.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:09:03 +01:00
Anders Eknert 6c3f363de3 Don't use rounding for coverage calculation (#6308)
Perhaps it looks prettier, but this is only reported in
JSON output, so I don't think we should decide on what
precision to use there.

On coverage < threshold error, we still print using 2
decimals, which is Pretty (tm).

Fixes #6307

Signed-off-by: Anders Eknert <anders@eknert.com>
2023-10-12 06:49:09 +02:00
Johan Fylling fb16650d23 Adding lines not covered to test coverage threshold error message (#6272)
Printing lines not covered when test coverage threshold isn't met for `opa test --threshold`, and `--verbose` flag is enabled.

Fixes: #2562
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-10-04 15:08:14 +02:00
Faris bb50eba171 Add line count to test coverage report (#4843)
Adds `covered_lines` and `not_covered_lines` to the test coverage report
for each file and the total. This allows custom scripts to parse the
output and calculate its own coverage numbers skipping certain files.

Signed-off-by: FarisR99 <farisrehman@hotmail.co.uk>
2022-07-11 17:29:46 -04:00
Anders Eknert cb01fba015 coverage: remove duplicates from coverage report (#4410)
Fixes #4393

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-03-04 15:27:32 +01:00
Patrick East f865d438e9 cover: Update Cover tracer to be a QueryTracer
Using the newer `topdown.QueryTracer` interface yields a significant
performance improvement for the tracer (up to ~10% for relevant
 benchmarks).

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-06-08 10:04:34 -04:00
Patrick East dff78c48b9 cover: Disable local var plugging on trace
Similar treatment as what we do with the `Profiler`, the coverage
tracer will now signal via configuration that it doesn't need local
variable metadata.

This improves the speed of evaluations with only coverage enabled by
a pretty substantial amount, in particular with many/larger variables.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-05-21 15:11:11 -07:00
Patrick East 1d9cf35926 cover: Exclude some expressions in coverage report
They would previously show up as not-covered in any report. This
changes to simply omit them. They will never be int the resulting
covered or not-covered lists, or count against the % covered.

Fixes: #1972
Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-02-12 09:56:53 -05:00
Torin Sandall b44fefe891 Unexport helper function to compute coverage
The helper function to compute coverage doesn't have to be exported
since the coverage is set as a field on the FileReport. Removing the
helper function in the spirit of minimizing the surface area of the
package.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-10-31 15:12:59 -07:00
Flavio Castelli a915f1a298 opa test: handle code coverage percentage
Compute the code coverage percentage of each file and the overall one.

Allow the user to specify a coverage threshold when running the `opa test`
command. The program execution will fail when the global file coverage
doesn't respect the required threshold.

`opa test` will exit with error code 2 when the coverage doesn't meet
the specified threshold.

Fixes issue #1029.

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
2018-10-31 10:45:43 -07:00
Ashutosh Narkar e85546d1b6 Add Rego profiler
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2018-07-03 10:34:04 -07:00
Torin Sandall 7b096c7a1e Add package description to cover 2018-03-19 11:24:04 -07:00
Torin Sandall 966eaac912 Add cover package and enhance test subcommand 2018-03-13 11:52:02 -07:00