55 lines
4.5 KiB
Python
55 lines
4.5 KiB
Python
"""Admit the eleven independently named S2a additions and retained baseline cases."""
|
|
from pathlib import Path
|
|
import hashlib, json, re, subprocess, sys
|
|
base=Path(__file__).resolve().parent.parent
|
|
root=base/'.local/analysis-core-worktree-20260911'
|
|
folder=base/'.local/analysis-source-gates-20260913'
|
|
name=sys.argv[1]
|
|
assert re.fullmatch(r'[a-zA-Z0-9-]+',name)
|
|
path=folder/(name+'.result.json'); record=json.loads(path.read_bytes())
|
|
assert record['exit']==0 and not record['changed_inputs'] and record['source']==record['head_after']
|
|
assert subprocess.check_output(['git','rev-parse','HEAD'],cwd=root).decode().strip()==record['source']
|
|
inputs_path=folder/record['inputs']; inputs=json.loads(inputs_path.read_bytes())
|
|
assert inputs['source']==record['source'] and len(inputs['inputs'])==524
|
|
for entry in inputs['inputs']:
|
|
raw=(root/entry['path']).read_bytes()
|
|
assert len(raw)==entry['bytes'] and hashlib.sha256(raw).hexdigest()==entry['sha256']
|
|
assert len(record['artifacts'])==1
|
|
artifact=record['artifacts'][0]; raw=Path(artifact['path']).read_bytes()
|
|
assert len(raw)==artifact['bytes'] and hashlib.sha256(raw).hexdigest()==artifact['sha256']
|
|
log_path=folder/(name+'.log'); log=log_path.read_text(encoding='utf-8')
|
|
if record['command'][-1]=='--list':
|
|
original_path=folder/'list-6216cff.result.json'
|
|
original=json.loads(original_path.read_bytes())
|
|
admission=json.loads((folder/'list-6216cff.admission.json').read_bytes())
|
|
assert admission['result_sha256']==hashlib.sha256(original_path.read_bytes()).hexdigest()
|
|
assert len(original['listing_members'])==118
|
|
new_names={'language::analysis_source::declarations::tests::inherited_version_root_and_short_word_contracts_do_not_enable_public8', 'language::analysis_source::declarations::tests::required_declarations_have_independent_typed_body_and_header_oracles', 'language::analysis_source::declarations::tests::borrowed_cursor_preserves_full_file_spans_and_does_not_rescan_fields', 'language::raw_tokens::tests::legacy_adapter_retains_authored_numeric_operator_and_trivia_tokens', 'language::analysis_source::declarations::tests::missing_required_fields_and_unknown_or_duplicate_entries_reject_locally', 'language::analysis_source::declarations::tests::empty_unbound_and_all_scalar_list_types_are_explicit_valid_syntax', 'language::analysis_source::declarations::tests::typed_brace_frames_have_exact_zero_one_two_boundaries', 'language::analysis_source::declarations::tests::declaration_frames_restore_the_callers_inherited_context', 'language::analysis_source::declarations::tests::declaration_budgets_share_literals_types_references_and_failure_state', 'language::analysis_source::declarations::tests::missing_id_metadata_is_stable_and_parameter_ids_are_owner_scoped', 'language::analysis_source::declarations::tests::typed_frame_budget_and_truncated_declaration_cleanup_have_nearby_successes'}
|
|
names=record['listing_members']
|
|
assert len(names)==len(set(names))==129
|
|
assert set(names)==set(original['listing_members'])|new_names
|
|
assert re.findall(r'^(\d+) tests, (\d+) benchmarks\s*$',log,re.M)==[('129','0')]
|
|
mode='list'
|
|
else:
|
|
listing_name,selector=sys.argv[2:4]
|
|
listing_path=folder/(listing_name+'.result.json'); listing=json.loads(listing_path.read_bytes())
|
|
admission=json.loads((folder/(listing_name+'.admission.json')).read_bytes())
|
|
assert admission['result_sha256']==hashlib.sha256(listing_path.read_bytes()).hexdigest()
|
|
assert admission['source']==listing['source']==record['source']
|
|
assert admission['artifact']==artifact and admission['mode']=='list'
|
|
assert selector in record['command']
|
|
names=[n for n in listing['listing_members'] if selector in n]
|
|
actual=re.findall(r'^test ([^\r\n]+) \.\.\. ok\s*$',log,re.M)
|
|
assert names and len(actual)==len(set(actual)) and set(actual)==set(names)
|
|
assert re.search(rf'test result: ok\. {len(actual)} passed; 0 failed; 0 ignored;',log)
|
|
mode='focused'
|
|
receipt={'source':record['source'],'mode':mode,'artifact':artifact,'names':names,
|
|
'result_sha256':hashlib.sha256(path.read_bytes()).hexdigest(),
|
|
'inputs_sha256':hashlib.sha256(inputs_path.read_bytes()).hexdigest(),
|
|
'log_sha256':hashlib.sha256(log_path.read_bytes()).hexdigest(),
|
|
'verified_inputs':len(inputs['inputs']),
|
|
'admission_helper_sha256':hashlib.sha256(Path(__file__).read_bytes()).hexdigest()}
|
|
with (folder/(name+'.admission.json')).open('x',encoding='utf-8',newline='\n') as stream:
|
|
stream.write(json.dumps(receipt,indent=2)+'\n')
|
|
print(json.dumps({'name':name,'mode':mode,'members':len(names),'source':record['source']}))
|