Skip to content

feat(doubles): dump the recorded calls when a spy assertion fails - #905

Merged
Chemaclass merged 1 commit into
mainfrom
feat/896-dump-spy-call-log-on-failure
Jul 27, 2026
Merged

feat(doubles): dump the recorded calls when a spy assertion fails#905
Chemaclass merged 1 commit into
mainfrom
feat/896-dump-spy-call-log-on-failure

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #896

A failed call assertion printed only the single call it happened to compare against. Working out whether the command was called with other arguments, in another order, or more times than expected took one edit-run-read cycle per guess — while the full call log was already recorded on disk.

💡 Changes

  • Print the spy's recorded calls below the failure for all five call assertions.
  • Cap the dump at 10 entries with an explicit … and N more; nothing extra is printed when the assertion passes.
  • Read the log on the failure path only, via a while read loop, so the per-test fork budget is unaffected; the block is rendered through print_line, so --simple stays a single marker.
  • assert_have_been_called_with_args dumps the per-argument form, keeping boundaries visible.

A failed call assertion showed only the one call it compared against, so
diagnosing it meant guessing between "called with other arguments", "called in
another order" and "called more times than expected" — a full edit-run-read
cycle per guess, when the answer was already on disk in the spy's params file.

Print that log under the failure, capped at 10 entries with an explicit
"and N more" so a spy on a hot command cannot flood the report. The renderer
reads the file with a `while read` loop on the failure path only, so the
per-test fork budget is untouched, and the block goes through print_line like
the rest of the failure so --simple output stays a single marker.

`assert_have_been_called_with_args` renders the per-argument form, keeping the
boundaries visible in the dump too.

Closes #896
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 27, 2026
@Chemaclass Chemaclass self-assigned this Jul 27, 2026
@Chemaclass
Chemaclass merged commit 347f7b3 into main Jul 27, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/896-dump-spy-call-log-on-failure branch July 27, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant