29 lines
848 B
Python
Executable File
29 lines
848 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Refresh the SHA-256 pin in kernel/kernel.json from kernel/mocklang.
|
|
|
|
This script is for fixture maintainers only. Tests never rewrite the fixture;
|
|
they read the committed digest and fail if it no longer matches.
|
|
"""
|
|
import hashlib
|
|
import json
|
|
import pathlib
|
|
import sys
|
|
|
|
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
KERNEL = ROOT / "kernel"
|
|
|
|
|
|
def main() -> int:
|
|
mocklang = KERNEL / "mocklang"
|
|
descriptor = KERNEL / "kernel.json"
|
|
digest = hashlib.sha256(mocklang.read_bytes()).hexdigest()
|
|
data = json.loads(descriptor.read_text(encoding="utf-8"))
|
|
data["digest"] = digest
|
|
descriptor.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
print(f"kernel.json digest = {digest} ({mocklang.name})")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|