P0-8 扩大: do_mode.py finish_worker 全专家插件强制路由 - GUI→XDB, network→NDB, C/C++→SDB, done→Rvr, blocked/failed→Dbg - 证据去重: 已有 xdbSessions/ndbSessions/sdbReports/rvrReviewed 则跳过 P1-GAP17: 事件 emit 规范化 - 新增 7 个事件常量 (TASK_ENTERED, TASK_FINISHED, ENGINE_ENTERED 等) - 全部 emit 调用替换字符串字面量为常量,零残留 - 30 个事件类型常量全部定义且唯一 P1-GAP18: 事件日志原子轮转 - emit 计数器每 128 次检查轮转,避免每次 emit 读文件 - 清除未使用的 _emit_with_completion/_pending_merge_complete - 原子轮转: tempfile+os.replace 保证不损坏 eng 极端接管: 强制调用全部专家插件 (Dbg/XDB/NDB/SDB/Rvr) commands/do.md: 更新为全专家插件路由文档 全量测试: 69 通过, 0 失败 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
166 lines
4.1 KiB
Python
Executable File
166 lines
4.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Dep/Tst/Sec/Rvr Mode 功能测试"""
|
|
|
|
import sys
|
|
import os
|
|
import tempfile
|
|
import json
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent / "lib"))
|
|
|
|
def test_dep_main():
|
|
"""测试部署器 CLI"""
|
|
import argparse
|
|
from air_runtime.modes.dep_mode import main as dep_main
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
args = argparse.Namespace(project=tmpdir, sub="status", task_id="", host="", binary="")
|
|
try:
|
|
dep_main(args)
|
|
except SystemExit:
|
|
pass
|
|
|
|
print("✓ Dep CLI 测试通过")
|
|
return True
|
|
|
|
|
|
def test_tst_main():
|
|
"""测试测试运行器 CLI"""
|
|
import argparse
|
|
from air_runtime.modes.tst_mode import main as tst_main
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
args = argparse.Namespace(project=tmpdir, sub="status", task_id="", framework="")
|
|
try:
|
|
tst_main(args)
|
|
except SystemExit:
|
|
pass
|
|
|
|
print("✓ Tst CLI 测试通过")
|
|
return True
|
|
|
|
|
|
def test_tst_framework_detection():
|
|
"""测试测试框架检测"""
|
|
from air_runtime.test_runtime import TestRunner
|
|
|
|
runner = TestRunner()
|
|
|
|
assert "pytest" in runner.FRAMEWORKS
|
|
assert "googletest" in runner.FRAMEWORKS
|
|
assert "go" in runner.FRAMEWORKS
|
|
assert "cargo" in runner.FRAMEWORKS
|
|
|
|
print("✓ 测试框架检测测试通过")
|
|
return True
|
|
|
|
|
|
def test_sec_main():
|
|
"""测试安全扫描器 CLI"""
|
|
import argparse
|
|
from air_runtime.modes.sec_mode import main as sec_main
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
args = argparse.Namespace(project=tmpdir, sub="status", task_id="", scan_path="", sec_mode="blocking")
|
|
try:
|
|
sec_main(args)
|
|
except SystemExit:
|
|
pass
|
|
|
|
print("✓ Sec CLI 测试通过")
|
|
return True
|
|
|
|
|
|
def test_sec_rules():
|
|
"""测试安全规则"""
|
|
from air_runtime.sec_runtime import scan_file
|
|
|
|
# scan_file 函数存在即可
|
|
assert callable(scan_file)
|
|
|
|
print("✓ 安全规则测试通过")
|
|
return True
|
|
|
|
|
|
def test_rvr_main():
|
|
"""测试需求审查器 CLI"""
|
|
import argparse
|
|
from air_runtime.modes.rvr_mode import main as rvr_main
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
args = argparse.Namespace(project=tmpdir, sub="status", task_id="")
|
|
try:
|
|
rvr_main(args)
|
|
except SystemExit:
|
|
pass
|
|
|
|
print("✓ Rvr CLI 测试通过")
|
|
return True
|
|
|
|
|
|
def test_rvr_report():
|
|
"""测试审查报告生成"""
|
|
from air_runtime.review_runtime import ReviewRuntime, ReviewReport, RequirementCoverage
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
project_root = Path(tmpdir)
|
|
|
|
rvr = ReviewRuntime(project_root)
|
|
|
|
report = ReviewReport(
|
|
task_id="T-001",
|
|
verdict="pass",
|
|
coverage=[
|
|
RequirementCoverage(requirement="功能完整", status="covered"),
|
|
],
|
|
)
|
|
|
|
report_path = rvr.save_report(report)
|
|
assert report_path.exists()
|
|
|
|
verdict = rvr.get_integration_verdict(report)
|
|
assert verdict == "pass"
|
|
|
|
print("✓ 审查报告生成测试通过")
|
|
return True
|
|
|
|
|
|
def main():
|
|
print("=" * 50)
|
|
print("Dep/Tst/Sec/Rvr Mode 功能测试")
|
|
print("=" * 50)
|
|
|
|
tests = [
|
|
("Dep CLI", test_dep_main),
|
|
("Tst CLI", test_tst_main),
|
|
("测试框架检测", test_tst_framework_detection),
|
|
("Sec CLI", test_sec_main),
|
|
("安全规则", test_sec_rules),
|
|
("Rvr CLI", test_rvr_main),
|
|
("审查报告生成", test_rvr_report),
|
|
]
|
|
|
|
passed = 0
|
|
failed = 0
|
|
|
|
for name, test_fn in tests:
|
|
try:
|
|
test_fn()
|
|
passed += 1
|
|
except Exception as e:
|
|
print(f"✗ {name} 失败: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
failed += 1
|
|
|
|
print("=" * 50)
|
|
print(f"测试结果: {passed} 通过, {failed} 失败")
|
|
print("=" * 50)
|
|
|
|
return failed == 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
success = main()
|
|
sys.exit(0 if success else 1) |