Skip to content

test: HWPX SVG snapshot regression harness (closes #173)#181

Open
seunghan91 wants to merge 1 commit intoedwardkim:mainfrom
seunghan91:feat/hwpx-svg-snapshot
Open

test: HWPX SVG snapshot regression harness (closes #173)#181
seunghan91 wants to merge 1 commit intoedwardkim:mainfrom
seunghan91:feat/hwpx-svg-snapshot

Conversation

@seunghan91
Copy link
Copy Markdown
Contributor

Summary

  • Adds tests/svg_snapshot.rs — a pure-Rust integration test that renders HWPX pages via HwpDocument::render_page_svg_native and diffs the output against committed golden SVGs.
  • Ships the first golden (form-002.hwpx page 0) to establish the baseline.
  • Runs under the existing cargo test step in ci.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=1 regeneration. When a rendering change is intentional, run UPDATE_GOLDEN=1 cargo test --test svg_snapshot to rewrite the goldens in place. The diff gets reviewed in the same PR as the source change.
  • Determinism probe. render_is_deterministic_within_process renders 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

  • Byte-identical across two back-to-back CLI invocations on the same machine:
    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   # empty
  • cargo test --release --test svg_snapshot passes locally (macOS, 2 tests).

Test plan

  • CI green on cargo test
  • Review the committed golden (tests/golden_svg/form-002/page-0.svg) visually — it's ~263 KB of readable SVG.
  • If golden size concerns arise later, gzip-encoding is a one-line change to the harness.

Not in this PR

  • Expanding the golden corpus to the 2024/2025 investment samples — easier to do file-by-file in follow-up PRs once the first run is green.
  • Cross-platform determinism check (macOS vs ubuntu CI) — will surface itself the first time CI runs the harness.

🤖 Generated with Claude Code

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.
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.

HWPX 검증: rhwp SVG 스냅샷 기반 (CI에서 한컴 의존 제거)

1 participant