Repository navigation
refactor(e2e): centralize timeout/gtimeout handling into e2e-timeout.sh - #2368
Conversation
Extract the duplicated timeout detection, self-wrap, and run_with_timeout() code from 10 E2E test scripts into a single shared helper (e2e-timeout.sh). Each script now sets NEMOCLAW_E2E_DEFAULT_TIMEOUT and sources the helper, preserving the per-script default while eliminating ~270 lines of identical boilerplate introduced in PR #2162. No behavioral changes — the timeout detection order, self-wrap logic, error message, and run_with_timeout() semantics are identical to the inlined versions they replace.
📝 WalkthroughWalkthroughThis pull request consolidates duplicate timeout handling logic from 10 E2E test scripts into a new shared utility module. Each test script previously contained its own timeout detection, wrapping, and command execution logic. The refactor extracts these common patterns to a centralized Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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 docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/e2e/e2e-timeout.sh (1)
35-41: Hardening re-exec against CWD/PATH assumptions — optional but recommended.Line 41 re-execs
"$0"directly. While all scripts are executable (100755) and invoked withbash, explicitly usingbash "$0"is more defensive and matches the pattern already present elsewhere in the codebase (e.g.,test/e2e/e2e-cloud-experimental/expect-interactive-install.sh).🔧 Suggested hardening
- exec "$TIMEOUT_CMD" -s TERM "$TIMEOUT_SECONDS" "$0" "$@" + exec "$TIMEOUT_CMD" -s TERM "$TIMEOUT_SECONDS" bash "$0" "$@"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/e2e/e2e-timeout.sh` around lines 35 - 41, The re-exec line using "$0" assumes the caller is directly executable; to harden against CWD/PATH assumptions, change the exec invocation so it explicitly runs the script via bash rather than relying on "$0" being executable — update the exec that uses TIMEOUT_CMD, NEMOCLAW_E2E_TIMEOUT_WRAPPED, TIMEOUT_SECONDS and "$@" to invoke bash with the script ("$0") as the interpreter (e.g., call bash with the script path) so the timeout wrapper runs the caller under an explicit shell interpreter.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/e2e/e2e-timeout.sh`:
- Around line 35-41: The re-exec line using "$0" assumes the caller is directly
executable; to harden against CWD/PATH assumptions, change the exec invocation
so it explicitly runs the script via bash rather than relying on "$0" being
executable — update the exec that uses TIMEOUT_CMD,
NEMOCLAW_E2E_TIMEOUT_WRAPPED, TIMEOUT_SECONDS and "$@" to invoke bash with the
script ("$0") as the interpreter (e.g., call bash with the script path) so the
timeout wrapper runs the caller under an explicit shell interpreter.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 310583bd-67f3-4009-9565-5ff43a43ca25
📒 Files selected for processing (11)
test/e2e/e2e-timeout.shtest/e2e/test-deployment-services.shtest/e2e/test-double-onboard.shtest/e2e/test-inference-routing.shtest/e2e/test-network-policy.shtest/e2e/test-onboard-resume.shtest/e2e/test-sandbox-operations.shtest/e2e/test-sandbox-survival.shtest/e2e/test-shields-config.shtest/e2e/test-skip-permissions-policy.shtest/e2e/test-token-rotation.sh
Summary
Centralize the duplicated timeout/gtimeout detection, self-wrap, and run_with_timeout() code from 10 E2E test scripts into a single shared helper (test/e2e/e2e-timeout.sh). PR #2162 introduced ~31 identical lines in every script;
this extracts them into one place and replaces each copy with a 4-line source stanza, removing ~210 lines of boilerplate with no behavioral changes.
Related Issue
Follow-up to #2162.
Changes
Type of Change
Verification
AI Disclosure
────────────────────────────────────────────────────────────────────────────────
Signed-off-by: Brandon Pelfrey [email protected]
Summary by CodeRabbit