feat: complete native BOM and Harness execution acceptance
This commit is contained in:
1 parent
4f8fbd7806
commit
65438cb7e5
234 files changed
+24402
-865
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
spec = importlib.util.spec_from_file_location('random_cases', Path(__file__).parents[2] / 'tools/random_acceptance_cases.py')
|
||||
generator = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(generator)
|
||||
|
||||
|
||||
def normalized(cases):
|
||||
return [{k: v for k, v in case.items() if k != 'directory'} for case in cases]
|
||||
|
||||
|
||||
def test_seed_replay_and_semantic_variation(tmp_path):
|
||||
seed, first = generator.generate(tmp_path / 'a', 1234)
|
||||
_, replay = generator.generate(tmp_path / 'b', seed)
|
||||
_, fresh = generator.generate(tmp_path / 'c', 5678)
|
||||
assert normalized(first) == normalized(replay)
|
||||
assert all(a['input_hashes'] != b['input_hashes'] for a,b in zip(first, fresh))
|
||||
assert {case['stratum'] for case in first} == set(generator.STRATA)
|
||||
|
||||
|
||||
def test_independent_literals_and_private_oracles(tmp_path):
|
||||
_, cases = generator.generate(tmp_path / 'inputs', 1234)
|
||||
by_kind = {c['stratum']: c for c in cases}
|
||||
totals = by_kind['totals']
|
||||
# Independent CSV read, not generator-derived expectation.
|
||||
import csv
|
||||
with (Path(totals['directory']) / 'bom.csv').open(encoding='utf-8') as stream:
|
||||
rows = list(csv.DictReader(stream))
|
||||
actual = {}
|
||||
for row in rows:
|
||||
actual[row['part']] = actual.get(row['part'], 0) + int(row['quantity'])
|
||||
actual['total'] = sum(int(row['quantity']) for row in rows)
|
||||
assert totals['expected']['result.json'] == actual
|
||||
assert by_kind['missing-file']['expected'] == {'result.json': {'status': 'missing', 'content': None}}
|
||||
assert by_kind['repair-json']['expected']['result.json'] == {'refdes': 'R204', 'part': 'NEW-819394'}
|
||||
for case in cases:
|
||||
directory = Path(case['directory'])
|
||||
assert not (directory / 'result.json').exists()
|
||||
assert not (directory / 'manifest.json').exists()
|
||||
assert {str(p.relative_to(directory)).replace('\\', '/') for p in directory.rglob('*') if p.is_file()} == set(case['input_hashes'])
|
||||
for filename, digest in case['input_hashes'].items():
|
||||
assert hashlib.sha256((directory / filename).read_bytes()).hexdigest() == digest
|
||||
|
||||
|
||||
def test_minimum_and_fresh_system_seeds(tmp_path):
|
||||
with pytest.raises(ValueError):
|
||||
generator.generate(tmp_path / 'small', count=19)
|
||||
a, _ = generator.generate(tmp_path / 'a')
|
||||
b, _ = generator.generate(tmp_path / 'b')
|
||||
assert a != b
|
||||
Reference in new issue
Block a user