Skip to content

Exit codes

Code Meaning What to do
0 everything selected ran and passed, or nothing was selected proceed
1 a test failed (for select --exit-code: something was selected) fix the failing tests
2 trimtest itself failed: bad config, no project found, git error read the message; run trimtest check
3 selection is uncertain: a selected test cannot be run by the runner (for select --exit-code: also a changed file no test is known to reach) run the full suite: trimtest run --full

Precedence: 1 outranks 3. A run where a test failed exits 1 even if another selected test could not run, and select --exit-code exits 1 whenever something is selected.

A runner command killed by --timeout counts as a test failure, so it exits 1.

trimtest select --exit-code does not run tests, so use it to gate a step. It exits:

  • 1 when something is selected (even if the selection is also uncertain);
  • 3 when nothing is selected but the selection is uncertain: a selected test cannot be run, or a changed file is not known to affect any test (see on_unobserved);
  • 0 when nothing is selected and nothing is in doubt.
Terminal window
trimtest select --base origin/main --exit-code >/dev/null
case $? in
0) echo "no tests affected" ;;
1) echo "tests are affected" ;;
3) echo "cannot tell: run everything" ;;
*) echo "trimtest failed" ;;
esac

select --json always carries uncertain (a boolean) and uncertain_reasons (a list of strings), whatever the exit code. In text and --paths output the reasons go to stderr as trimtest: uncertain: ....