Skip to content

fix/902 --bail flag not stopping execution when a test fails#8103

Open
sharan-bruno wants to merge 6 commits into
usebruno:mainfrom
sharan-bruno:fix/bail_flag_not_stopping-execution_when_a_test_fails_in_a_CSV_file
Open

fix/902 --bail flag not stopping execution when a test fails#8103
sharan-bruno wants to merge 6 commits into
usebruno:mainfrom
sharan-bruno:fix/bail_flag_not_stopping-execution_when_a_test_fails_in_a_CSV_file

Conversation

@sharan-bruno
Copy link
Copy Markdown
Contributor

@sharan-bruno sharan-bruno commented May 26, 2026

Description

CLI run command now prints a cli-table3 execution summary table and handles --bail cleanly:

New 📊 Execution Summary table with Status / Requests / Tests / Assertions / Duration columns.
Requests cell breaks down counts inline, e.g. 4 (1 Passed, 1 Failed, 2 Skipped (Bail)).
On --bail, the run synthesizes skipReason: 'bail' placeholder results for remaining requests so they're counted as skipped, and prints an inline orange notice:
Bail: Stopping run, test failure in "2nd API". Remaining 2 request(s) skipped.

Before:
image

After
image

Adds cli-table3 dependency to print the table similar to golden edition.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • Execution summary now displays as a formatted table with passed, failed, skipped, and duration metrics.
    • Added a distinct "Skipped (Bail)" count to show items skipped due to bail and a clear bail reason in run output.
  • Chores

    • Added a runtime dependency to support table formatting in CLI output.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 04089cf2-4590-4403-a64a-c82e5a2b37d4

📥 Commits

Reviewing files that changed from the base of the PR and between a84c065 and 3272c05.

📒 Files selected for processing (3)
  • packages/bruno-cli/src/commands/run.js
  • packages/bruno-common/src/runner/runner-summary.ts
  • packages/bruno-common/src/runner/types/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-cli/src/commands/run.js

Walkthrough

Displays a table-based execution summary, adds an ORANGE color constant and the cli-table3 dependency, and synthesizes skipped results when --bail triggers so the summary shows "Skipped (Bail)" counts.

Changes

Execution Summary with Bail Reporting

Layer / File(s) Summary
Color constant and table dependency
packages/bruno-cli/src/constants.js, packages/bruno-cli/package.json
Adds COLORS with ORANGE: '#FFA500' and adds cli-table3 (^0.6.5) as a runtime dependency.
Summary table formatting helpers
packages/bruno-cli/src/commands/run.js
Imports Table from cli-table3, replaces the text summary with table-based printRunSummary and helpers that compute requests/pass/fail/skipped counts and return the runner summary augmented with skippedByBail.
Bail handling and result synthesis
packages/bruno-cli/src/commands/run.js
Initializes bailInfo, extends --bail logic to determine a bailReason, synthesize placeholder skipped results for remaining requests marked with skipReason: 'bail', populate bailInfo (bailedAt, skippedByBail), and print an orange bail message before stopping the run.
Runner summary and types
packages/bruno-common/src/runner/runner-summary.ts, packages/bruno-common/src/runner/types/index.ts
Adds skippedByBail counter to getRunnerSummary return shape and increments it for results with skipReason === 'bail'; extends T_RunnerRequestExecutionResult with skipReason?: string and T_RunSummary with skippedByBail: number.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • usebruno/bruno#6780: Both PRs modify packages/bruno-cli/src/commands/run.js to incorporate skipped results in the run flow and summary output.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • sid-bruno

Poem

🍊 When bail rings out, the runner stalls,
A table tallies passes, fails, and falls.
Skipped rows sprout where work was stalled,
Orange flags flash where bail was called.
The summary sings of runs recalled.

🚥 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 clearly describes the main fix: implementing the --bail flag to stop execution when a test fails, which aligns with the primary changes in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@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.

Actionable comments posted: 2

🤖 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-cli/package.json`:
- Line 62: The repo's lockfile is out of sync after adding "cli-table3" to
packages/bruno-cli/package.json; run npm install from the repository root to
regenerate package-lock.json (ensuring the new dependency is resolved into the
lock), verify the updated package-lock.json includes the "cli-table3" entry, and
commit and push the updated lockfile so CI can pass.

In `@packages/bruno-cli/src/commands/run.js`:
- Around line 729-744: The bail placeholder objects pushed in the remainingItems
loop are missing required fields (test, request, iterationIndex) causing
reporters like JUnit to crash; update the object created in that loop inside
run.js so it matches the skipped shape used by createSkippedFileResults: include
iterationIndex (e.g., 0 or same default used elsewhere), a request object with
the same empty/default structure as createSkippedFileResults, and a test object
containing filename set from ri.pathname (or ri.name as appropriate) so
reporters can safely access result.test.filename and result.request.url.
🪄 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: 8fa99dcf-5ac2-41ff-8fa4-0c30d22dbb50

📥 Commits

Reviewing files that changed from the base of the PR and between 809f951 and 90dc2c4.

📒 Files selected for processing (3)
  • packages/bruno-cli/package.json
  • packages/bruno-cli/src/commands/run.js
  • packages/bruno-cli/src/constants.js

Comment thread packages/bruno-cli/package.json
Comment thread packages/bruno-cli/src/commands/run.js
Comment thread packages/bruno-cli/src/commands/run.js
Copy link
Copy Markdown
Collaborator

@bijin-bruno bijin-bruno left a comment

Choose a reason for hiding this comment

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

Please update package-lock file

Comment thread packages/bruno-cli/src/constants.js Outdated

const CLI_EPILOGUE = `Documentation: https://docs.usebruno.com (v${version})`;
const CLI_VERSION = version;
const ORANGE_COLOR = '#FFA500';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it is better to export a COLORS object rather than exporting individual colors.

const COLORS = { 
  ORANGE: '#FFA500'
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion. I removed ORANGE_COLOR and am now accessing it through the color object

Copy link
Copy Markdown
Contributor

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-cli/src/commands/run.js (1)

693-699: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Double hrtime call introduces timing drift.

process.hrtime(start) is invoked twice, returning slightly different values each time. Store the result once for accurate duration.

Proposed fix
+      const elapsed = process.hrtime(start);
       results.push({
         ...result,
-        runDuration: process.hrtime(start)[0] + process.hrtime(start)[1] / 1e9,
+        runDuration: elapsed[0] + elapsed[1] / 1e9,
         suitename: pathname.replace('.bru', ''),
         name,
         path: result.test?.filename || path.relative(collectionPath, pathname)
       });
🤖 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-cli/src/commands/run.js` around lines 693 - 699, The
runDuration calculation in the results.push block calls process.hrtime(start)
twice (in runDuration: process.hrtime(start)[0] + process.hrtime(start)[1] /
1e9) which can cause small timing drift; capture the hrtime result once into a
local variable (e.g., hr = process.hrtime(start)) and compute runDuration from
hr[0] and hr[1] before pushing the object in results.push so runDuration uses
the single consistent measurement; update the block that constructs the pushed
object (referencing results.push, runDuration, and start) to use that stored hr
value.
🤖 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.

Outside diff comments:
In `@packages/bruno-cli/src/commands/run.js`:
- Around line 693-699: The runDuration calculation in the results.push block
calls process.hrtime(start) twice (in runDuration: process.hrtime(start)[0] +
process.hrtime(start)[1] / 1e9) which can cause small timing drift; capture the
hrtime result once into a local variable (e.g., hr = process.hrtime(start)) and
compute runDuration from hr[0] and hr[1] before pushing the object in
results.push so runDuration uses the single consistent measurement; update the
block that constructs the pushed object (referencing results.push, runDuration,
and start) to use that stored hr value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: af89a3d3-a9c1-4956-9d8a-49c31798d0b6

📥 Commits

Reviewing files that changed from the base of the PR and between a44db21 and f101266.

📒 Files selected for processing (2)
  • packages/bruno-cli/src/commands/run.js
  • packages/bruno-cli/src/constants.js

@sharan-bruno
Copy link
Copy Markdown
Contributor Author

Please update package-lock file

done, updated

Copy link
Copy Markdown
Contributor

@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)
packages/bruno-cli/src/commands/run.js (1)

761-766: 💤 Low value

bailInfo is assigned but never used.

This variable is populated with bail metadata but isn't read, returned, or passed anywhere afterward. Consider removing it or utilizing it if intended for future features.

♻️ Proposed removal if not needed
-          bailInfo = {
-            bailed: true,
-            bailReason,
-            bailedAt: name,
-            skippedByBail: remainingItems.length
-          };

Also remove the declaration at line 662: let bailInfo = null;

🤖 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-cli/src/commands/run.js` around lines 761 - 766, The variable
bailInfo is being assigned but never used; either remove the unused declaration
and assignment or wire it into the function's output/callback so the metadata is
consumed. Locate the bailInfo declaration (let bailInfo = null) and the later
assignment where bailInfo = { bailed: true, bailReason, bailedAt: name,
skippedByBail: remainingItems.length } and either delete both lines (and any
dead-code dependent on it) or modify the surrounding function to return or emit
this bailInfo (e.g., include it in the resolved object or pass it to the
existing result/emit path) so the metadata is actually consumed. Ensure no other
references to bailInfo remain after removal.
🤖 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.

Nitpick comments:
In `@packages/bruno-cli/src/commands/run.js`:
- Around line 761-766: The variable bailInfo is being assigned but never used;
either remove the unused declaration and assignment or wire it into the
function's output/callback so the metadata is consumed. Locate the bailInfo
declaration (let bailInfo = null) and the later assignment where bailInfo = {
bailed: true, bailReason, bailedAt: name, skippedByBail: remainingItems.length }
and either delete both lines (and any dead-code dependent on it) or modify the
surrounding function to return or emit this bailInfo (e.g., include it in the
resolved object or pass it to the existing result/emit path) so the metadata is
actually consumed. Ensure no other references to bailInfo remain after removal.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2256a15f-2dd7-44b4-ad09-332fd68a892f

📥 Commits

Reviewing files that changed from the base of the PR and between f101266 and a84c065.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • packages/bruno-cli/src/commands/run.js

if (totalPreRequestTests > 0) {
preRequestTestSummary = formatTestSummary('Pre-Request Tests:', maxLength, passedPreRequestTests, failedPreRequestTests, totalPreRequestTests);
}
const summary = getRunnerSummary(results);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the summary should already get bail information extracted using getRunnerSummary method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed now its coming from getRunnerSummary(results)

request: T_EmptyRequest | T_Request;
response: T_EmptyResponse | T_Response | T_SkippedResponse;
status: null | undefined | string;
skipReason?: string;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we are missing skipped: boolean here. skipReason should coexist with skipped property.

preRequestTestResults: [],
postResponseTestResults: [],
runDuration: 0,
suitename: ri.pathname.replace('.bru', ''),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this handing yml collections?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants