Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- markdownlint-disable MD041 -->

[![Build Status](https://github.com/open-policy-agent/regal/workflows/Build/badge.svg)](https://github.com/open-policy-agent/regal/actions)
![OPA v1.13.1](https://www.openpolicyagent.org/badge/v1.13.1)
![OPA v1.13.1-0.20260224105757-9b2143cdf99c](https://www.openpolicyagent.org/badge/v1.13.1-0.20260224105757-9b2143cdf99c)
[![codecov](https://codecov.io/github/open-policy-agent/regal/graph/badge.svg?token=EQK01YF3X3)](https://codecov.io/github/StyraInc/regal)
[![Downloads](https://img.shields.io/github/downloads/open-policy-agent/regal/total.svg)](https://github.com/open-policy-agent/regal/releases)

Expand Down
3 changes: 2 additions & 1 deletion bundle/regal/ast/ast.rego
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ rules := [rule |
tests := [rule |
some rule in rules

startswith(rule.head.ref[0].value, "test_")
some part in rule.head.ref
startswith(part.value, "test_")
]

# METADATA
Expand Down
24 changes: 24 additions & 0 deletions bundle/regal/lsp/testlocations/testlocations.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# METADATA
# description: |
# This returns a set of test_ rule locations in a given module.
# Used by the regal/testLocations method in the LSP to have clients know
# where tests are.
package regal.lsp.testlocations

import data.regal.ast
import data.regal.result as rs

# METADATA
# description: |
# result contains a list of locations. A location is test name, package and
# the location (which has start and end char range too).
result contains object.union(loc, {
"package": _package_ref_string,
"name": ast.ref_static_to_string(test.head.ref),
}) if {
some test in ast.tests

loc := rs.location(test.head)
}

_package_ref_string := ast.ref_to_string(input.package.path)
126 changes: 126 additions & 0 deletions bundle/regal/lsp/testlocations/testlocations_test.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package regal.lsp.testlocations_test

import data.regal.lsp.testlocations

test_multiple_test_rules if {
policy := `package foo_test

test_1 if {
1 == 2
}

test_2 if true

test_3 if {
1 == 2
2 == 1
}
`

result := testlocations.result with input as regal.parse_module("file://foo_test.rego", policy)

{
{
"package": "data.foo_test",
"name": "test_1",
"location": {
"col": 1,
"row": 3,
"end": {"col": 7, "row": 3},
"file": "file://foo_test.rego",
"text": "test_1 if {",
},
},
{
"package": "data.foo_test",
"name": "test_2",
"location": {
"col": 1,
"row": 7,
"end": {"col": 7, "row": 7},
"file": "file://foo_test.rego",
"text": "test_2 if true",
},
},
{
"package": "data.foo_test",
"name": "test_3",
"location": {
"col": 3,
"row": 9,
"end": {"col": 9, "row": 9},
"file": "file://foo_test.rego",
"text": " test_3 if {",
},
},
} == result
}

test_no_test_rules if {
policy := `package foo_test`

result := testlocations.result with input as regal.parse_module("file://foo_test.rego", policy)

set() == result
}

test_non_test_package if {
policy := `package foo

test_foo if true
`

result := testlocations.result with input as regal.parse_module("file://foo.rego", policy)

{{
"package": "data.foo",
"name": "test_foo",
"location": {
"col": 1,
"row": 3,
"end": {"col": 9, "row": 3},
"file": "file://foo.rego",
"text": "test_foo if true",
},
}} == result
}

test_funny_test_names_package if {
policy := `package foo

foo.bar.test_me if {
false
}

foo.bar.test_me.baz if {
false
}
`

result := testlocations.result with input as regal.parse_module("file://foo.rego", policy)

{
{
"package": "data.foo",
"name": "foo.bar.test_me",
"location": {
"col": 1,
"row": 3,
"end": {"col": 16, "row": 3},
"file": "file://foo.rego",
"text": "foo.bar.test_me if {",
},
},
{
"package": "data.foo",
"name": "foo.bar.test_me.baz",
"location": {
"col": 1,
"row": 7,
"end": {"col": 20, "row": 7},
"file": "file://foo.rego",
"text": "foo.bar.test_me.baz if {",
},
},
} == result
}
1 change: 1 addition & 0 deletions cmd/languageserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func init() {

go ls.StartDiagnosticsWorker(ctx)
go ls.StartHoverWorker(ctx)
go ls.StartTestLocationsWorker(ctx)
go ls.StartCommandWorker(ctx)
go ls.StartConfigWorker(ctx)
go ls.StartWorkspaceStateWorker(ctx)
Expand Down
2 changes: 1 addition & 1 deletion docs/readme-sections/badges.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- markdownlint-disable MD041 -->

[![Build Status](https://github.com/open-policy-agent/regal/workflows/Build/badge.svg)](https://github.com/open-policy-agent/regal/actions)
![OPA v1.13.1](https://www.openpolicyagent.org/badge/v1.13.1)
![OPA v1.13.1-0.20260224105757-9b2143cdf99c](https://www.openpolicyagent.org/badge/v1.13.1-0.20260224105757-9b2143cdf99c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need? Ah, the runtime bits. 💡

[![codecov](https://codecov.io/github/open-policy-agent/regal/graph/badge.svg?token=EQK01YF3X3)](https://codecov.io/github/StyraInc/regal)
[![Downloads](https://img.shields.io/github/downloads/open-policy-agent/regal/total.svg)](https://github.com/open-policy-agent/regal/releases)
67 changes: 33 additions & 34 deletions e2e/testbuild/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.26
replace github.com/open-policy-agent/regal => ../../

require (
github.com/open-policy-agent/opa v1.13.1
github.com/open-policy-agent/opa v1.13.1-0.20260224105757-9b2143cdf99c
github.com/open-policy-agent/regal v0.0.0-00010101000000-000000000000
)

Expand All @@ -19,18 +19,18 @@ require (
github.com/bytecodealliance/wasmtime-go/v39 v39.0.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/containerd/containerd/v2 v2.2.1 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v1.0.0-rc.2 // indirect
github.com/containerd/typeurl/v2 v2.2.3 // indirect
github.com/cyphar/filepath-securejoin v0.5.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/dgraph-io/badger/v4 v4.9.0 // indirect
github.com/dgraph-io/ristretto/v2 v2.3.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 // indirect
github.com/dgraph-io/badger/v4 v4.9.1 // indirect
github.com/dgraph-io/ristretto/v2 v2.4.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.18.0 // indirect
Expand All @@ -49,42 +49,42 @@ require (
github.com/goccy/go-json v0.10.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/google/flatbuffers v25.9.23+incompatible // indirect
github.com/google/flatbuffers v25.12.19+incompatible // indirect
github.com/google/go-dap v0.12.0 // indirect
github.com/google/pprof v0.0.0-20251007162407-5df77e3f7d1d // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/huandu/go-clone v1.7.3 // indirect
github.com/huandu/go-sqlbuilder v1.39.0 // indirect
github.com/huandu/go-sqlbuilder v1.39.1 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/jstemmer/go-junit-report/v2 v2.1.0 // indirect
github.com/kevinburke/ssh_config v1.4.0 // indirect
github.com/klauspost/compress v1.18.2 // indirect
github.com/klauspost/compress v1.18.4 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
github.com/lestrrat-go/dsig v1.0.0 // indirect
github.com/lestrrat-go/dsig-secp256k1 v1.0.0 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc/v3 v3.0.2 // indirect
github.com/lestrrat-go/httprc/v3 v3.0.4 // indirect
github.com/lestrrat-go/jwx/v3 v3.0.13 // indirect
github.com/lestrrat-go/option/v2 v2.0.0 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.20 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
github.com/olekukonko/errors v1.1.0 // indirect
github.com/olekukonko/ll v0.1.2 // indirect
github.com/olekukonko/tablewriter v1.1.0 // indirect
github.com/olekukonko/errors v1.2.0 // indirect
github.com/olekukonko/ll v0.1.7 // indirect
github.com/olekukonko/tablewriter v1.1.3 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/owenrumney/go-sarif/v2 v2.3.3 // indirect
Expand All @@ -95,10 +95,9 @@ require (
github.com/pkg/profile v1.7.0 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.19.2 // indirect
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/sergi/go-diff v1.4.0 // indirect
Expand All @@ -112,34 +111,34 @@ require (
github.com/spf13/viper v1.21.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tchap/go-patricia/v2 v2.3.3 // indirect
github.com/valyala/fastjson v1.6.7 // indirect
github.com/vektah/gqlparser/v2 v2.5.31 // indirect
github.com/valyala/fastjson v1.6.10 // indirect
github.com/vektah/gqlparser/v2 v2.5.32 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/yashtewari/glob-intersection v0.2.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect
go.opentelemetry.io/otel v1.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.39.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/sdk v1.39.0 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0 // indirect
go.opentelemetry.io/otel v1.40.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.40.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 // indirect
go.opentelemetry.io/otel/metric v1.40.0 // indirect
go.opentelemetry.io/otel/sdk v1.40.0 // indirect
go.opentelemetry.io/otel/trace v1.40.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/net v0.50.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
golang.org/x/time v0.14.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/grpc v1.78.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/grpc v1.79.1 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/ini.v1 v1.67.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
Loading
Loading