Skip to content

fix(integration): trust unittest exit code, not 'tail -3 | grep ^OK' (false-fail seen on main today) - #443

Merged
joelteply merged 1 commit into
canaryfrom
fix/python-units-trust-exit-code
May 3, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/python-units-trust-exit-code

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Joel pasted main CI showing test_envelope failing while it passed locally. Root cause: the python-units scenario greps the LAST 3 LINES of unittest output for '^OK'. CI's Python emits DeprecationWarning/ResourceWarning lines AFTER the OK marker → tail -3 misses OK → false-fail.

Two real bugs in one:

  1. Pass detection via output parsing is fragile against ANY post-OK noise (warnings, debug prints, cleanup messages). Fix: trust unittest's exit code (python3 test.py returns 0 on pass, non-zero on fail).
  2. Failure mode emitted only '✗ test_X' with no traceback. Debugger can't act. Fix: capture stderr+stdout to tempfile, dump last 30 lines on failure so the actual error reaches CI logs.

Same pattern as airc's 'evidence is for the debugger, not the trash' rule. Same family as my recent jtag chat.log artifact upload (#1012) — make failures actually surface their cause.

🤖 Generated with Claude Code

Pre-fix CI false-failed test_envelope when unittest emitted DeprecationWarning lines after the OK marker — output looked like:

  ..................
  ----------------------------------------------------------------------
  Ran 18 tests in 0.246s

  OK
  /home/runner/.venv/.../resource_warning.py:N: ResourceWarning: ...

`tail -3` captured the last 3 lines (the warning + blank + something), missed the OK marker, scenario_python_units called fail(). Joel hit this on main CI after promote — false-positive failure on a passing test.

Two real bugs in one:
1. Output-parsing for pass detection is fragile against any post-OK noise (warnings, debug prints, etc.). Fix: trust unittest's exit code (0=pass, non-zero=fail).
2. Failure mode emitted only "✗ test_X" with no error context. Debugger can't act. Fix: capture stderr+stdout to tempfile, dump last 30 lines on failure so the actual traceback reaches CI logs.

Both fixes together: false-pass impossible, true-fail actionable. Same pattern as airc's "evidence is for the debugger, not the trash" rule.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 3, 2026 00:49
@joelteply
joelteply merged commit 26d84f3 into canary May 3, 2026
10 checks passed
@joelteply
joelteply deleted the fix/python-units-trust-exit-code branch May 3, 2026 00:50
@joelteply
joelteply removed the request for review from Copilot May 3, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant