mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
kittest: Add UPDATE_SNAPSHOTS=force (#7508)
This adds a new mode, `UPDATE_SNAPSHOTS=force`, which will lower the threshold to zero, overwriting every image that is not _exactly_ the same. Most comparisons has a threshold because different GPUs render slightly differently. However, setting that threshold accurately can be hard. Sometimes a test will pass locally, but fail on CI. In those cases you want to force an update of the failing test. You can use `UPDATE_SNAPSHOTS=force` for that. And sometimes a small change _should_ update all images, but the change is so tiny that it falls under the threshold. Still, you want to make a point of showing that these images have changes. You can use `UPDATE_SNAPSHOTS=force` for that.
This commit is contained in:
@@ -44,7 +44,11 @@ Once enabled, you can call `Harness::snapshot` to render the ui and save the ima
|
||||
|
||||
To update the snapshots, run your tests with `UPDATE_SNAPSHOTS=true`, so e.g. `UPDATE_SNAPSHOTS=true cargo test`.
|
||||
Running with `UPDATE_SNAPSHOTS=true` will cause the tests to succeed.
|
||||
This is so that you can set `UPDATE_SNAPSHOTS=true` and update _all_ tests, without `cargo test` failing on the first failing crate.
|
||||
This is so that you can set `UPDATE_SNAPSHOTS=true` and update all tests, without `cargo test` failing on the first failing crate.
|
||||
|
||||
`UPDATE_SNAPSHOTS=true` will only update the images of _failing_ tests.
|
||||
If you want to update all snapshot images, even those that are within error margins,
|
||||
run with `UPDATE_SNAPSHOTS=force`.
|
||||
|
||||
If you want to have multiple snapshots in the same test, it makes sense to collect the results in a `Vec`
|
||||
([look here](https://github.com/emilk/egui/blob/70a01138b77f9c5724a35a6ef750b9ae1ab9f2dc/crates/egui_demo_lib/src/demo/demo_app_windows.rs#L388-L427) for an example).
|
||||
|
||||
Reference in New Issue
Block a user