File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44#
55# SPDX-License-Identifier: MIT
66
7+ import os
8+ import shutil
9+ import struct
710import subprocess
811import unittest
912from pathlib import Path
10- import struct
1113import zlib
1214
1315PROJECT_ROOT = Path (__file__ ).resolve ().parents [2 ]
@@ -93,7 +95,15 @@ def test_snapshot_matches_golden(self) -> None:
9395 self .assertTrue (RAW_SNAPSHOT .exists (), "Snapshot generator did not create raw output" )
9496
9597 _rgb565_to_png (RAW_SNAPSHOT , PNG_SNAPSHOT )
96- self .assertTrue (GOLDEN_SNAPSHOT .exists (), "Golden snapshot missing" )
98+
99+ if os .getenv ("UPDATE_GOLDEN" ):
100+ GOLDEN_SNAPSHOT .parent .mkdir (parents = True , exist_ok = True )
101+ shutil .copy2 (PNG_SNAPSHOT , GOLDEN_SNAPSHOT )
102+
103+ if not GOLDEN_SNAPSHOT .exists ():
104+ self .fail (
105+ "Golden snapshot missing. Run scripts/update_goldens.sh to refresh the reference image."
106+ )
97107
98108 generated = PNG_SNAPSHOT .read_bytes ()
99109 golden = GOLDEN_SNAPSHOT .read_bytes ()
You can’t perform that action at this time.
0 commit comments