tradingSystem/scripts/run_tests.py

42 lines
1.3 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""
全部单测一次跑完 (零外部依赖, 不连库)
======================================
运行: docker compose run --rm pms-web python scripts/run_tests.py
包含:
test_core_units.py 仓位规划器 / 安全垫与成本账 (14 )
test_batch2_units.py 命令状态机 / 方案生成器 / 回放对账纯逻辑 (35 )
test_wiring.py 装配自检: 服务层核心落表 全链路 (内存桩) (18 )
任一子集失败即整体失败 (退出码 1)
"""
import os
import subprocess
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(HERE)
SUITES = ["test_core_units.py", "test_batch2_units.py", "test_wiring.py"]
def main():
failed = []
for s in SUITES:
path = os.path.join(HERE, s)
if not os.path.exists(path):
print(f"== 跳过 {s} (文件不存在)")
continue
print(f"\n=== {s} " + "=" * (52 - len(s)))
r = subprocess.run([sys.executable, path], cwd=ROOT)
if r.returncode != 0:
failed.append(s)
print("\n" + "=" * 62)
if failed:
print(f"SUITE FAILED: {', '.join(failed)}")
sys.exit(1)
print("ALL SUITES PASS")
if __name__ == "__main__":
main()