Skip to content

Lock down the CLI summary output with tests - #1235

Merged
trunk-io[bot] merged 2 commits into
mainfrom
dylan/trunk-22399-add-tests-that-lock-down-the-current-cli-summary-output
Oct 29, 2026
Merged

trunk-io[bot] merged 2 commits into
mainfrom
dylan/trunk-22399-add-tests-that-lock-down-the-current-cli-summary-output

Conversation

@dfrankland

@dfrankland dfrankland commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Adds tests that compare the plain-text summary for upload, validate and ErrorReport, line by line. The upcoming refactors that build these summaries as data, separate from rendering, can use them to show the output doesn't change. No output code changes.

The tests live in one integration test crate, cli/tests/summary/, with a file each for upload, validate and ErrorReport. Run them with cargo test -p trunk-analytics-cli --test summary. Each type goes through one helper: upload_summary, validate_summary or error_summary. When EndOutput is replaced, only those helpers should need to change.

Changes outside the tests.

  • report_limiting is now pub mod, so the tests can set ValidationReport::Full and None.
  • The existing ErrorReport output test moves into the new crate, and now checks every line instead of the first four.

What's covered.

  • Upload outcomes: a passing run, no tests found, all failures quarantined, some not quarantined, a non-zero exit code with no failures.
  • Upload errors: a failed quarantine lookup, an unauthorized error that stops quarantining, and a client error the run continues past.
  • The upload line: a collection link (with a GUID test link), the collection short link, --hide-test-collection-links, and no bundle upload ID at all.
  • Failure tables: grouped by file, by suite and with neither; more than 3 failures in a group; long failure messages with --show-failure-messages.
  • --validation-report limited, full and none, and every file correct.
  • validate, run on fixture files in cli/test_fixtures/summary/: a file that can't be parsed, an empty file, a file with two reports, test issues, a CODEOWNERS file with a warning, and a BEP file with a parse error.
  • ErrorReport: connection refused, unauthorized, a client error explanation, a generic error, an interrupting error, and each exit-code line.

The validate tests run run_validate instead of building a ValidateRunResult, whose fields are private. Every fixture file has at least a missing-timestamp warning, since a fixed timestamp goes stale, so no case has a valid file. The CODEOWNERS path is printed in full, so the helper replaces the crate directory with <cli>. The BEP fixture has no .json extension because it is malformed, and prettier only skips cli/test_fixtures/*.json.

Today's output, asserted as-is. Some expected lines look wrong because the output is wrong today. They are left alone here:

  • In upload's validation section, a JUnit file that fails to parse is counted under "with issues", but it is never listed.
  • In the limited report, files without issues count toward the 8-file limit, so they can push a file with issues into "…and N more". Issues past 8 in a file are dropped without a note.
  • --validation-report none still prints a blank line.
  • An error that reaches main says "using quarantining exit code", but the CLI exits 0.
  • An error with a cause chain is printed on one line with the newlines removed (…was foundCaused by: expected…).

Two tests expect TRUNK_PUBLIC_API_ADDRESS and RUST_BACKTRACE to be unset, as they are in CI. The unauthorized hint reads the API host from the environment, and validate prints a parse failure with {:?}, which includes a backtrace when one is captured.

Testing.

  • cargo test -p trunk-analytics-cli --test summary: 29 pass.
  • cargo test -p trunk-analytics-cli --lib: 23 pass.
  • cargo clippy -p trunk-analytics-cli --all-targets: no warnings in the new code.
  • trunk check on the new and changed files: no issues.

🤖 Generated with Claude Code

@trunk-io

trunk-io Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@codecov-commenter

codecov-commenter commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.17647% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.25%. Comparing base (2da0f15) to head (5976f94).

Files with missing lines Patch % Lines
cli/src/upload_command.rs 91.17% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1235      +/-   ##
==========================================
+ Coverage   84.43%   85.25%   +0.82%     
==========================================
  Files          78       78              
  Lines       18633    18613      -20     
==========================================
+ Hits        15732    15868     +136     
+ Misses       2901     2745     -156     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trunk-staging-io

trunk-staging-io Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

Failed Test Failure Summary Logs
pending_quarantine_test should be quarantined when run with variant A test marked as pending was expected to fail but unexpectedly passed. Logs ↗︎
variant_quarantine_test should be quarantined when run with variant The test failed because it expected 2 + 2 to equal 5, but the result was 4. Logs ↗︎
multiple_exception_error_test nested context with multiple failures multiple expectations that fail The aggregated test failed because three expectations did not match and an additional RuntimeError was raised. Logs ↗︎
multiple_exception_error_test with before and after hook failures test execution with hook errors The test failed because both its before and after hooks raised errors, and RSpec could not match the failure to a backtrace line. Logs ↗︎

... and 3 more

View Full Report ↗︎ ⋅ Docs

Comment thread cli/tests/summary/error_report.rs
Comment thread cli/tests/summary/main.rs

@acatxnamedvirtue acatxnamedvirtue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice

@dfrankland
dfrankland force-pushed the dylan/trunk-22399-add-tests-that-lock-down-the-current-cli-summary-output branch from a6f5c8a to d4fd1e7 Compare October 27, 2026 20:42
@dfrankland
dfrankland added this pull request to stack #1268 October 28, 2026 15:54
dfrankland and others added 2 commits October 28, 2026 20:57
Adds tests that compare the plain-text summary line by line for upload,
validate and ErrorReport, so the summary-as-data refactors (TRUNK-22401,
TRUNK-22402) can show they change nothing. Each type goes through one
helper (upload_summary, validate_summary, error_summary), which is the
only thing those refactors should need to change.

Refs TRUNK-22399

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The lock-down tests move from src/ into one integration test crate,
cli/tests/summary, with a file each for upload, validate and ErrorReport.
The existing ErrorReport output test moves with them and now checks every
line. report_limiting becomes public so the tests can set
--validation-report.

The validate tests now run run_validate on fixture files instead of
building ValidateRunResult, whose fields are private.

Refs TRUNK-22399

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@dfrankland
dfrankland force-pushed the dylan/trunk-22399-add-tests-that-lock-down-the-current-cli-summary-output branch from d4fd1e7 to 5976f94 Compare October 28, 2026 21:28
@trunk-io
trunk-io Bot merged commit ef06742 into main Oct 29, 2026
51 of 55 checks passed
@trunk-io

trunk-io Bot commented Oct 29, 2026

Copy link
Copy Markdown

This pull request was merged into main as part of stacked PR 1265.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants