cli: Add new swift-opa test command. - #189
Open
philipaconrad wants to merge 1 commit into
Open
Conversation
This commit includes the CLI interface and plumbing required to implement a minimal subset of `opa test`'s functionality for IR policies. We can now run tests on compiled IR bundles! The core idea is that we generate wrapper plans for any `test_*` rules that are present in the bundle, replacing any plans that may already have been present. This results in consistent execution of tests. The wrapper plans are then executed one-by-one, and the results are aggregated and reporting in similar style to `opa test`'s output format. Resolves: open-policy-agent#182 Signed-off-by: Philip Conrad <philip_conrad@apple.com>
philipaconrad
force-pushed
the
philip/add-opa-test-ir
branch
from
July 15, 2026 19:50
ce23258 to
2fb78ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What code changed, and why?
This commit includes the CLI interface and machinery required to implement a basic subset of
opa test's functionality for IR policies. We can now run tests on compiled IR bundles!The core idea is that we generate wrapper IR plans for any
test_*rules that are present in the bundle, replacing any IR plans that may already have been present. This results in consistent execution of tests.The wrapper plans are then executed one-by-one, and the results are aggregated and reported in similar style to
opa test's output format.The most reliable way to ensure the tests are included in the IR plan outputs is to mark the test package(s) as entrypoints, like:
opa build -b <dir> -t plan -e <test-package>Resolves: #182
How to test
Related Resources