"""Compare complete generated assets with the reviewed, pinned output baseline.""" import hashlib import json import pathlib import sys def verify(root): expected = json.loads(pathlib.Path(__file__).with_name('fixtures').joinpath('assets_manifest.json').read_text()) actual = {path.relative_to(root).as_posix(): hashlib.sha256(path.read_bytes()).hexdigest() for path in sorted(root.rglob('*')) if path.is_file() and path.relative_to(root).parts[0] != 'analysis'} changed = sorted(name for name in expected.keys() | actual.keys() if expected.get(name) != actual.get(name)) if changed: raise AssertionError('Generated assets differ from the reviewed baseline:\n' + '\n'.join(changed)) print(f'All {len(expected)} generated assets match the reviewed baseline.') if __name__ == '__main__': verify(pathlib.Path(sys.argv[1]))