//donner/svg/renderer/tests:resvg_test_suite uses https://github.com/RazrFalcon/resvg-test-suite to validate Donner's rendering end-to-end. The test suite provides .svg files that can be rendered with the static subset of SVG (and some SVG2), and resvg's golden images to compare against.
To validate against this suite continuously, https://github.com/jwmcglynn/pixelmatch-cpp17 is used to perceptually difference the images and wrap it in a gtest. Execution is single-threaded but it's fast enough to be run in CI, and sufficiently fast to be run as part of inner loop development.
To run the suite:
Or in debug mode:
Since this is a gtest, it will also be run as part of any bazel test targeting this directory:
To run as part of gtest, parameter-driven tests are generated by scanning the suite's category directories and registering one test per .svg file found.
Affected pull requests use resvg_test_suite_default_text for the complete CPU corpus and resvg_test_suite_max_text for text-rendering cases in the full shaping tier. The scoped target includes fixtures with direct, embedded, or linked text outside tests/text/. Full-graph runs exercise the disjoint resvg_test_suite_max_text and resvg_test_suite_max_nontext targets. For a direct invocation of the complete corpus in the full shaping tier, select resvg_test_suite_max explicitly. When using --config=ci for that invocation, add --test_tag_filters= to include the manual target.
The suite has these lanes, each a Bazel wrapper that bazel test //... runs:
| Wrapper | Backend | Text tier | Cases |
|---|---|---|---|
| resvg_test_suite_default_text | TinySkia | simple | all |
| resvg_test_suite_max_text | TinySkia | full | text-rendering |
| resvg_test_suite_max_nontext | TinySkia | full | the rest |
| resvg_test_suite_geode | Geode | simple | all |
| resvg_test_suite_geode_max_text | Geode | full | text-rendering |
The text-rendering cases are //third_party/resvg-test-suite:tests_with_text. Only their output depends on the text tier, so Geode with full shaping runs them alone; the other cases render the same in both tiers, and resvg_test_suite_geode compares them on Geode. Both Geode wrappers run only the GeodeGolden comparisons, as the CPU wrappers of the same cases run the TinyGolden ones. resvg_test_suite_max (manual) is the complete corpus in the full tier on TinySkia, and resvg_test_suite_wgpu_reference_linux (manual) compares the simple tier through the test-only wgpu-native reference.
Generate a deterministic JSON ledger of every vendored case, active or disabled category, skip/render-only state, pixel budget, custom golden, backend mode, text-full gate, and recorded reason:
The generator joins the C++ registration table to the vendored corpus and fails closed on duplicate registrations, unregistered categories, missing overrides, or malformed parameter expressions. //tools/resvg_parity:parity_report_tests verifies parser fixtures and the exact live-tree totals in Bazel runfiles. The report distinguishes explicit pixel-budget sources from effective cases after category defaults are applied, and counts the two render-without-compare buckets separately. The same test fails when a case renders without a comparison through anything but Params::UndefinedBehavior or Params::DeprecatedInSVG2, when an undefined-behavior case's reference is not the resvg UB marker image and the case is not in SPEC_UB_ALLOWLIST, or when a deprecated-in-SVG-2 case is not under a feature in DEPRECATED_IN_SVG2_FEATURES (both in parity_report.py; see the policy below).
The same test also enforces these registration rules, each against a list in parity_report.py:
//tools/resvg_parity:parity_report_tests enforces in CI that each list matches the registry. That the lists only shrink is a review rule: a new entry, or a larger value, needs maintainer approval in the pull request that adds it.
--head-to-head compares Donner with resvg's own recorded results for the same snapshot, the resvg column of third_party/resvg-test-suite/results.csv:
It reports both pass counts, the margin (Donner passes minus resvg passes), a strict Donner count, the cases Donner passes and resvg does not (with resvg's recorded result), and the gap: cases resvg passes and Donner does not, with their state and reason.
A Donner pass is an active case registered to compare, by default or within its recorded settings, that disableBackend does not remove from every comparison mode; the count assumes the comparison tests are green, and a text-full or backend capability gate does not remove a case. It also credits two render-only contract rows listed in RENDER_PASS_CONTRACTS in parity_report.py, filters/feGaussianBlur/huge-stdDeviation and structure/svg/funcIRI-with-invalid-characters, whose reviewed contract is a completed render rather than a pixel match. Other render-only cases and skips are not passes; neither are resvg's unknown or crashed rows.
The strict count takes the compared cases only, so it excludes those two render-only credits, and then excludes every case whose params carry a pixel-budget or threshold call (WithThreshold, WithMaxPixels, withMaxPixelsDifferent, withSimpleTextMaxPixels or withGeodeMaxPixelsDifferent, even when the value equals the default) or a custom golden (WithGoldenOverride or withGeodeGoldenOverride). It still counts cases whose vendored reference is an upstream resvg rendering newer than the snapshot (provenance in third_party/resvg-test-suite/BUILD.bazel), cases whose reference is not 500x500, and cases behind a text-full or backend capability gate.
The rows in QUARTER_PIXEL_EDGE_ALLOWLIST are not strict passes either: their Geode comparison accepts pixels the default comparison counts.
The resvg references sample coverage on four sub-scanlines per pixel: a horizontal edge lands on the nearest quarter-pixel boundary, and an edge pixel with k of its four quarter rows covered is stored as 64 * k (255 when all four are). Donner's CPU renderer samples the same way and matches those edges. Geode computes exact coverage and stores round(255 * f) for the true coverage f, which is within 1/8 of k/4, so the two differ by up to 31.875 + 0.25 * k + 0.5 levels: 33 at k = 3. An edge row covered 0.625 px, as on the references' 1.25 px crosshair, is 192 in the reference and 159 on Geode. On text, whose glyph, decoration and crosshair edges are mostly such pixels, that difference alone can exceed the default 100-pixel budget.
A row whose Geode comparison against its vendored resvg reference exceeds its budget only because of that difference opts in with QuarterPixelEdgeReference() (or .withGeodeQuarterPixelEdgeCoverage() chained onto its other params) in resvg_test_suite.cc and is listed in QUARTER_PIXEL_EDGE_ALLOWLIST. Pixels the rule does not accept still count against the row's unchanged budget. A row that compares against a custom golden may opt in only when the golden is a Donner software renderer rendering listed in the "Quarter-pixel quantized goldens" table of donner/svg/renderer/testdata/golden/README.md: that renderer samples coverage as resvg does, and the table records the measurement. A browser rendering, an area-averaged image or a Geode golden is not quarter-pixel quantized, so its row cannot opt in.
For an opted-in row, the Geode comparison also accepts a pixel pixelmatch counts when:
The vertical-neighbor condition follows the mechanism: a quantized edge row lies between a shape's inside and outside, so a pixel above or below it is empty or fully covered and differs from it. The condition is not limited to horizontal edges. It still accepts:
It rejects a uniform partially covered region two or more rows tall, the first row of a translucent shape directly below an opaque one, pure vertical edges, and the interior of a vertical alpha gradient. On resvg_test_suite_geode, across the 173 rows opted in there, the rule accepts 51,612 pixels on Metal and 51,610 on software Vulkan, and every row passes its unchanged budget.
The rule is part of the canonical comparison (svg_suite::ComparisonOptions::acceptQuarterPixelEdgeCoverage in tools/svg_suite/ImageCompare.h) and is off by default. It never applies to the CPU comparisons, to a comparison against a Geode golden, or to a pixel that is fully covered or empty in either image, and it does not change the pixel budget. The test log reports how many pixels it accepted and their largest alpha difference; the diff image draws them in blue. A row whose Geode comparison passes without the rule leaves the list.
The opt-in applies to both Geode lanes, resvg_test_suite_geode (simple text tier) and resvg_test_suite_geode_max_text (full shaping). The list holds 187 rows: the 173 that need the rule on the simple tier, which need it on the full tier too, and 14 rows that only the full tier renders (13 bidirectional, Arabic and complex-script rows, and text/text/emojis against its recorded Donner golden). On the full tier the rule accepts 55,653 pixels across those 187 rows on software Vulkan (55,657 on Metal), and the largest count it leaves is 91 of 100.
A row whose Geode comparison fails for a cause the edge coverage rule does not cover disables its Geode comparison with disableBackend(RendererBackend::Geode, reason), in both text tiers, and is listed in GEODE_GATE_ALLOWLIST; its CPU comparisons are unchanged. A cause that only the simple tier has uses disableGeodeForSimpleText(reason) instead, so the full-shaping lane still compares the row; the list records which tiers each row disables. The reason names the measured cause, and resvg_test_suite.cc keeps one helper per cause (for example GeodeUnquantizedGoldenGate) so the reason is written once. //tools/resvg_parity:parity_report_tests enforces in CI that the list matches the gated rows and that no other backend is disabled; that the list only shrinks is a review rule.
The results.csv values are manual visual judgments recorded with the snapshot, not a pixel diff, and current upstream resvg may score differently.
Some tests need a different reference, a documented comparison setting, or (for an unimplemented feature) a skip. To do this, per-test params may be specified. A test registration appears as:
getTestsInCategory(category, overrides, defaultParams) scans one category directory under the resvg-test-suite tree (e.g. painting/fill, filters/feBlend, text/text) and registers every .svg it finds. overrides is keyed by the bare filename (with extension) and sets per-test Params (skip, threshold, golden override, …); files not listed use defaultParams. Combine(..., ValuesIn(ActiveComparisonModes())) runs each test under every active comparison mode: one mode on CPU builds (TinyGolden) and two on the Geode build (TinyGolden and GeodeGolden). The former GeodeTinyParity pixel-vs-pixel mode is retired; both backends are independently gated against their reference goldens.
The test name is <SuiteName>/ImageComparisonTestFixture.ResvgTest/<sanitized-filename>, where the filename stem has every non-alphanumeric character replaced by _. For the example above:
StrokeLinecap/ImageComparisonTestFixture.ResvgTest/zero_length_path_with_round_cap
On the Geode build (multiple comparison modes) the mode is appended, for example ..._TinyGolden / ..._GeodeGolden.
Each comparison renders on the canvas its reference image was rendered on, so no registration states a canvas size. The harness reads the PNG header of the image the mode compares with (the vendored PNG, the WithGoldenOverride golden, or in the GeodeGolden mode the withGeodeGoldenOverride golden) and fits the document into the square of the image's longer side, the way resvg renders the suite: most references are 500x500, upstream resvg's newer references are 300x300, and a 2:1 document's 500x250 reference comes from a 500x500 canvas. An explicit .setCanvasSize(w, h) always takes precedence. Render-only cases (Params::UndefinedBehavior, Params::DeprecatedInSVG2) compare with no image and keep the suite's 500x500 canvas. parity_report derives the same canvas for each lane from the PNG header.
A reference that is missing or unreadable fails the case with a message naming the file, rather than rendering at a guessed size. The exception is golden regeneration: with UPDATE_GOLDEN_IMAGES_DIR set, a missing golden is rendered on the canvas of the case's vendored PNG and written, so deleting a Donner-rendered golden and rerunning its row regenerates it. Every golden has its vendored PNG's size except the 800x800 ones (resvg-half-box-blur.png, resvg-all-types-inline-*.png and resvg-complex-graphemes-and-coordinates-list.png), which are resvg renderings of independent scenes; regenerate those with the resvg commands in the golden README, not with UPDATE_GOLDEN_IMAGES_DIR, which would write them at their rows' 500x500 size. A new case whose vendored PNG is missing too needs an explicit .setCanvasSize(w, h).
To run a single test:
If a test is skipped, it is still useful to manually run it without editing resvg_test_suite.cc. Params::Skip(...) prefixes the generated gtest name with DISABLED_. Run those tests with gtest's disabled-test flag and a narrow filter; text-full-only tests still require a text-full build.
To run a skipped test:
With suffix-matching, the same test identifier can be used.
When tests fail, follow this systematic approach to triage and document them:
First, identify which tests are failing:
Look for tests marked as FAIL and note the pixel difference count. Tests pass if the count of pixels whose color difference exceeds the threshold (default 0.02) is within the pixel budget (default 100 pixels).
When a test fails, the framework provides detailed diagnostic information:
When a test fails, it re-renders with verbose logging showing:
This shows:
The complete SVG source is printed inline:
Look for:
On failure, three PNGs are written to $TEST_UNDECLARED_OUTPUTS_DIR (Bazel exposes this under bazel-testlogs/.../test.outputs/), named after the sanitized test:
actual (Donner's output): what the renderer currently produces.
expected (golden reference): the resvg-test-suite PNG for this test, from the bazel runfiles directory, generated by resvg.
diff (visual comparison): highlights where actual and expected differ — red/orange pixels mark differing pixels, colored outlines mark positional differences.
What to look for:
Based on the output, determine what's causing the failure:
Check the SVG source (printed in test output):
Compare images:
Review verbose output:
Common failure categories:
Deprecated in SVG 2: The case exercises a feature SVG 2 removed or deprecated and Donner deliberately does not implement (see docs/unsupported_svg1_features.md); Params::DeprecatedInSVG2(reason) renders without a comparison. A removed feature with a UB marker reference belongs here.
Nothing else renders without a comparison, and a case that passes the default comparison compares.
Add the test to the appropriate INSTANTIATE_TEST_SUITE_P block with params and a reason. For an approved skip of an unimplemented feature:
Skip reason formats. A new skip uses only the first form. The second is the form of the one skip already in SKIP_ALLOWLIST, kept until it is fixed; do not add new ones:
Other reason formats:
Within a category's override map, group the entries by reason with a short comment so the gaps read at a glance:
Each resvg category is its own getTestsInCategory(...) block, so a feature that shows up in more than one category (e.g. text/font-weight and painting/fill) is tracked once per category, not in a shared list.
After adding skips, verify tests run correctly:
You should see:
The resvg-test-triage MCP server provides automated test analysis. When available, use it to:
Batch analyze test failures:
Analyze individual tests:
Get implementation guidance (NEW):
Find related tests for batch implementation (NEW):
Track feature progress (NEW):
Analyze visual differences (NEW):
Setup:
Benefits:
See resvg-test-triage README for full documentation.