Added the fix for bru.runner.stopExecution() while running collection run from tests#8720
Added the fix for bru.runner.stopExecution() while running collection run from tests#8720ravindra-bruno wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughTest execution results now expose whether a test requested execution to stop. The Electron runner consumes this flag to terminate the collection run and avoids emitting the normal completion event afterward, with coverage across NodeVM and QuickJS runtimes. ChangesTest stop-execution propagation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant TestRuntime
participant ElectronRunner
participant WebContents
TestRuntime->>ElectronRunner: return stopExecution
ElectronRunner->>ElectronRunner: set stopRunnerExecution
ElectronRunner->>WebContents: use termination-specific testrun-ended path
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/bruno-electron/src/ipc/network/index.js (1)
2072-2074: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftAdd runner-level regression coverage.
The current tests validate the runtime payload but not that the Electron collection loop stops before executing later requests. Add a behavior-driven runner test that asserts the stop request halts the collection and emits one terminal event. As per coding guidelines, meaningful code changes should add or update high-value behavior-driven tests.
🤖 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 `@packages/bruno-electron/src/ipc/network/index.js` around lines 2072 - 2074, Add runner-level behavior-driven coverage for the collection loop around stopRunnerExecution: simulate a request returning testResults.stopExecution, assert later requests are not executed, and verify exactly one terminal event is emitted. Update the existing runner test suite rather than only testing the runtime payload.Source: Coding guidelines
🤖 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.
Inline comments:
In `@packages/bruno-electron/src/ipc/network/index.js`:
- Around line 2072-2074: Update the stopExecution handling around the test-run
loop and the later testrun-ended emission so a terminated run emits exactly one
event. Make the termination branch the sole owner of that event, and prevent the
post-loop path from emitting another testrun-ended event when
stopRunnerExecution is set.
---
Nitpick comments:
In `@packages/bruno-electron/src/ipc/network/index.js`:
- Around line 2072-2074: Add runner-level behavior-driven coverage for the
collection loop around stopRunnerExecution: simulate a request returning
testResults.stopExecution, assert later requests are not executed, and verify
exactly one terminal event is emitted. Update the existing runner test suite
rather than only testing the runtime payload.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8dab5603-9443-4a7e-bf5c-d26ef6cad05f
📒 Files selected for processing (3)
packages/bruno-electron/src/ipc/network/index.jspackages/bruno-js/src/runtime/test-runtime.jspackages/bruno-js/tests/runtime.spec.js
JIRA: BRU-3342
Fixes : #7928
Problem
The Issue: The built-in scripting method bru.runner.stopExecution() is failing to halt a Bruno collection run when it is invoked specifically within the Tests block of a request.
The Discrepancy: The method works exactly as expected (immediately halting the execution) when called inside either the Pre-Request or Post-Response script blocks. However, in the Tests block, the runner ignores the stop command and incorrectly continues running subsequent lines of code and moving on to the next requests in the collection.
Impact: Automation workflows and test suites cannot be aborted dynamically from the test stage when an unrecoverable assertion or validation failure occurs.
Solution
The Fix: A programmatic fix was introduced to ensure that the collection runner monitors and respects the execution stop signal triggered during the Tests evaluation phase, aligning it with the pre-request and post-response lifecycle hooks.
Contribution Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Tests
stopExecutionbehavior for both NodeVM and QuickJS, including normal completion when not stopped.