Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend test command to allow filtering package / file / test #6696

Open
anderseknert opened this issue Apr 15, 2024 · 0 comments
Open

Extend test command to allow filtering package / file / test #6696

anderseknert opened this issue Apr 15, 2024 · 0 comments

Comments

@anderseknert
Copy link
Member

Having recently looked into a deeper integration of the OPA test runner (via command line invocation) and the OPA VS Code extension, there are some hurdles that I think would be best solved in OPA itself, as that would benefit not just VS Code but any editor including a similar integration. The problems are described in this issue, but to summarize here:

Editors and IDEs commonly run tests filtered by either:

  • file (run all tests in file)
  • package (run all tests in package)
  • name inside of a file (click test to run)

The opa test command doesn't really accomodate any of the above needs, as it'll always run all tests in the files that are loaded. From an editors POV, that'll be all files in the workspace, or all Rego files really. It's possible to workaround this in editors by actually running all the tests, but only presenting the filtered result to the user, making them think that only the tests they asked for got run. It's also possible to use the --run argument to pass a list of regular expressions that should match the name of the tests, but that doesn't take the name of the file or package into account... and a similarly named test could theoretically exist in any number of files without them being logically related.

Suggestion here is to either extend what --run accepts, so that it would be possible to provide something like package/*, file.rego/* or file.reg/test_1, or to introduce another flag for this purpose. Naturally, this would need to work as expected with things like coverage, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant