# CLI, Testing, and Bundles Use this reference for command behavior, test output, formatting, bundle validation and compilation, REPL migration, and Wasm artifacts. ## Checking and parsing ### Parse legacy modules explicitly (`1.6.0`) `opa parse` accepts `--v0-compatible`, allowing legacy syntax to be parsed in the intended mode: ```sh opa parse --v0-compatible policy.rego ``` ### Detect base/virtual document conflicts (`1.6.0`) `opa check --bundle` reports JSON or YAML base documents that overlap virtual documents generated by Rego rules. Resolve ambiguous paths before accepting a bundle: ```sh opa check --bundle ./bundle ``` ## Testing and execution output ### Parameterize data-driven tests (`1.2.0`) Generate hierarchical named cases by putting the case name in a test rule's head. `opa test` reports each case beneath the parent rule, so a failure does not obscure other inputs. ```rego package example_test test_concat[note] if { some note, tc in { "empty": {"a": [], "b": [], "want": []}, "filled": {"a": [1], "b": [2], "want": [1, 2]}, } array.concat(tc.a, tc.b) == tc.want } ``` ### Expect corrected test summaries (`1.3.0`) Parameterized cases count toward the report counter. In non-verbose mode, the summary includes only failed sub-test cases. ### Control parallel test execution (`1.6.0`) `opa test` uses one execution thread per available CPU core by default. Force sequential execution for order-sensitive tests: ```sh opa test . --parallel=1 ``` ### Separate evaluation errors from stdout (`1.9.0`) `opa eval` writes evaluation errors to stderr. Callers that capture or parse results must read stderr separately from stdout. ### Sort JSON test output by duration (`1.13.0`) JSON-format `opa test` results can be sorted by duration to identify slow tests. ### Handle streamed test output (`1.17.0`) `opa test` streams individual test-case results. Consumers must handle results arriving incrementally. Under `--coverage`, failures include full errors. ### Rebaseline coverage locations (`1.18.0`) `opa test --coverage` reports source ranges and tracks inline rule heads and conjunction expressions. Coverage locations and totals can change even when policy behavior does not, so update stored expectations deliberately. ### Debug with YAML input (`1.0.0`) The debugger accepts YAML input directly. ## Formatting ### Preserve compatibility imports (`1.0.0`) When formatting in v1 mode, OPA keeps `rego.v1` and `future.keywords` imports. Do not treat their survival as a formatting failure; they preserve intent for older consumers. ### Reformat with the corrected formatter (`1.4.0`) The formatter no longer changes string contents and no longer panics on unexpected comments. Re-run `opa fmt` with 1.4.0 or newer before trusting diffs created by an affected older formatter. ### Preserve unchanged file timestamps (`1.13.0`) `opa fmt` does not overwrite a file when formatting produces no changes, so a no-op format preserves its modification time. ### Use the fixed 1.18 formatter (`1.18.0`) OPA 1.18.0 accidentally forced single-item arrays, objects, and sets onto multiple lines. Version 1.18.2 restores source-newline-controlled one-line or multiline formatting. The 1.18 formatter also preserves `with` clauses after comments in object values and lone `with` placement on closing-bracket lines. ## Bundle production and validation ### Keep `print` in Wasm bundles (`1.0.0`) `opa build` has an option to preserve `print` statements when targeting Wasm. Enable it for bundles whose diagnostics depend on `print`. ### Use multi-term optimized entrypoints (`1.3.0`) Optimized bundle builds reject single-term entrypoint paths. Include at least the package and rule: ```sh opa build -O=1 -e=authz/allow . ``` ### Account for API default Rego versions (`1.5.0`) The bundle API supplies a default Rego version when a caller omits one. Embedded producers must account for resulting version metadata rather than assuming the field remains unset. ### Resolve versions per module (`1.18.0`) Bundle handling corrects per-module Rego-version lookup and resolves overlapping `file_rego_versions` patterns deterministically. Recheck mixed-version bundles and manifests with overlapping patterns because module selection may change. ### Choose a plan-bundle format (`1.19.0`) `opa build --format` selects whether a plan bundle emits its plan representation as protobuf or JSON. ## Wasm behavior and artifacts ### Recheck reference-head results (`1.3.0`) Wasm and non-Wasm evaluation now agree for reference-head rules affected by an over-eager planner optimization. Upgrading can change Wasm results for policies that encountered the bug. ### Build without a C toolchain (`1.18.0`) The `wasm` evaluation target and Wasm SDK use the pure-Go wazero runtime rather than `wasmtime-go`. Wasm-enabled builds no longer require cgo or a C toolchain. ### Preserve package annotations (`1.19.0`) Wasm bundle compilation retains package annotations. Metadata-dependent tooling no longer loses package-scoped annotations during `opa build`. ## REPL history ### Expect automatic migration (`1.19.0`) The REPL supports bracketed paste, so pasted tab-indented policy is inserted literally instead of triggering completion. On first use, it migrates the default `~/.opa_history`—or the file selected by `--history`—from the old line format to JSON Lines in place.