How We Prove a PPTX Library Actually Works
go-pptx Tech Blog · Part 9: Quality Engineering — Corpus, Golden Samples, Coverage, Fuzz, and the Real-Device Matrix
Series: go-pptx Tech Blog (10 parts)
Baseline: v2.4.4
Keywords: corpus regression, B1 assertions, coverage gate, native fuzz, L3 client matrix, performance guardrails, CI
1. Why "unit tests pass" is not enough
Quality problems in a file-format library are usually not "the function is written wrong," but rather:
- Real documents contain extensions you have never seen;
- Clients differ in their tolerance and interpretation of element order and namespaces;
- A single "optimization" quietly changes the output bytes;
- Newly added security branches have no tests, and coverage silently declines;
- You only tested on Linux, and the Windows/WASM build fails.
go-pptx's quality engineering revolves around one principle: turn "claimed capabilities" into reproducible evidence. This part breaks down its layers of defense.
2. Corpus: 30+ real samples + public golden samples
2.1 Corpus structure
The project maintains a corpus index (testdata/corpus):
| Category | Content | Distributed |
|---|---|---|
| Public golden samples | s001-text / s002-table / s003-image / s004-audio | Yes (license permits) |
| Private index | ext-0001 … ext-0033 (sources such as PowerPoint / WPS / Google Slides / Keynote) | No, manifest only |
| Documentation count | 36 samples (public golden samples + private index); testdata/corpus currently has 37 manifests | — |
Each sample records at least:
- Sample ID, source license, whether it may be redistributed;
- Generator and version, platform;
- Creation steps, font environment;
- OOXML type (Transitional / Strict);
- Feature tags (which capabilities are exercised);
- Expected assertions;
- Known issues.
Private samples are not distributed with the open source, but their index is kept, to prove that "we tested real sources," not just files we generated ourselves.
2.2 The closed loop of public golden samples
Each public golden sample contains:
s001-text/ ├── s001-text.pptx # before modification ├── s001-text.edited.pptx # after modification ├── s001-text.actions.json # modification actions └── s001-text.compat-smoke.json CI will:
- Validate the manifest / actions conventions;
- Replay the actions with
-tags=corpus; - Compare the post-modification bytes / structure;
- Archive logs on failure.
This is far more meaningful than "sample files sit in the repository and nobody runs them."
2.3 B1 byte assertions
The three pieces of evidence for B1:
- Empty change set save: unmodified Part decompressed content is byte-identical;
-
ext-0024(WPS, containing animation + unknown extensions) single-Run replacement: the difference span converges to 1 byte; - Public golden sample pre/post-modification replay: byte-level comparison.
The significance of B1 is: differences appear only where you declared a modification.
3. Coverage gate: from "silent decline" to "immediately red"
3.1 A real lesson
internal/opc once silently fell from 90.4% to 89.5%, dropping below the 90% threshold, and no one noticed for three days. The reasons:
-
ADR-018Tier 2 raw pass-through added 4 new security-limit rejection branches; - These branches had no tests;
- At the time CI only ran build/test/vet, not coverage.
3.2 Gate mechanism
scripts/coverage/gate.sh turns each package's threshold into an assertion:
FLOORS=( "github.com/F31/go-pptx/v2/pptx=82" "github.com/F31/go-pptx/v2/internal/opc=90" "github.com/F31/go-pptx/v2/internal/xmlstore=90" "github.com/F31/go-pptx/v2/internal/chart=90" # ... ) It also performs a completeness check:
- Every package in
go list ./...must appear inFLOORSorSKIP; - Otherwise FAIL — closing off "new packages silently going unchecked."
This rule comes from three lessons of "forgot to add a threshold after adding a package."
3.3 Current coverage (v2.4.4)
| Package | Coverage |
|---|---|
pptx (public facade) | 82.5% |
internal/opc | 90.6% |
internal/chart | 90.8% |
internal/ooxml | 92.7% |
internal/document/geometry | 90.7% |
internal/document/style | 90.9% |
| Whole-repo weighted | about 84%+ |
The threshold is not "the higher the better," but "a regression-prevention lower bound + behavior first." For example, ir / render / chart value the behavioral contract more, so their thresholds are taken as regression-prevention lower bounds.
4. Fuzz: untrusted input does not panic
Native fuzz targets cover:
- Open paths:
opc.Load/opc.Scan/xmlstore.Scanner/xmlstore.Index/OpenReader; - Text editing:
ReplaceText/SetPlainText; - Template binding:
FuzzBind; - Edit paths:
fuzz_edit.
The value of fuzz is not only "finding panics," but also:
- Whether resource budgets take effect (oversized Parts, overly deep XML);
- Whether errors are classifiable (
ErrMalformedPackage/ErrLimitExceeded/ErrEncoding); - Whether zero residue is preserved on failure (revision unchanged).
Known fixes driven by fuzz include:
- Chart
c:pt/@idxupper bound (preventing themakeslicepanic / ~16GB allocation frommake([]string, max+1)); - MP4
ftypcompatible brand collection capped at 64 (preventing 21× amplification); - Shape ID duplicate diagnostics (
DRAWING_ID_DUPLICATE).
5. L3 client matrix: open, edit, and re-save on real devices
Unit tests cannot prove "PowerPoint can open it." The project fills this layer with a real-device matrix:
5.1 First-round matrix (2026-09-11)
- Microsoft PowerPoint 16.0.20326 (Microsoft 365, Windows 11);
- WPS Presentation 12.1.0.28599 (Windows 11);
- 4 files × 2 clients = 8/8 passed;
- Verified: opens with no repair prompt, re-saves, and go-pptx re-verification yields 0 errors.
Sample coverage:
- Real private samples
ext-0001/ext-0008; -
ext-0024(WPS animation + unknown extensions); - Public golden sample
s001-text.
5.2 v2.4.x extended matrix
- PowerPoint 16 / WPS 12: a 13-page comprehensive sample opens and re-saves successfully;
- LibreOffice 24.2: PDF conversion passes;
- Combination charts, series labels/styles/markers, gridlines, number formats, table styleId/diagonal lines, connector sites, and seven categories of effects are all verified to be preserved;
- WPS may downgrade 3D columns to 2D — recorded as known behavior, without pretending "fully identical."
Reproduction script: scripts/l3/run_client.sh (Windows host COM automation).
6. Performance guardrails: three corpus tiers × six benchmark types
6.1 Benchmark design
Three corpus tiers:
| Corpus | Scale |
|---|---|
10p-text | 10 pages of plain text |
50p-image | 50 pages of text and images, each page with a text box + one small image |
100p-media | 100 pages, with the first 20 pages overlaid with noisy large images |
Six benchmark types:
-
Open: open + close; -
Traverse: Slides → Shapes → TextFrame → Paragraph.Text; -
Replace: single replacement; -
SaveMem:Writetoio.Discard; -
SaveDisk:Saveto disk (including atomic replacement); -
PeakHeap: full-process heap peak.
6.2 A real performance fix
The V2.0.1 review found that Presentation.Slides() repeatedly parsed relationships inside a loop, and that AddPicture deduplication read the full bytes + SHA-256 of every stored media, forming O(N²).
Measured (BenchmarkPerfTraverse/100p-media, -benchtime=6x):
| Metric | Before fix | After fix | Reduction |
|---|---|---|---|
| Time | 16.40 ms | 3.96 ms | −75.8% |
| Memory | 26.77 MB | 1.17 MB | −95.6% |
| allocs | 223,284 | 10,713 | −95.2% |
Such data is "platform-dependent"; the project explicitly does not write "how many times faster than Python," nor does it assert ns/op thresholds on shared CI runners (which would be flaky). CI only does a smoke guard:
- The benchmark suite compiles;
- All three corpus tiers execute;
- The report generator can parse;
- The corpus size lower bound is guarded.
A full baseline runs separately at night.
7. CI: one matrix
| Job | Content |
|---|---|
lint | gofmt -l . + go vet (default + corpus tag) |
test | Ubuntu / Windows / macOS × Go 1.24 / 1.27, CGO_ENABLED=0 |
race | go test -race ./... |
corpus-replay | -tags=corpus replay of public golden samples + ext-0024 |
cross-build | js/wasm, darwin/arm64, wasip1/wasm, linux/arm64 (Windows covered by the test matrix) |
coverage-gate | Per-package thresholds + completeness check |
perf-smoke | Benchmarks run, report parses, size lower bound |
Dependency direction is enforced by internal/archlint within go test, with no external lint tools introduced, keeping CI with zero extra dependencies.
8. Principles of quality engineering
- Evidence is reproducible: golden samples come with actions, manifests, and logs; not "I ran it locally."
- Differences are explainable: B1 assertions constrain differences to the declared scope; opaque diffs are not guessed at.
- Thresholds are executable: coverage, cross-build, and corpus replay are all CI assertions, not slogans in documentation.
- Failures are classifiable: error codes, diagnostics, and capability states are all stable strings, convenient for downstream handling.
- Boundaries are disclosed: no rendering, no encrypted writing, no in-place save — state it clearly rather than pretending to support it.
9. Known limitations
- Private
ext-*samples are not distributed with the open source, so they cannot be fully reproduced externally; public golden samples can only serve as a fallback. - L3 relies on real Windows machines/COM and cannot be fully automated in CI; it relies on scripts + a manual matrix.
- Performance numbers are strongly correlated with hardware and Go version; cross-machine comparison requires fixing the environment first.
- Coverage is not a sufficient condition for quality; the behavioral contract (especially byte fidelity) takes priority.
- What fuzz covers is "no panic / classifiable errors," not "all semantics are correct."
10. Summary
The core of quality engineering is not "more tests," but what the tests can prove:
- The corpus proves "real files can be handled";
- Golden samples + B1 prove "the scope of change is controllable";
- The coverage gate proves "new code does not silently regress";
- Fuzz proves "malicious input does not bring down the service";
- L3 proves "clients can open it";
- Performance guardrails prove "optimizations introduce no regressions."
The next post is the final one: Architecture Evolution and Cross-Platform Delivery — v2 facade convergence, engine, archlint, the ECMA-376 generation pipeline, the CLI, and WASM.
Series navigation: ← Part 8: Read-Only Audit and Semantic Diff · Part 10: Architecture Evolution and Cross-Platform Delivery →

