Skip to content

Test to pass if a specific exit code #25954

Answered by airtower-luna
dgibbs64 asked this question in Actions
Discussion options

You must be logged in to vote

That would be possible by wrapping your test in something that checks the exit code, e.g. a Python script:

import subprocess
import sys
p = subprocess.run(command)
p.returncode != 1:
    print(f'Unexpected return code from {command}: {p.returncode}', file=sys.stderr)
    sys.exit(1)

However, you should only do that if you’re specifically testing error conditions. A successful run of your program should always lead to an error code of zero.

If you want, you can integrate the Python script into the workflow file by setting shell: python on a run step.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants