Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
41 lines
3.0 KiB
Python
41 lines
3.0 KiB
Python
"""Read-only source/test/tool binding; explicit later prose changes only."""
|
|
from pathlib import Path
|
|
import ast,hashlib,json
|
|
|
|
def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest()
|
|
def load(p):return json.loads(p.read_text())
|
|
def registered(root):
|
|
values=[n.value for n in ast.walk(ast.parse((root/'tools/check.py').read_text())) if isinstance(n,ast.Constant) and isinstance(n.value,str) and n.value.endswith('.py') and (Path(n.value).name.startswith('test_') or n.value.endswith('_regression.py'))]
|
|
paths=['tests/'+Path(n).name for n in values]
|
|
assert paths and len(paths)==len(set(paths))
|
|
return set(paths)
|
|
def checked_inputs(root,suite):
|
|
inputs=load(suite/'suite-inputs.json');result=load(suite/'suite-result.json');changes=load(suite/'post-suite-docs.json')
|
|
assert result['exit']==0 and result['inputs_unchanged'] is True and not result.get('resumed')
|
|
rows=result['programs'];assert all(x['exit']==0 for x in rows)
|
|
assert len(rows)==len({x['path'] for x in rows})==result['regression_programs']
|
|
assert {x['path'] for x in rows}==registered(root)
|
|
assert 'All repository checks passed.' in (suite/'suite.log').read_text()
|
|
for n,v in changes.items():
|
|
assert n.startswith('docs/') and len(Path(n).parts)==2 and n.endswith('.md'),n
|
|
assert inputs[n]==v['before_sha256'] and sha(root/n)==v['after_sha256'],n
|
|
from source_manifest import addon_manifest
|
|
assert set(addon_manifest(root))=={n for n in inputs if n.startswith('addons/')}, 'authored addon membership'
|
|
current={n:sha(root/n) for n in inputs}
|
|
assert {n:{'before_sha256':h,'after_sha256':current[n]} for n,h in inputs.items() if h!=current[n]}==changes
|
|
for folder in ['tests','tools','terrain-profiles','terrain-adapters','terrain-integrations']:
|
|
actual={str(p.relative_to(root)) for p in (root/folder).rglob('*') if p.is_file() and '__pycache__' not in p.parts and p.suffix!='.pyc'}
|
|
assert actual=={n for n in inputs if n.startswith(folder+'/')},folder
|
|
assert {str(p.relative_to(root)) for p in (root/'docs').iterdir() if p.is_file()}=={n for n in inputs if n.startswith('docs/') and len(Path(n).parts)==2}
|
|
return current,changes,result
|
|
|
|
def verify_suite_binding(f,suite,authored):
|
|
from source_manifest import addon_manifest
|
|
pin_path=Path(__file__).with_name('binding-inputs.json');pin=load(pin_path)
|
|
for n,h in pin['suite_files'].items():assert sha(suite/n)==h,n
|
|
current,changes,result=checked_inputs(f,suite)
|
|
assert changes==pin['post_suite_docs'] and current==pin['frozen_inputs']
|
|
assert addon_manifest(f)==authored
|
|
original=load(suite/'suite-inputs.json');assert all(original.get(n)==h for n,h in authored.items())
|
|
return {'kind':'complete recorded suite reused only for exact source/tests/tools with separately pinned later prose','regression_programs':result['regression_programs'],'suite_inputs_sha256':sha(suite/'suite-inputs.json'),'suite_result_sha256':sha(suite/'suite-result.json'),'suite_log_sha256':sha(suite/'suite.log'),'binding_inputs_sha256':sha(pin_path),'documentation_differences':changes,'fresh_full_suite_claimed':False,'historical_fixture_hashes_verified':True,'live_source_equivalence_claimed':False}
|