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

opa test exit value is the same for skipped as it is for failures #3773

Closed
kirk-patton opened this issue Sep 1, 2021 · 3 comments
Closed

Comments

@kirk-patton
Copy link
Contributor

I created a unit test prefixed with "todo_" and then ran it with OPA test. As expected, the test was skipped. I checked the exit code and noted it was "2". When I remove the "todo_" and run the test, I get an expected failure. But, the exit value is also "2".

Expected Behavior

I expected some other exit value other that "2".

Actual Behavior

I expected some other value so that it would be possible to allow skipped tests in our CICD pipeline by checking the exit value.

Steps to Reproduce the Problem

  • create a todo_sometest{}
  • opa test -r todo_sometest
  • echo $?
  • rename todo_sometest{} to sometest{}
  • opa test -r sometest
  • echo $?

Additional Info

@tsandall
Copy link
Member

tsandall commented Sep 1, 2021

Thanks for filing this Kirk. I believe the test subcommand exits with status code 2 because of this line.

Changing the exit code to another value if there are no failures and at least one skip sounds reasonable to me. This would encourage people to make all of their tests pass but allow them to handle the exceptional case where some tests have to be skipped.

How does that sound?

@kirk-patton
Copy link
Contributor Author

Perfect 👍

@kirk-patton
Copy link
Contributor Author

I submitted a small PR #3774

dolevf pushed a commit to dolevf/opa that referenced this issue Nov 4, 2021
…t#3774)

When `-z` is passed to `opa test`, skipped tests will not affect
the exit code. (When not passed, skipped tests produce the same
exit code as failed tests.)

Fixes open-policy-agent#3773.

Signed-off-by: Kirk Patton <kpatton@verizonmedia.com>
Signed-off-by: Dolev Farhi <farhi.dolev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants