Skip to content

fix(test): skip broken opencode shims - #561

Open
ColumbusLabs wants to merge 1 commit into
bmad-code-org:mainfrom
ColumbusLabs:fix/294-probe-opencode-binary
Open

fix(test): skip broken opencode shims#561
ColumbusLabs wants to merge 1 commit into
bmad-code-org:mainfrom
ColumbusLabs:fix/294-probe-opencode-binary

Conversation

@ColumbusLabs

@ColumbusLabs ColumbusLabs commented Aug 12, 2026

Copy link
Copy Markdown

What

Harden the zero-token OpenCode live-test gate so stale or broken shims skip cleanly instead of failing during server startup.

Why

shutil.which() only proves that a path resolves. A dead WSL/npm shim still passed the gate and produced one failure plus four startup errors. Fixes #294.

How

  • Probe opencode --version with a 10-second timeout before enabling the live module.
  • Treat launch errors, timeouts, and nonzero exits as unavailable while preserving the module-level live gate.
  • Add mocked regression coverage for success, nonzero exit, launch failure, and timeout.

Testing

  • uv run pytest tests/test_opencode_http.py -q — 89 passed
  • uv run pytest tests/test_opencode_live.py -q — 5 skipped without OpenCode
  • uv run pytest -q -n auto — 5,048 passed, 78 skipped, 5 xfailed after deselecting three existing macOS undecodable-filename cases that fail unchanged on main
  • trunk check — passed

Summary by CodeRabbit

  • Bug Fixes

    • Improved live OpenCode smoke-test gating by verifying that the installed command runs successfully before tests start.
    • Unavailable, stale, or broken installations are now skipped cleanly, while incompatible runnable installations continue to report failures.
  • Tests

    • Added coverage for successful checks, failed version checks, and command-probe errors.
  • Documentation

    • Added an Unreleased changelog entry describing the updated live-test behavior.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 78881592-c5a6-4d02-9a17-43fca0c2258c

📥 Commits

Reviewing files that changed from the base of the PR and between 26385b4 and ac9d7d4.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • tests/opencode_support.py
  • tests/test_opencode_http.py
  • tests/test_opencode_live.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/test_opencode_live.py
  • tests/test_opencode_http.py
  • CHANGELOG.md

Walkthrough

OpenCode live smoke tests now use a shared availability helper. The helper requires a successful opencode --version probe and handles missing binaries, unsupported platforms, nonzero exits, and probe errors. Tests cover each probe result.

Changes

OpenCode live gate

Layer / File(s) Summary
Version probe gate
tests/opencode_support.py, tests/test_opencode_live.py, CHANGELOG.md
The live-test gate checks that opencode --version succeeds within 10 seconds before enabling OpenCode tests.
Version probe validation
tests/test_opencode_http.py
Tests cover nonzero exits, OSError, timeouts, and successful version probes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: 🔵 Low · up to ac9d7

The PR makes unavailable OpenCode shims skip cleanly, but merge should retain owner awareness for the test helper’s real CLI invocation and for proving that negative cases detect the intended failure modes rather than merely returning false.

Possibly related issues

  • Issue 294 — The changes implement the _opencode_runs() version-probe gate and its broken-shim coverage.

Poem

A rabbit checks the version line,
Then hops past shims that fail to shine.
Good binaries may start and run,
Broken probes are safely done.
Tests guard each path with care.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: skipping broken OpenCode shims in tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
tests/test_opencode_http.py (2)

26-26: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid importing the live-test module for this helper.

Importing test_opencode_live executes its module-level availability probe before these tests run. A targeted pytest tests/test_opencode_http.py run can therefore launch a real probe and wait up to ten seconds. Move _opencode_runs to a side-effect-free test-support module and import it from both test modules.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_opencode_http.py` at line 26, Move the _opencode_runs helper out
of test_opencode_live into a side-effect-free shared test-support module, then
update both test_opencode_http.py and test_opencode_live.py to import it from
that module. Ensure importing the helper does not execute the live-test module’s
availability probe.

55-58: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Assert the version-probe invocation contract.

The subprocess fakes accept all arguments and discard them. These tests pass if the implementation removes --version, removes timeout=10, or changes check=False. Record the call and assert the command, timeout, capture_output=True, and check=False.

As per coding guidelines: “Add new behavior tests at the lowest layer capable of catching the regression: pure-core unit test, then seam test, then sandbox E2E.”

Also applies to: 70-73, 80-82

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_opencode_http.py` around lines 55 - 58, Update the subprocess
fakes in the affected version-probe tests to record invocation arguments instead
of discarding them, then assert the command includes the expected version probe
and that timeout=10, capture_output=True, and check=False are passed. Apply this
to each referenced test while preserving their existing result assertions.

Source: Coding guidelines

tests/test_opencode_live.py (1)

33-37: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Use the executable path returned by shutil.which.

The code checks one PATH resolution, then resolves bare opencode again. If PATH changes between these calls, the probe can execute a different binary than the one checked. Store the result and pass it as argv[0].

Proposed fix
-    if sys.platform == "win32" or shutil.which("opencode") is None:
+    if sys.platform == "win32":
         return False
+    binary = shutil.which("opencode")
+    if binary is None:
+        return False
     try:
         probe = subprocess.run(
-            ["opencode", "--version"], capture_output=True, timeout=10, check=False
+            [binary, "--version"], capture_output=True, timeout=10, check=False
         )

Verify the returned path form on supported POSIX environments.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_opencode_live.py` around lines 33 - 37, Update the opencode
availability check to store the path returned by shutil.which, use that stored
path for the subprocess.run probe’s executable argument, and pass it as argv[0]
rather than resolving the bare “opencode” name again. Preserve the Windows skip
behavior and verify the resolved path form on supported POSIX environments.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/test_opencode_http.py`:
- Line 26: Move the _opencode_runs helper out of test_opencode_live into a
side-effect-free shared test-support module, then update both
test_opencode_http.py and test_opencode_live.py to import it from that module.
Ensure importing the helper does not execute the live-test module’s availability
probe.
- Around line 55-58: Update the subprocess fakes in the affected version-probe
tests to record invocation arguments instead of discarding them, then assert the
command includes the expected version probe and that timeout=10,
capture_output=True, and check=False are passed. Apply this to each referenced
test while preserving their existing result assertions.

In `@tests/test_opencode_live.py`:
- Around line 33-37: Update the opencode availability check to store the path
returned by shutil.which, use that stored path for the subprocess.run probe’s
executable argument, and pass it as argv[0] rather than resolving the bare
“opencode” name again. Preserve the Windows skip behavior and verify the
resolved path form on supported POSIX environments.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e76beba0-5c72-4983-8c20-70240a3c7365

📥 Commits

Reviewing files that changed from the base of the PR and between d0c2f27 and 26385b4.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • tests/test_opencode_http.py
  • tests/test_opencode_live.py

@ColumbusLabs
ColumbusLabs force-pushed the fix/294-probe-opencode-binary branch from 26385b4 to ac9d7d4 Compare August 13, 2026 10:20
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.

opencode live gate: which() finds broken shims — probe that the binary actually runs so a dead install skips instead of failing

1 participant