Skip to content

Commit 893a06e

Browse files
committed
Add comment to run_test method
1 parent a2568b5 commit 893a06e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

tests/scripts/gen-tests.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ def main():
111111
if str(test_file.svg_path()) in IGNORE_TESTS:
112112
test_string += f"// {IGNORE_TESTS[str(test_file.svg_path())]}\n"
113113
test_string += "#[ignore] "
114-
elif not test_file.has_ref():
115-
test_string += f"// unknown reason\n"
116-
test_string += "#[ignore] "
117114

118115
test_string += "#[test] "
119116

tests/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,16 @@ fn is_pix_diff(pixel1: &Rgba<u8>, pixel2: &Rgba<u8>) -> bool {
114114
/// Runs a single test instance.
115115
pub fn run_test(svg_path: &str, ref_path: &str, diff_path: &str, replace: bool) -> i32 {
116116
let (_, actual_image) = convert_svg(&fs::read_to_string(svg_path).unwrap());
117+
118+
// Just as a convenience, if the test is supposed to run but there doesn't exist
119+
// a reference image yet, we create a new one. This allows us to conveniently generate
120+
// new reference images for test cases.
117121
if !Path::new(ref_path).exists() {
118122
fs::create_dir_all(Path::new(ref_path).parent().unwrap()).unwrap();
119123
save_image(&actual_image, Path::new(ref_path));
120-
return 0;
124+
return 1;
121125
}
126+
122127
let expected_image = Reader::open(ref_path).unwrap().decode().unwrap().into_rgba8();
123128

124129
let width = max(expected_image.width(), actual_image.width());

0 commit comments

Comments
 (0)