Improve kittest snapshot output: print absolute path to diff file

This commit is contained in:
Emil Ernerfeldt 2025-01-02 14:56:27 +01:00
parent cf7150c6a3
commit 64f077588c
1 changed files with 15 additions and 10 deletions

View File

@ -106,24 +106,28 @@ impl Display for SnapshotError {
diff, diff,
diff_path, diff_path,
} => { } => {
let diff_path = std::path::absolute(diff_path).unwrap_or(diff_path.clone());
write!( write!(
f, f,
"'{name}' Image did not match snapshot. Diff: {diff}, {diff_path:?}. {HOW_TO_UPDATE_SCREENSHOTS}" "'{name}' Image did not match snapshot. Diff: {diff}, {diff_path:?}. {HOW_TO_UPDATE_SCREENSHOTS}"
) )
} }
Self::OpenSnapshot { path, err } => match err { Self::OpenSnapshot { path, err } => {
ImageError::IoError(io) => match io.kind() { let path = std::path::absolute(path).unwrap_or(path.clone());
ErrorKind::NotFound => { match err {
write!(f, "Missing snapshot: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}") ImageError::IoError(io) => match io.kind() {
} ErrorKind::NotFound => {
write!(f, "Missing snapshot: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}")
}
err => {
write!(f, "Error reading snapshot: {err:?}\nAt: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}")
}
},
err => { err => {
write!(f, "Error reading snapshot: {err:?}\nAt: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}") write!(f, "Error decoding snapshot: {err:?}\nAt: {path:?}. Make sure git-lfs is setup correctly. Read the instructions here: https://github.com/emilk/egui/blob/master/CONTRIBUTING.md#making-a-pr")
} }
},
err => {
write!(f, "Error decoding snapshot: {err:?}\nAt: {path:?}. Make sure git-lfs is setup correctly. Read the instructions here: https://github.com/emilk/egui/blob/master/CONTRIBUTING.md#making-a-pr")
} }
}, }
Self::SizeMismatch { Self::SizeMismatch {
name, name,
expected, expected,
@ -135,6 +139,7 @@ impl Display for SnapshotError {
) )
} }
Self::WriteSnapshot { path, err } => { Self::WriteSnapshot { path, err } => {
let path = std::path::absolute(path).unwrap_or(path.clone());
write!(f, "Error writing snapshot: {err:?}\nAt: {path:?}") write!(f, "Error writing snapshot: {err:?}\nAt: {path:?}")
} }
} }