fix(test): make subagent sleep hook portable on Windows - #13
Merged
Conversation
The `async_subagent_completes_after_launching_exec_process_exits` test
wrote a `pre_model_call` hook running `sleep 0.4`. On Windows the resolved
host shell is PowerShell, where `sleep` aliases `Start-Sleep`, and Windows
PowerShell 5.1 rejects the fractional `0.4` seconds argument (and cmd.exe
has no `sleep` at all). The hook therefore failed and `orca exec` exited
with code 1 instead of 0, panicking the test.
Because every test in this file shares a single static `Mutex`, that first
panic poisoned the lock and cascaded into all 12 tests failing with
`PoisonError`, masking the real cause on the Windows CI gate.
- Emit a platform-specific delay command: `sleep {seconds}` on Unix and
`Start-Sleep -Milliseconds {ms}` (integer, valid on PowerShell 5.1 and 7)
on Windows, mirroring the existing hook idiom in tests/exec_jsonl.rs.
- Recover from a poisoned test lock so a single failure is reported on its
own merits instead of cascading across the whole suite.
Co-authored-by: TRAE CLI <noreply@bytedance.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe test helpers now recover from poisoned mutex locks and generate operating-system-specific pre-model hook sleep commands for Unix and Windows. ChangesSubagent contract test robustness
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Windows CI gate on
mainhas been failing on thesubagent_contracttest binary (all 12 tests reported failed, e.g. run 30501966908).Root cause
async_subagent_completes_after_launching_exec_process_exitswrites apre_model_callhook that runssleep 0.4:pwsh/powershell.exe), wheresleepis an alias forStart-Sleep.Start-Sleeprejects the fractional0.4seconds argument (only PowerShell 6.2+ accepts adouble), andcmd.exehas nosleepat all.orca execexits1instead of0→ the test panics (left: Some(1), right: Some(0)).Because every test in the file shares one
static Mutex, that first panic poisons the lock, cascading into all other tests failing withPoisonErrorand masking the real cause. (Evidence: the suite "finished in 1.70s", proving the 0.4s hook never actually slept.)Fix
sleep {seconds}on Unix andStart-Sleep -Milliseconds {ms}(integer, valid on both PowerShell 5.1 and 7) on Windows, mirroring the existing#[cfg(unix)]/#[cfg(windows)]hook idiom intests/exec_jsonl.rs.Verification
cargo test --test subagent_contract→ 12/12 pass on macOS (host).#[cfg(windows)]branch was compiled in isolation and producesStart-Sleep -Milliseconds 400.x86_64-pc-windows-msvcis blocked locally byring's C toolchain requirement (no Windows C headers on this Mac); the Windows CI gate on this PR is the authoritative check.Summary by CodeRabbit