chore: SETUP.md + 测试报告脚本 + 文档更新

- SETUP.md: 完整环境搭建指南(同事用)
- SETUP_QUICK.md: 快速搭环境(4步)
- s22~s26: TNA端到端、覆盖率报告、回归检查
- procedure_grammar.lark: 实验性Lark语法

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
NB-076
2026-06-25 08:50:17 +08:00
parent 56d1cf5e78
commit 50995d3335
25 changed files with 6861 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
"""Coverage measurement using Python coverage API (avoids CLI issues)"""
import sys, os, glob
# Start coverage
import coverage
cov = coverage.Coverage(omit=["test-data/*", "__pycache__/*", "tests/*", "coverage_report/*"])
cov.start()
# Import ALL production modules first
modules = []
for root, dirs, files in os.walk("."):
if "__pycache__" in root or "test-data" in root or ".git" in root or "coverage_report" in root:
continue
for f in files:
if f.endswith(".py") and not f.startswith("test_"):
path = os.path.join(root, f).replace("\\", "/")[2:].replace("/", ".").replace(".py", "")
try:
__import__(path)
modules.append(path)
except Exception as e:
pass
print(f"Pre-loaded {len(modules)} modules")
# Import and run test routines
def run_test(path):
try:
with open(path, encoding="utf-8-sig") as f:
exec(compile(open(path, encoding="utf-8-sig").read(), path, 'exec'), {})
return True
except SystemExit:
return True
except Exception as e:
print(f" FAIL {path}: {e}")
return False
# Run test files
tests = [
"test-data/round2_remaining_tests.py",
"test-data/round3_deep_coverage.py",
"test-data/r4_deep_coverage.py",
"test-data/r4_design_coverage.py",
"test-data/r4_cond_coverage.py",
"test-data/r4_coverage_coverage.py",
"test-data/r5_integration_coverage.py",
"test-data/r6_deep_coverage.py",
"test-data/r7_final_deep.py",
"test-data/r8_env_coverage.py",
"test-data/r9_deep_coverage.py",
"test-data/r10_pipeline_agent.py",
"test-data/r11_real_verification.py",
"test-data/r12_real_cobol_pipeline.py",
"test-data/r12b_orchestrator_e2e.py",
"test-data/r13_final_sweep.py",
]
print("Running tests...")
for t in tests:
sys.stdout.flush()
run_test(t)
sys.stdout.flush()
# Stop coverage
cov.stop()
cov.save()
# Generate report
print("\n" + "=" * 70)
print("COVERAGE REPORT (line coverage)")
print("=" * 70)
total = cov.report(show_missing=True, file=sys.stdout)
# Find files with < 50% coverage
print("\n" + "=" * 70)
print("FILES WITH < 50% COVERAGE")
print("=" * 70)
data = cov.get_data()
low_coverage = []
for f in data.measured_files():
if "test-data" in f or "__pycache__" in f or ".git" in f or "coverage_report" in f:
continue
try:
analysis = cov._analyze(cov._get_file_reporter(f))
total = analysis.numbers.n_statements
executed = analysis.numbers.n_executed
if total > 0 and executed / total < 0.5:
low_coverage.append((f, executed, total, executed/total*100))
except:
pass
low_coverage.sort(key=lambda x: x[3])
for f, e, t, p in low_coverage[:30]:
print(f" {f:55s} {e:4d}/{t:4d} ({p:.0f}%)")
# Generate HTML
cov.html_report(directory="coverage_report")
print(f"\nHTML report: coverage_report/index.html")