Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/hop/blob/main/Linux/tests/build_record_check.py # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hop / Linux / tests / build_record_check.py` 52 lines ยท 2447 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """Independent checks of successful-build proofs and failed-build invalidation.""" 3 import hashlib 4 import json 5 from pathlib import Path 6 import shutil 7 import subprocess 8 import tempfile 9 10 11 def sha(path): 12 return hashlib.sha256(path.read_bytes()).hexdigest() 13 14 15 def main(): 16 root = Path(__file__).resolve().parents[2] 17 build = root / 'build/linux' 18 toolchain = root / 'build/linux-toolchain' 19 head = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=root, text=True).strip() 20 expected = ['HOPBUILD1', head, (toolchain / 'source-commit').read_text().strip(), 21 sha(toolchain / 'seed/out/omc'), sha(build / 'hop'), sha(build / 'hopcore')] 22 proof = (build / 'BUILD_RECORD').read_bytes() 23 assert proof == ('\n'.join(expected) + '\n').encode(), proof 24 with tempfile.TemporaryDirectory(prefix='hop-build-proof-') as raw: 25 source = Path(raw) / 'source' 26 subprocess.run(['git', 'clone', '--quiet', '--no-hardlinks', str(root), str(source)], check=True) 27 output = source / 'build/linux' 28 output.mkdir(parents=True) 29 record = output / 'BUILD_RECORD' 30 record.write_bytes(proof) 31 (source / 'Linux/window.om').unlink() 32 result = subprocess.run([str(build.parent / 'linux-build'), str(toolchain)], 33 cwd=source, capture_output=True) 34 assert result.returncode != 0, result.stdout 35 assert record.read_bytes() == b'', 'failed build retained an installable proof' 36 shutil.copyfile(root / 'Linux/window.om', source / 'Linux/window.om') 37 with (source / 'Linux/window.om').open('ab') as stream: 38 stream.write(b'\nnote independent dirty-source control\n') 39 record.write_bytes(proof) 40 result = subprocess.run([str(build.parent / 'linux-build'), str(toolchain)], 41 cwd=source, capture_output=True) 42 assert result.returncode == 0, (result.stdout, result.stderr) 43 assert record.read_bytes() == b'', 'dirty build acquired an installable proof' 44 assert (output / 'SOURCE_HEAD').read_bytes() == b'' 45 print(json.dumps({'status': 'PASS', 'checks': [ 46 'successful proof binds source, compiler revision and actual compiler/hop/hopcore hashes', 47 'failed build invalidates a previous proof', 48 'successful dirty-source development build stays un-installable']})) 49 50 51 if __name__ == '__main__': 52 main()