Repository navigation
fix: the HTML report lists every failed screenshot - #302
Conversation
Reviewer's GuideThe PR fixes HTML reporting for resized screenshots by making frozen null results safely readable and adding dedicated dimension-change entries, while ensuring any per-entry rendering error is always warned about, retained as a failed report entry, and rendered without broken images. Sequence diagram for resilient HTML screenshot reportingsequenceDiagram
participant Assertion
participant HTML
participant Comparison
participant ComparisonResult
participant Report
HTML->>Assertion: compare
Assertion-->>HTML: comparison
HTML->>Comparison: difference
Comparison-->>HTML: different comparison
alt dimensions_changed?
HTML->>Comparison: dimensions_changed?
Comparison-->>HTML: true
HTML->>Comparison: reporter.dimension_change
Comparison-->>HTML: baseline size => current size
HTML->>Report: retain resized failure entry
else report entry raises
HTML->>Report: retain error entry
HTML-->>HTML: warn could not render
else same-size failure
HTML->>ComparisonResult: region_area_size
ComparisonResult-->>HTML: area size
HTML->>Report: retain failure entry
end
HTML->>Report: count entry as failed
Flow diagram for resized and unrenderable report entriesflowchart TD
A[HTML#record assertions] --> B{Comparison available?}
B -- No --> Z[Skip assertion]
B -- Yes --> C{Comparison failed?}
C -- No --> P[Count as passed]
C -- Yes --> D{dimensions_changed?}
D -- Yes --> R[Create resized entry with baseline, current, and dimensions_changed]
R --> H[Render no heatmap or annotations]
D -- No --> E[Build normal failure entry]
E --> F{Entry rendering raises?}
F -- No --> N[Render normal failure]
F -- Yes --> W[Warn unconditionally]
W --> X[Keep error entry and count as failed]
H --> Q[Include in failed total]
N --> Q
X --> Q
Q --> S[Write HTML report]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No actionable issue was identified in the selected change. Merge after the reported rebase and normal CI checks. Pre-merge checks |
|
A screenshot whose capture changed size (Dimensions have changed:
1034x111 => 1040x111) was counted in the run summary but missing from
snap_diff_report.html. Comparison returns a frozen null ComparisonResult
for that case, and ComparisonResult#region_area_size memoized into an
ivar, so the reporter's read of area_size raised FrozenError. #record
rescues per assertion and only warns under DEBUG, so the entry vanished
silently, and the report header counted it as passed (passed is total
minus entries). The same raise hit #to_h and #inspect on every null
result.
region_area_size no longer memoizes: Region#size is two multiplications,
and the result stays frozen as build_null intends.
For a dimension change the entry carries the baseline, the new capture
and dimensions_changed ("WxH => WxH", worded by
Reporters::Default#dimension_change, the same as the failure message).
It links no annotated or heatmap images: none are drawn for
different-sized images, and any on disk are left over from an earlier
same-size failure.
The template says what it shows and why: the entry is badged "resized"
(it showed a green "pass" for any entry without diff images), the
heatmap view explains a missing heatmap (a size change, or an image
driver that produced no difference mask, which only chunky_png does)
and what to do next, and the Annotated toggle
labels plain images as not annotated instead of "Annotated Base/New".
Why the failure was silent is the next commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HTML#record rescues each entry so one bad entry can't sink the whole
report, but it warned only under DEBUG and dropped the entry. Because
passed is total minus entries, the dropped screenshot was counted as
passed: the size-change bug fixed in the previous commit showed up as a
silent pass, not as an error.
The rescue now always warns, in the same shape as Reporting's reporter
warnings, and keeps the screenshot as {name:, error:}. The report shows
it as "could not render" with the error and where to report it, and
counts it as failed: the report can't vouch for it. People reading the
report as a CI artifact never see stderr, so the entry is what tells
them.
The rescue itself stays: a report that refuses to render because of one
entry would be worse.
An entry that raises before its comparison is read is counted in the
total too, so failed can't exceed total. README's "Debug mode" said
DEBUG=1 shows skipped entries; nothing reads DEBUG any more, so it now
describes the always-on warning.
DiffTest's sample cases script a Minitest::Mock comparison for exactly
what verification reads; the global HTML reporter reads past that
script, which used to fail silently and now warns. Those three cases
now run without registered reporters, as reporter_interplay_test does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
726255d to
29e9e21
Compare
|
Rebased on |
A screenshot whose capture changed size fails the test, but it is missing from
snap_diff_report.html, and the report header counts it as passed. Underneath, any error while building a report entry did the same thing, silently unlessDEBUGwas set. This PR fixes both. Two commits, reviewable separately.Before (real run,
rake report:sampleonmaster, with one resized pair added)The test run sees four failures. The report says:
header-resized(80x80 → 80x60) is not listed, and it is counted among the passes. Nothing in the output says why. OnlyDEBUG=1shows it:If every failure in a run is a size change, no report is written at all. A size change is the failure the README warns about ("every comparison then fails with
Dimensions have changed"), so the report drops one of the most common failures. First seen on 2.0.0.beta4 (Ruby 3.4, vips); it's the same onmasterand with chunky_png.Why
For a dimension mismatch,
ComparisonreturnsComparisonResult.build_null(..., {different_dimensions: true}), andbuild_nullfreezes its result.ComparisonResult#region_area_sizememoized:On a frozen instance, that ivar write raises
FrozenError.HTML#failure_entry_forreadsarea_sizefor every failure, so the raise happened there.HTML#recordrescued it per entry, warned only underDEBUG(993bcb9, "DEBUG-only diagnostics"), and dropped the entry.passedistotal - failures.size, so the dropped entry became a pass.The same raise breaks
#to_hand#inspecton every null result: identical files, a missing image, a size change. That's why the message above ends in...: Ruby couldn't inspect the receiver either.Commit 1: the HTML report shows screenshots that changed size
The root:
region_area_sizeno longer memoizes.Region#sizeis two multiplications, so the cache bought nothing, and the result stays frozen asbuild_nullintends. I considered two other options:#to_h/#inspectraising for debuggers, error messages and custom reporters.The entry: a size change says so. With the root fix alone, the entry would come back as
area_size: 0, a green "pass" badge and a broken heatmap. Forcompare.dimensions_changed?the entry now carries the baseline, the new capture anddimensions_changed: "80x80 => 80x60". That wording isReporters::Default#dimension_change, extracted frombuild_error_for_different_dimensions, so the report and the failure message say it the same way. The entry links no annotated or heatmap images.Reporters::Default#generatereturns before annotating different-sized images, so none are drawn, and any.diff.png/.heatmap.diff.pngon disk under that name are left over from an earlier same-size failure.The template: say what is shown, and why.
dimensions changed: 80x80 => 80x60. Sidebar badge:resized. Previously any entry without diff images got a greenpassbadge, although every entry in the report is a failure.<img src="">:Baseline (not annotated)/Current (not annotated), notAnnotated Base/Annotated New.rake report:samplekeeps thatheader-resizedpair (a.png80x80 vsa_cropped.png80x60), so the case stays visible to anyone working on the template.Commit 2: a report error no longer hides the screenshot
The FrozenError was one bug. The silent drop is what made it look like a pass, and it would do the same to the next bug. Since 993bcb9, 2.0 has moved the other way:
Reportingwarns unconditionally ([snap_diff] Reporter X failed (…)), and so doesAISimple([snap_diff:ai] Backend failed for …). So the per-entry rescue inHTML#recordnow:[snap_diff] HTML report: could not render 'checkout' (FrozenError: can't modify frozen …){name:, error:}, counted as failed (and in the total, even if the error comes before its comparison is read), because the report can't vouch for it. The page shows "could not render" and the error, says where to report it, and shows no empty images. This matters most for whoever opens the report as a CI artifact, because they never see stderr.The rescue itself stays: a report that refuses to render because of one entry would be worse. With commit 1 reverted, the resized screenshot shows up through this path, as "could not render (FrozenError …)", instead of disappearing.
The README's "Debug mode" section said
DEBUG=1makes the HTML reporter print why it skipped an entry. Nothing inlib/readsDEBUGany more, so it now describes the always-on warning.DiffTest's three sample cases script aMinitest::Mockcomparison for exactly what verification reads. The globally registered HTML reporter reads past that script, which used to fail silently and now warns. Those three cases now run without registered reporters, using the same pattern asreporter_interplay_test.rb.After (same run)
Not changed
Reporting.notify/finalize!) keep their existing handling. Only the per-entry rescue insideHTML#recordchanged.Evidence
test/unit/difference_test.rb: a frozenbuild_nullresult answersregion_area_size,to_handinspect.test/unit/reporters/html_reporter_test.rb:ComparisonthroughHTML#recordyields one entry withname,original,newanddimensions_changed, andfinalizewrites the report;.diff.png/.base.diff.png/.heatmap.diff.pngon disk are not linked;DEBUG, kept with itserror, counted (2 failed, 0 passed), and the rest of the report still renders;test/unit/reporters/ai_simple_test.rb: the hand-rolledHtmlComparestub ("the exact surface the reporter touches") gainsdimensions_changed?.ComparisonResulttest red withFrozenError … comparison_result.rb:64 in region_area_size.dimensions_changed?turns both size-change reporter tests red.lib/from commit 1 turns its three tests red, and the first reporter test fails exactly as reported:SoleItemExpectedError: no item found.rake test:uniton the branch rebased ontomaster: 774 runs, 0 failures, and nocould not renderlines in the output (Ruby 3.4.11).standardrb: 178 files, no offenses.master, which includes fix: stop blur_active_element clicking inputs, and green selenium_headless on Firefox 157 #301 (onlyCHANGELOG.mdconflicted): fullrakein a container built from the repo's Dockerfile, 815 runs, 0 failures, 1 skip, and nocould not renderlines.Deliberately not here
baseline:/actual:labels. That belongs in a separate, small PR.Reporters::Default#generatedoesn't callclean_tmp_fileson that path). The report no longer links them, and I left the disk alone.failed_by: "missing_image", a String) still raisesTypeErrorinComparison#dimensions_changed?andReporters::Default#generate, which index it like a Hash. That's older than this PR. With this PR such a screenshot shows as "could not render (TypeError …)" instead of vanishing, and#to_h/#inspectwork on it; fixing theTypeErrorbelongs in its own small PR.Summary by Sourcery
Keep every failed screenshot visible and accurately classified in HTML reports, including resized and unrenderable entries.
Bug Fixes:
Enhancements:
Documentation:
Tests:
Summary by CodeRabbit

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was found.Summary
The PR keeps resized screenshots and report-entry errors visible in the HTML report.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Read screenshot comparison] --> B{Entry can be built?} B -->|No| C[Warn and keep error entry] B -->|Yes| D{Screenshot failed?} D -->|No| E[Count as passed] D -->|Yes| F{Image sizes changed?} F -->|Yes| G[Keep baseline, current image, and sizes] F -->|No| H[Keep images and difference metrics] C --> I[Count as failed and write report] G --> I H --> IReviews (2) · Last reviewed commit: "fix: a report error no longer hides the ..." · Reviewed by Greptile