fix(tests): stabilize plugin and doctor tests for Docker/act (#238)#242
Conversation
…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>
📝 WalkthroughWalkthroughThree 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (3)
src/cli/doctor.rssrc/providers/plugin.rssrc/tools/binary_plugin.rs
Summary
test_execute_binary_not_executablewhen running as root (UID 0) — root bypasses file execute permission checks on Linux, causing the test to pass when it should failtest_execute_spawn_failureandtest_chat_spawn_failureto accept OS-level error text alongside our wrapped messagetest_check_binary_missingto avoid PATH collisions in unusual environmentsDebugderive toDiagItemfor better assertion messagesRoot Cause Analysis
test_execute_binary_not_executabletest_execute_spawn_failuretest_chat_spawn_failuretest_check_binary_missingTest plan
cargo test --libpasses (2918 tests)cargo clippy -- -D warningscleancargo fmt -- --checkcleanCloses #238
🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Refactor