Skip to content

fix(tests): stabilize plugin and doctor tests for Docker/act (#238)#242

Merged
qhkm merged 1 commit into
mainfrom
fix/docker-test-mismatch
Mar 4, 2026
Merged

fix(tests): stabilize plugin and doctor tests for Docker/act (#238)#242
qhkm merged 1 commit into
mainfrom
fix/docker-test-mismatch

Conversation

@qhkm
Copy link
Copy Markdown
Owner

@qhkm qhkm commented Mar 4, 2026

Summary

  • Skip test_execute_binary_not_executable when running as root (UID 0) — root bypasses file execute permission checks on Linux, causing the test to pass when it should fail
  • Broaden spawn-failure error assertions in test_execute_spawn_failure and test_chat_spawn_failure to accept OS-level error text alongside our wrapped message
  • Use longer random binary name in test_check_binary_missing to avoid PATH collisions in unusual environments
  • Add Debug derive to DiagItem for better assertion messages

Root Cause Analysis

Test Root Cause
test_execute_binary_not_executable Docker runs as root → root ignores execute permission bits
test_execute_spawn_failure Error message format may differ across Docker/act environments
test_chat_spawn_failure Same as above
test_check_binary_missing Defensive fix — longer name prevents collisions

Test plan

  • All 4 affected tests pass locally
  • Full cargo test --lib passes (2918 tests)
  • cargo clippy -- -D warnings clean
  • cargo fmt -- --check clean

Closes #238

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests

    • Improved test reliability across different runtime environments, including containerized and CI setups.
    • Enhanced error handling to be platform-agnostic across diagnostic and plugin tooling tests.
    • Strengthened test stability in restricted runtime contexts.
  • Refactor

    • Added enhanced debugging support to diagnostic tools.

…ents

- Skip test_execute_binary_not_executable when running as root (UID 0)
  since root bypasses file execute permission checks on Linux
- Broaden spawn-failure error assertions to accept OS-level error text
  in addition to our wrapped message
- Use longer random binary name in doctor test to avoid collisions
- Add Debug derive to DiagItem for better test failure messages

Closes #238

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Three files updated to stabilize tests across local and Docker/Act environments. Changes include adding Debug derive to DiagItem, accepting flexible error messages in spawn failure assertions, and adding root-aware test guards to skip permission-related tests when running as root.

Changes

Cohort / File(s) Summary
Test Error Message Flexibility
src/providers/plugin.rs, src/tools/binary_plugin.rs
Modified test_chat_spawn_failure and test_execute_spawn_failure to accept either "Failed to spawn" or "No such file" error messages, accommodating OS-level variations across environments.
Root-Aware Test Guards
src/tools/binary_plugin.rs
Added Unix-only is_root() helper and skip guard in test_execute_binary_not_executable to prevent false negatives when tests run as root in Docker-like environments.
DiagItem Debug Derive & Test Name Uniqueness
src/cli/doctor.rs
Added #[derive(Debug)] to public DiagItem struct and updated test_check_binary_missing to use a random-looking binary name for reduced collision risk.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Tests now wiggle-hop with grace,
Root checks and messages embrace,
Docker, Act, and local too,
All environments work through!
Derive and guards now save the day,
Unstable tests skip away! 🎉

🚥 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 'fix(tests): stabilize plugin and doctor tests for Docker/act' accurately describes the main objective of the PR—fixing environment-specific test failures in Docker/act environments.
Linked Issues check ✅ Passed All changes directly address the failing tests identified in issue #238: skip root execution permission test, broaden error assertions for environment differences, extend binary name to prevent collisions, and add Debug derive to improve diagnostics.
Out of Scope Changes check ✅ Passed All changes are directly scoped to stabilizing the four failing tests: test_execute_binary_not_executable, test_execute_spawn_failure, test_chat_spawn_failure, and test_check_binary_missing. No unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/docker-test-mismatch

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/tools/binary_plugin.rs (1)

282-294: LGTM!

The is_root() helper is well-implemented with proper error handling. The docstring clearly explains why this check is needed for Docker environments.

💡 Optional: Consider using libc::getuid() for a lighter-weight check

The current implementation spawns a process, which is fine for test code. If you ever want to avoid the process spawn overhead, you could use:

#[cfg(unix)]
fn is_root() -> bool {
    // SAFETY: getuid() is always safe to call
    unsafe { libc::getuid() == 0 }
}

This is purely optional since the current implementation is correct and clear.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/tools/binary_plugin.rs` around lines 282 - 294, Replace the current
process-spawn implementation of is_root() with a direct UID check to avoid
overhead: update the #[cfg(unix)] fn is_root() to call libc::getuid() (unsafe
block) and return true when it equals 0, keeping the docstring and cfg intact;
this changes the check from using std::process::Command::new("id") to using
unsafe { libc::getuid() == 0 } while preserving behavior and error handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/tools/binary_plugin.rs`:
- Around line 282-294: Replace the current process-spawn implementation of
is_root() with a direct UID check to avoid overhead: update the #[cfg(unix)] fn
is_root() to call libc::getuid() (unsafe block) and return true when it equals
0, keeping the docstring and cfg intact; this changes the check from using
std::process::Command::new("id") to using unsafe { libc::getuid() == 0 } while
preserving behavior and error handling.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3884e12c-3650-49e8-b2ee-42d5f9f2fa8c

📥 Commits

Reviewing files that changed from the base of the PR and between e782488 and 234f855.

📒 Files selected for processing (3)
  • src/cli/doctor.rs
  • src/providers/plugin.rs
  • src/tools/binary_plugin.rs

@qhkm qhkm merged commit b78a3fe into main Mar 4, 2026
8 checks passed
@qhkm qhkm deleted the fix/docker-test-mismatch branch March 4, 2026 06:49
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.

chore: investigate Docker/act test mismatch for plugin and doctor tests

1 participant