Skip to content

Improve the test harness - #954

Merged
LaurenzV merged 4 commits into
mainfrom
test-diff
Aug 31, 2025
Merged

LaurenzV merged 4 commits into
mainfrom
test-diff

Conversation

@LaurenzV

Copy link
Copy Markdown
Collaborator

I found it really awkward to work with the test harness (generating new reference images, generating diff images, etc.), so I've rewritten it a bit to be more similiar to how we have it in vello_cpu.

First, in case a test fails it now prints a nice diff image that also shows the expected and actual versions on the left/right:
image

In case you want to override the tests that are currently failing, you can run with MAKE_REF="" cargo test --release to do so.

I've raised the pixel diff threshold to 1 because it seems like there are apparently slight differences when loading with the image crate vs. the previous code, not sure if we should set this to 0 and re-add the previously existing code instead.

Overall, this will hopefully make it easier to work with the test suite. :)

@RazrFalcon

Copy link
Copy Markdown
Collaborator

Why do we need an image dependency? All our files are PNGs.
I just don't want to increase compilation time and vendored archive size (afaik dev-dependencies are included).

Otherwise, looks good.

PS: since when we use oxipng?!

@LaurenzV

Copy link
Copy Markdown
Collaborator Author

Why do we need an image dependency? All our files are PNGs.

Mainly for convenience, but I'll see whether I can get rid of it.

PS: since when we use oxipng?!

Since a long time it seems. 😄

@LaurenzV
LaurenzV requested a review from nicoburns August 31, 2025 15:40
Comment thread .gitignore Resolved
@LaurenzV
LaurenzV merged commit 7b0837a into main Aug 31, 2025
@LaurenzV
LaurenzV deleted the test-diff branch August 31, 2025 17:51
nicoburns added a commit that referenced this pull request Jul 29, 2026
## Changes made

- Replaces `rustybuzz` with `harfrust`
- Replaces `ttf_parser` with `skrifa`

## Notes

- This is failing 23 tests. These probably need to be manually checked.
I'm waiting on #954 to
investigate these.
- This requires an MSRV bump from `1.65` to `1.85`
- This will represent a binary size bump for users of `resvg`.

## Production profile

The analysis below uses the following "production" profile:

```toml
[profile.production]
inherits = "release"
opt-level = 3
debug = false
lto = true
codegen-units = 1
strip = true
incremental = false
```

## Binary size analysis:

According to `cargo-bloat` (not the most accurate):

  - `harfrust` and `rustybuzz` are both ~250kb
  - `ttf_parser` and `read-fonts` are both ~100kb
- However, `ttf_parser` includes the metrics outlining functionality of
`skrifa`. And skrifa is another ~250kb.

Compiling the CLI (which is a much more useful test) with the production
profile above (`cargo build --profile production --bin resvg`) I get:

- `2.4mb` for `main`
- `3.0mb` for this PR

**So this PR causes a binary size increase of around `600kb`**

## Compile time analysis

Compile times on an M1 Pro (8+2 cores) are shown below (`cargo build`):

| Profile | `main` | This PR |
| --- | ---| --- |
| `debug` | 4.68s | 9.09s |
| `release` | 7.64s | 14.84s |
| `production` | 24.59s | 34.00s |

**So this PR roughly doubles compile times at regular opt settings**
(with the effect being less pronounced with LTO and other production
optimisation settings enabled)

---------

Signed-off-by: Nico Burns <[email protected]>
Co-authored-by: Laurenz Stampfl <[email protected]>
dmtrKovalenko pushed a commit to dmtrKovalenko/svgr that referenced this pull request Oct 13, 2026
Upstream: linebender/resvg@7b0837a

Adaptation: merged upstream's TestMode/render_inner, MAKE_REF reference
regeneration (oxipng is optional) and side-by-side diff images written to
tests/diffs (gitignored) into the fork's harness, keeping svgr::render with
SvgrCache/PixmapPool, preloaded image and sub-SVG data for normal tests and
the fork's `-actual.png` output. Public helpers render, render_extra,
render_extra_with_scale and render_node keep their names, and images of
different sizes now count as a diff instead of panicking.
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.

3 participants