test: HWPX SVG snapshot regression harness (closes #173)#181
Open
seunghan91 wants to merge 1 commit intoedwardkim:mainfrom
Open
test: HWPX SVG snapshot regression harness (closes #173)#181seunghan91 wants to merge 1 commit intoedwardkim:mainfrom
seunghan91 wants to merge 1 commit intoedwardkim:mainfrom
Conversation
Adds a pure-Rust integration test that renders pages via `HwpDocument::render_page_svg_native` and diffs the output against committed golden SVGs. Runs under the existing `cargo test` job in ci.yml, so no new workflow is required and the check is active on every PR without any Hancom-Office / Windows dependency. ## Highlights - `tests/svg_snapshot.rs` — harness with `UPDATE_GOLDEN=1` regeneration (same pattern used in the MDM project's `golden_hwpx.rs`). - First golden: `form-002.hwpx` page 0 — the smallest committed sample (~130KB input → ~263KB SVG). More goldens can be added file-by-file without harness changes. - Determinism probe: `render_is_deterministic_within_process` renders the same page twice in a single process and asserts byte equality, so any future non-determinism bug surfaces loudly instead of masquerading as a golden mismatch. ## Verification - Byte-identical across two separate CLI invocations: `rhwp export-svg samples/hwpx/form-002.hwpx -o /tmp/a -p 0` vs `... -o /tmp/b -p 0` → `diff -q /tmp/a /tmp/b` returns empty. - `cargo test --test svg_snapshot` passes locally. ## Follow-up (not in this PR) - Expand golden corpus to the 2024/2025 investment samples once the first run is green on CI. - Consider gzip-encoding large goldens if the corpus grows past a few MB. For now, raw SVG plays nicely with git diff and PR review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/svg_snapshot.rs— a pure-Rust integration test that renders HWPX pages viaHwpDocument::render_page_svg_nativeand diffs the output against committed golden SVGs.form-002.hwpxpage 0) to establish the baseline.cargo teststep inci.yml, so the check is active on every PR with no new workflow and no Hancom-Office / Windows dependency.Closes #173.
Design
Pattern borrowed from the MDM project's
core/tests/golden_hwpx.rs(same maintainer). Two things worth calling out:UPDATE_GOLDEN=1regeneration. When a rendering change is intentional, runUPDATE_GOLDEN=1 cargo test --test svg_snapshotto rewrite the goldens in place. The diff gets reviewed in the same PR as the source change.render_is_deterministic_within_processrenders the same page twice inside a single process and asserts byte equality. If this ever fails, every snapshot test above becomes unreliable regardless of golden correctness — so we surface non-determinism as its own failure mode.Font embedding is explicitly OFF (the native entry point doesn't embed), which keeps goldens independent of host system fonts.
Verification
rhwp export-svg samples/hwpx/form-002.hwpx -o /tmp/a -p 0 rhwp export-svg samples/hwpx/form-002.hwpx -o /tmp/b -p 0 diff -q /tmp/a /tmp/b # emptycargo test --release --test svg_snapshotpasses locally (macOS, 2 tests).Test plan
cargo testtests/golden_svg/form-002/page-0.svg) visually — it's ~263 KB of readable SVG.Not in this PR
🤖 Generated with Claude Code