Skip to content

Make verbose timing output sink injectable (#341)#373

Draft
leynos wants to merge 1 commit into
mainfrom
issue-341-injectable-timing-sink
Draft

Make verbose timing output sink injectable (#341)#373
leynos wants to merge 1 commit into
mainfrom
issue-341-injectable-timing-sink

Conversation

@leynos

@leynos leynos commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #341

VerboseTimingReporter wrote timing summary lines directly to io::stderr() (src/status_timing.rs), bypassing the reporter abstraction and leaving the timing path uncapturable in tests.

Of the approaches the issue offers, this implements the dedicated injected sink:

  • New public TimingSink alias (dyn Fn(&str) + Send + Sync, one rendered line per call) and VerboseTimingReporter::with_sink constructor.
  • new keeps the stderr default via a named stderr_sink, so existing behaviour (accessible, silent, indicatif wrapping) is preserved bit-for-bit.
  • report_complete emits through the injected sink.

Testing

  • New verbose_timing_reporter_routes_summary_through_injected_sink: captures the localised summary (header, stage line, total) through an injected sink with a fake clock — no global stderr involved.
  • Existing timing snapshot/behaviour tests unchanged and green.

Validation

  • make check-fmt / make lint / make test — pass (37 suites)

🤖 Generated with Claude Code

Summary by Sourcery

Inject a configurable sink for verbose timing summaries so timing output no longer writes directly to stderr and can be captured in tests.

New Features:

  • Add public TimingSink type and VerboseTimingReporter::with_sink / with_clock_and_sink constructors to route timing lines to an injectable destination.

Enhancements:

  • Change VerboseTimingReporter to use an injected sink for timing summary lines while preserving stderr as the default sink.

Tests:

  • Add a regression test ensuring verbose timing summary lines are routed through the injected sink and can be captured without using global stderr.

`VerboseTimingReporter` bypassed the reporter abstraction by writing
its timing summary lines straight to `io::stderr()`, creating a second
hard-coded output path that tests and alternative reporters could not
capture.

Introduce an injectable `TimingSink` (one rendered line per call):
`new` keeps the stderr default, while the new `with_sink` constructor
lets callers route the summary anywhere. The accessible, silent, and
indicatif reporter behaviour is unchanged — only the summary's
destination becomes a policy of the constructor.

Add a test that captures the summary through an injected sink without
touching global stderr, alongside the existing behaviour tests.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d12504d7-5743-44ab-a23c-fade762f4357

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-341-injectable-timing-sink

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

@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Makes VerboseTimingReporter’s verbose timing output go through an injectable sink instead of writing directly to stderr, and adds a focused test that captures the timing summary via this new sink using a fake clock.

File-Level Changes

Change Details Files
Make verbose timing output injectable via a TimingSink instead of hard‑wiring stderr, while preserving existing behaviour as the default.
  • Introduce a public TimingSink type alias representing a Send+Sync line-based sink function for timing summaries.
  • Extend VerboseTimingReporter to store a sink field, and route report_complete timing lines through this sink rather than writing directly to stderr.
  • Refactor constructors: new now delegates to with_sink with a default stderr_sink; add with_sink and with_clock_and_sink helpers so tests and alternative reporters can inject both a clock and a sink; keep with_clock (test-only) delegating to stderr_sink.
  • Add a stderr_sink helper that writes each line to process stderr, matching the previous behaviour.
src/status_timing.rs
Add a regression test ensuring timing summaries are routed through an injected sink and are fully capturable without touching global stderr.
  • Add a SilentInner StatusReporter stub that ignores stage and completion events so only timing behaviour is under test.
  • Create verbose_timing_reporter_routes_summary_through_injected_sink test that constructs VerboseTimingReporter with a fake clock and custom sink capturing lines into a shared vector.
  • In the test, drive a single stage and completion, then assert that exactly three lines (header, stage line, total line) are captured and contain the expected localized timing content after normalization.
src/status_timing_tests.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#341 Make verbose timing summary output injectable instead of writing directly to global stderr, so that timing output can be captured by tests and alternative reporters.
#341 Preserve existing behaviour for accessible, silent, and indicatif status reporting when using VerboseTimingReporter by keeping stderr as the default timing sink.
#341 Add tests that cover timing summary output routed through the injected timing sink rather than global stderr.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep verbose timing output behind an injectable reporter sink

1 participant