fix: harden task recovery and DR contract handling
This commit is contained in:
@@ -16,8 +16,14 @@ import trace
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
CORE_TESTS = ('core_test', 'workflow_test', 'journal_failure_test', 'preflight_test',
|
||||
'settlement_test', 'proof_regression_test', 'readiness_regression_test', 'scenario_test', 'lifecycle_test')
|
||||
CORE_TESTS = tuple(path.stem for path in sorted((ROOT / 'core/tests').glob('*_test.cpp')))
|
||||
|
||||
|
||||
def executable_lines(path):
|
||||
# Python 3.14 can include artificial bytecode positions without a source
|
||||
# line; these are not executable source statements and cannot be sorted.
|
||||
return {line for line in trace._find_executable_linenos(str(path))
|
||||
if type(line) is int and line > 0}
|
||||
|
||||
|
||||
def production(path):
|
||||
@@ -35,13 +41,20 @@ def python_lines(destination):
|
||||
# are deliberately not counted as covered without an observed trace event.
|
||||
result = tracer.runfunc(unittest.TextTestRunner(verbosity=1).run, suite)
|
||||
counts = tracer.results().counts
|
||||
observed = {}
|
||||
resolved = {}
|
||||
for (filename, line), count in counts.items():
|
||||
if count <= 0:
|
||||
continue
|
||||
if filename not in resolved:
|
||||
resolved[filename] = Path(filename).resolve()
|
||||
observed.setdefault(resolved[filename], set()).add(line)
|
||||
files = []
|
||||
for path in sorted(ROOT.rglob('*.py')):
|
||||
if not production(path):
|
||||
continue
|
||||
statements = set(trace._find_executable_linenos(str(path)))
|
||||
hit = {line for (filename, line), count in counts.items()
|
||||
if Path(filename).resolve() == path and count > 0} & statements
|
||||
statements = executable_lines(path)
|
||||
hit = observed.get(path, set()) & statements
|
||||
files.append(dict(path=str(path.relative_to(ROOT)), statements=len(statements),
|
||||
covered=len(hit), missing=sorted(statements-hit)))
|
||||
data = dict(metric='Python executable source lines; main test thread only',
|
||||
|
||||
Reference in New Issue
Block a user