1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Enforce consistent snapshot updates (#7744)

* Closes https://github.com/emilk/egui/issues/7647


This collects SnapshotResults within the Harness and adds a check to
enforce snapshot results are merged in case multiple Harnesses are
constructed within a test.

This should make snapshot updates via kitdiff/accept_snapshots.sh way
more useful since it should now always update all snapshots instead of
only the first one per test.
This commit is contained in:
Lucas Meurer
2025-11-26 14:56:19 +01:00
committed by Emil Ernerfeldt
parent e6fff4b018
commit 33fb2f300b
7 changed files with 100 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ use egui_kittest::Harness;
#[test]
fn test_image_blending() {
let mut results = egui_kittest::SnapshotResults::new();
for pixels_per_point in [1.0, 2.0] {
let mut harness = Harness::builder()
.with_pixels_per_point(pixels_per_point)
@@ -21,5 +22,6 @@ fn test_image_blending() {
harness.run();
harness.fit_contents();
harness.snapshot(format!("image_blending/image_x{pixels_per_point}"));
results.extend_harness(&mut harness);
}
}

View File

@@ -2,6 +2,7 @@ use egui_kittest::Harness;
#[test]
fn test_kerning() {
let mut results = egui_kittest::SnapshotResults::new();
for pixels_per_point in [1.0, 2.0] {
for theme in [egui::Theme::Dark, egui::Theme::Light] {
let mut harness = Harness::builder()
@@ -23,12 +24,14 @@ fn test_kerning() {
egui::Theme::Light => "light",
}
));
results.extend_harness(&mut harness);
}
}
}
#[test]
fn test_italics() {
let mut results = egui_kittest::SnapshotResults::new();
for pixels_per_point in [1.0, 2.0_f32.sqrt(), 2.0] {
for theme in [egui::Theme::Dark, egui::Theme::Light] {
let mut harness = Harness::builder()
@@ -48,6 +51,7 @@ fn test_italics() {
egui::Theme::Light => "light",
}
));
results.extend_harness(&mut harness);
}
}
}