refactor: implement concrete Delivery responsibility dispositions
This commit is contained in:
1 parent
cb6b41f1a5
commit
1bff2cefab
23 files changed
+231
-717
No files matched your search
@@ -1,45 +1,7 @@
|
||||
"""Run every unittest, standalone test function and main-style contract."""
|
||||
"""Validate the current bounded source contract, not full-program completion."""
|
||||
from pathlib import Path
|
||||
import importlib.util
|
||||
import inspect
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
import subprocess,sys
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
TESTS=Path(__file__).resolve().parent
|
||||
sys.path.insert(0, str(TESTS))
|
||||
suite=unittest.TestSuite()
|
||||
modules=[]
|
||||
for path in sorted(TESTS.glob('test_*.py')):
|
||||
spec=importlib.util.spec_from_file_location('verify_'+path.stem,path)
|
||||
assert spec is not None and spec.loader is not None
|
||||
module=importlib.util.module_from_spec(spec)
|
||||
sys.modules[spec.name]=module
|
||||
spec.loader.exec_module(module)
|
||||
modules.append(module)
|
||||
suite.addTests(unittest.defaultTestLoader.loadTestsFromModule(module))
|
||||
result=unittest.TextTestRunner(verbosity=1).run(suite)
|
||||
if not result.wasSuccessful(): sys.exit(1)
|
||||
standalone=0
|
||||
for module in modules:
|
||||
for name,fn in inspect.getmembers(module,inspect.isfunction):
|
||||
if name.startswith('test_') or name=='main':
|
||||
fn()
|
||||
standalone+=1
|
||||
files=[ROOT/'SKILL.md',*sorted(ROOT.glob('references/*.md'))]
|
||||
links=0
|
||||
for path in files:
|
||||
for link in re.findall(r'\]\(([^)]+)\)',path.read_text()):
|
||||
if '://' in link or link.startswith(('#','<')): continue
|
||||
target=link.split('#')[0]
|
||||
if target:
|
||||
assert (path.parent/target).exists(),(path,link)
|
||||
links+=1
|
||||
subprocess.run(['git','diff','--check'],cwd=ROOT,check=True)
|
||||
before=sum(len(subprocess.check_output(['git','show','HEAD:'+str(p.relative_to(ROOT))],cwd=ROOT)) for p in files)
|
||||
after=sum(p.stat().st_size for p in files)
|
||||
ref_before=before-len(subprocess.check_output(['git','show','HEAD:SKILL.md'],cwd=ROOT))
|
||||
ref_after=after-(ROOT/'SKILL.md').stat().st_size
|
||||
print(json.dumps({'package':ROOT.name,'unittest':result.testsRun,'standalone':standalone,'total':result.testsRun+standalone,'local_links':links,'diff_check':'passed','operational_bytes_before':before,'operational_bytes_after':after,'reference_bytes_before':ref_before,'reference_bytes_after':ref_after},indent=2))
|
||||
if __name__=='__main__':
|
||||
print('Source-contract checks only; A02/A04/A17 and deferred helpers are not completion claims.',flush=True)
|
||||
subprocess.run([sys.executable,'-m','pytest','-q',str(Path(__file__).parent)],cwd=ROOT,check=True)
|
||||
Reference in new issue
Block a user