Skip to content

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

Closed
seunghan91 wants to merge 1 commit into
edwardkim:mainfrom
seunghan91:feat/hwpx-svg-snapshot
Closed

test: HWPX SVG snapshot regression harness (closes #173)#181
seunghan91 wants to merge 1 commit into
edwardkim: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.
@edwardkim

Copy link
Copy Markdown
Owner

@seunghan91 기여 감사합니다. 본 PR 의 하네스(tests/svg_snapshot.rs) 와 golden 샘플을 local/devel 에 cherry-pick 하여 반영했습니다.

본 PR 은 base 가 main 이었고 devel 에 대량 머지가 있었기에 rebase 시 diff 가 크게 변동됨 (PR #213 과 동일 현상). 대신 devel 에 cherry-pick + golden 재생성 방식으로 처리했습니다. 저자 authorship 보존 (seunghan Kim <theqwe2000@gmail.com>) + Co-Authored 표기.

본 PR 은 close 처리합니다. 다음 PR 부터는 devel 기준 rebase 로 올려주시면 diff 가 명확해집니다. 감사합니다.

@edwardkim edwardkim closed this Apr 20, 2026
edwardkim pushed a commit that referenced this pull request Apr 20, 2026
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.

Cherry-picked from PR #181 (originally targeted main; applied to devel).

Co-Authored-By: seunghan Kim <theqwe2000@gmail.com>
edwardkim added a commit that referenced this pull request Apr 20, 2026
PR #181 (by @seunghan91) 가 2026-04-17 기준으로 작성된 후 다음 두 PR 이 devel 에 머지되어 SVG 출력이 변경됨:

- #213 (cherry-picked by @jskang): HWPX char offsets interleaved 보정
- #221 (by @planet6897): OLE/Chart/EMF 네이티브 렌더링 + HWPX 차트 파서

두 fix 가 form-002 렌더링에 반영되어 원본 golden 과 diff 발생.
`UPDATE_GOLDEN=1 cargo test --test svg_snapshot` 로 재생성 후 결정성 확인 완료.

Verification:
- cargo test --test svg_snapshot → 2 passed (form_002_page_0 + render_is_deterministic_within_process)
- 재실행 back-to-back 결정성 유지

Refs #181 · #173

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request Apr 20, 2026
2026-04-20~21 사이클 정리:

PR 처리 9건:
- admin merge 5: #209 #214 #215 #221 #224
- cherry-pick + close 2: #213 (+중복 #210 close), #181 (+golden 재생성)
- dependabot close 2: #211 #212 (devel 수동 bump + target-branch=devel 설정)
- 보류 1: #165 skia (별도 사이클)

이슈 close 7: #173 #195 #202 #205 #207 #210 #222
신규 이슈 등록 1: #204 (표 Undo/Redo)

Chrome Web Store / Edge Add-ons v0.2.1 심사 통과 (2026-04-21).

local/task205 폐기: PR #209+#214 가 중복 처리하여 잔여 고유 기여 분리 곤란.

기여자 7명 감사 기록.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request Apr 21, 2026
한글판 README.md 와 영문판 README_EN.md 의 섹션 구조·내용을 1:1 일치시킴.

주요 변경:
- Roadmap + Milestones 섹션을 상단(로드맵/이정표 위치) 으로 이동
- v0.5.0 ~ v0.7.x 이정표에 v0.2.1 사이클 전체 반영 (Chrome/Edge 심사 통과, PR #213/#215/#221/#169/#209/#214/#224/#181)
- rhwp-firefox (v0.1.1 AMO 준비) + rhwp-safari (v0.2.1) 섹션 추가
- 기여자 감사 목록 확장: @seo-rii, @planet6897, @yl-star7 추가 (9명)
- Features: OLE/Chart/EMF native rendering 항목 추가 (#221)
- Project Structure: src/emf/, src/ooxml_chart/, rhwp-firefox/, rhwp-shared/ 반영
- Trademark 섹션 신규 (한글판 동일 위치)
- AI 페어 프로그래밍 섹션: Git Workflow / Task Workflow / Debugging Protocol / Documentation Rules 완전 반영
- 로드맵 링크를 mydocs/eng/report/rhwp-milestone.md 로 보정
- 테스트 수치 783 → 935

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request Apr 22, 2026
한글판 README.md 와 영문판 README_EN.md 의 섹션 구조·내용을 1:1 일치시킴.

주요 변경:
- Roadmap + Milestones 섹션을 상단(로드맵/이정표 위치) 으로 이동
- v0.5.0 ~ v0.7.x 이정표에 v0.2.1 사이클 전체 반영 (Chrome/Edge 심사 통과, PR #213/#215/#221/#169/#209/#214/#224/#181)
- rhwp-firefox (v0.1.1 AMO 준비) + rhwp-safari (v0.2.1) 섹션 추가
- 기여자 감사 목록 확장: @seo-rii, @planet6897, @yl-star7 추가 (9명)
- Features: OLE/Chart/EMF native rendering 항목 추가 (#221)
- Project Structure: src/emf/, src/ooxml_chart/, rhwp-firefox/, rhwp-shared/ 반영
- Trademark 섹션 신규 (한글판 동일 위치)
- AI 페어 프로그래밍 섹션: Git Workflow / Task Workflow / Debugging Protocol / Documentation Rules 완전 반영
- 로드맵 링크를 mydocs/eng/report/rhwp-milestone.md 로 보정
- 테스트 수치 783 → 935

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request Apr 23, 2026
… + table border)

PR #251 (by @seanshin · #249) 머지 후 CI Build & Test 실패:
- test form_002_page_0 ... FAILED
- test table_text_page_0 ... FAILED

원인: PR #251 의 3가지 렌더 수정이 SVG 출력에 의도된 미세 변화를 발생시킴.
- PUA 심볼 문자 → 유니코드 표준 문자 (map_pua_bullet_char)
- 문단 border_fill margin 반영 (margin_left/right 적용)
- 표 외곽 테두리 fallback + 셀 미커버 영역 한정

determinism probe (render_is_deterministic_within_process) 는 통과 →
하네스 자체는 정상, golden 만 outdated.

UPDATE_GOLDEN=1 cargo test --test svg_snapshot 로 재생성 후 결정성 재검증.

Verification:
- cargo test --test svg_snapshot → 3 passed (form_002 + table_text + determinism)
- 두 번째 실행 back-to-back 결정성 유지
- 변경 규모: +3/-3 (PR #251 의 국소 렌더 수정 반영분만)

CI 실패 로그: run #24809115353

Refs #249 · #181 (hwpx snapshot harness)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request Apr 23, 2026
…ot 반영)

피드백 mydocs/feedback/manual_currency_audit.md 결정 반영. 최근 사이클의 주요 변경을
매뉴얼에 동기화하고, PR 처리 절차 매뉴얼을 신설.

[A] publish_guide.md
- 버전 예시 0.7.0 → 0.7.3 (현재 릴리즈 기준)
- 커맨드 예시 갱신 (git tag v0.7.3 등)
- 테스트 수치 783 → 941
- 신규 섹션 "브라우저 확장 버전 정책 (라이브러리와 이원화)" — v0.2.x 정책 명문화

[B] chrome_edge_extension_build_deploy.md → 통합 확장 매뉴얼로 확장
- 제목: "브라우저 확장 빌드 및 배포 매뉴얼 (Chrome/Edge/Firefox/Safari)"
- 빌드 크기 실측치 갱신 (WASM 3.9MB · 전체 23MB)
- 테스트 페이지에 06-security.html 추가
- 4.4 절 Firefox (AMO 제출 절차) + 4.5 절 Safari (macOS 전용 빌드) 신규

[C] browser_extension_dev_guide.md
- 제목: Safari/Chrome/Edge → Safari/Chrome/Edge/Firefox
- Service Worker vs Background Scripts 표에 Firefox 열 추가
- 9절 신규 "chrome.* vs browser.* 네임스페이스 차이"
- 10절 신규 "rhwp-shared/ 공통 모듈 + 심볼릭 링크 + dereference 빌드 패턴" (PR #214)
- 11절 신규 "Chrome onDeterminingFilename vs Firefox onCreated+onChanged"

[D] hyper_waterfall.md
- 783+ 테스트 → 941+ 테스트
- "1인 개발" → "1인 메인테이너 + Claude Code AI + 외부 기여자 9명 (v0.2.1 기준)"
- "v0.6.0 릴리즈" → "v0.5.0 공개 릴리즈 (뼈대 완성 지점)"

[E] e2e_verification_guide.md
- 신규 섹션 "SVG 회귀 검증 (Rust 유닛 테스트 기반)" — PR #181 하네스
- UPDATE_GOLDEN=1 사용법, 결정성 재확인 절차
- 경고: 렌더 영향 PR 머지 후 golden 재생성 필수 (PR #221 / #251 2회 재현)
- 신규 섹션 "향후 작업 — 한컴 PDF 기준 Visual Diff 하네스" — 이슈 #253

[F] onboarding_guide.md
- E2E 모드 설명 환경 일반화 (Windows Chrome → 로컬/컨테이너 헤드리스 · 호스트 Chrome/Chromium)

[G.2] 신규 mydocs/manual/pr_review_workflow.md
- PR 리뷰 · 통합 워크플로우 표준화
- 리뷰 문서 2종 (review + impl) 작성 절차
- 로컬 사전 검증 (빌드/테스트/Clippy/doctest/svg_snapshot)
- Admin merge 후 필수 후속 (이슈 close · 감사 코멘트 · devel sync · golden 재생성 · archives 이동)
- 재작업 요청 패턴 (PR #234#251 사례)
- 예외 케이스 (dependabot · 오래된 base · 대형 PR)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request Apr 23, 2026
…ot 반영)

피드백 mydocs/feedback/manual_currency_audit.md 결정 반영. 최근 사이클의 주요 변경을
매뉴얼에 동기화하고, PR 처리 절차 매뉴얼을 신설.

[A] publish_guide.md
- 버전 예시 0.7.0 → 0.7.3 (현재 릴리즈 기준)
- 커맨드 예시 갱신 (git tag v0.7.3 등)
- 테스트 수치 783 → 941
- 신규 섹션 "브라우저 확장 버전 정책 (라이브러리와 이원화)" — v0.2.x 정책 명문화

[B] chrome_edge_extension_build_deploy.md → 통합 확장 매뉴얼로 확장
- 제목: "브라우저 확장 빌드 및 배포 매뉴얼 (Chrome/Edge/Firefox/Safari)"
- 빌드 크기 실측치 갱신 (WASM 3.9MB · 전체 23MB)
- 테스트 페이지에 06-security.html 추가
- 4.4 절 Firefox (AMO 제출 절차) + 4.5 절 Safari (macOS 전용 빌드) 신규

[C] browser_extension_dev_guide.md
- 제목: Safari/Chrome/Edge → Safari/Chrome/Edge/Firefox
- Service Worker vs Background Scripts 표에 Firefox 열 추가
- 9절 신규 "chrome.* vs browser.* 네임스페이스 차이"
- 10절 신규 "rhwp-shared/ 공통 모듈 + 심볼릭 링크 + dereference 빌드 패턴" (PR #214)
- 11절 신규 "Chrome onDeterminingFilename vs Firefox onCreated+onChanged"

[D] hyper_waterfall.md
- 783+ 테스트 → 941+ 테스트
- "1인 개발" → "1인 메인테이너 + Claude Code AI + 외부 기여자 9명 (v0.2.1 기준)"
- "v0.6.0 릴리즈" → "v0.5.0 공개 릴리즈 (뼈대 완성 지점)"

[E] e2e_verification_guide.md
- 신규 섹션 "SVG 회귀 검증 (Rust 유닛 테스트 기반)" — PR #181 하네스
- UPDATE_GOLDEN=1 사용법, 결정성 재확인 절차
- 경고: 렌더 영향 PR 머지 후 golden 재생성 필수 (PR #221 / #251 2회 재현)
- 신규 섹션 "향후 작업 — 한컴 PDF 기준 Visual Diff 하네스" — 이슈 #253

[F] onboarding_guide.md
- E2E 모드 설명 환경 일반화 (Windows Chrome → 로컬/컨테이너 헤드리스 · 호스트 Chrome/Chromium)

[G.2] 신규 mydocs/manual/pr_review_workflow.md
- PR 리뷰 · 통합 워크플로우 표준화
- 리뷰 문서 2종 (review + impl) 작성 절차
- 로컬 사전 검증 (빌드/테스트/Clippy/doctest/svg_snapshot)
- Admin merge 후 필수 후속 (이슈 close · 감사 코멘트 · devel sync · golden 재생성 · archives 이동)
- 재작업 요청 패턴 (PR #234#251 사례)
- 예외 케이스 (dependabot · 오래된 base · 대형 PR)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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에서 한컴 의존 제거)

2 participants