-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-all.py
More file actions
109 lines (93 loc) · 4.01 KB
/
Copy pathverify-all.py
File metadata and controls
109 lines (93 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python3
"""Verify all 16 Evolver CLI tools install and run correctly."""
import subprocess, sys, os, tempfile, shutil
WHEEL_DIR = "/root/evolver-packages/wheels"
WHEELS = sorted(os.listdir(WHEEL_DIR))
# Each tool: (entry_point_name, test_command)
TOOLS = {
"sysmon": (["sysmon", "--help"], "终端系统监控"),
"smellfinder": (["smellfinder", "--help"], "代码异味检测"),
"project-doctor": (["project-doctor", "--help"], "项目健康检查"),
"web-summary": (["web-summary", "--help"], "网页摘要"),
"csv-stats": (["csv-stats", "--help"], "CSV 分析"),
"jsonql": (["jsonql", "--help"], "JSON 查询"),
"chart-cli": (["chart-cli", "--help"], "终端图表"),
"siege-lite": (["siege-lite", "--help"], "压力测试"),
"ren": (["ren", "--help"], "批量重命名"),
"nb": (["nb", "--help"], "命令行笔记"),
"license-cli": (["license-cli", "--help"], "许可证生成"),
"markdown-check": (["markdown-check", "--check", "README.md", "--help"], "Markdown 检查"),
"envcheck": (["envcheck", "--help"], "环境变量验证"),
"dirsize": (["dirsize", "--help"], "目录空间分析"),
"passgen": (["passgen", "--help"], "密码生成"),
"timer": (["timer", "--help"], "终端计时器"),
}
results = {"pass": [], "fail": [], "skip": []}
venv_dir = tempfile.mkdtemp(prefix="evo-verify-")
print(f"🔨 创建虚拟环境: {venv_dir}")
subprocess.run([sys.executable, "-m", "venv", venv_dir], check=True)
# Determine pip/python paths
if os.name == "nt":
pip = os.path.join(venv_dir, "Scripts", "pip")
py = os.path.join(venv_dir, "Scripts", "python")
else:
pip = os.path.join(venv_dir, "bin", "pip")
py = os.path.join(venv_dir, "bin", "python")
# Upgrade pip
print("\n📦 升级 pip...")
subprocess.run([pip, "install", "--upgrade", "pip", "-q"], capture_output=True)
for w in WHEELS:
name = w.split("-")[0].replace("_", "-")
print(f"\n{'='*60}")
print(f"📦 {name}")
print(f"{'='*60}")
wheel_path = os.path.join(WHEEL_DIR, w)
# Install
r = subprocess.run([pip, "install", wheel_path, "-q"], capture_output=True, text=True)
if r.returncode != 0:
print(f" ❌ 安装失败: {r.stderr[:200]}")
results["fail"].append((name, "install", r.stderr[:200]))
continue
# Check entry point exists
r2 = subprocess.run([py, "-m", "pip", "show", name.split(".")[0]], capture_output=True, text=True)
# Run test
cmd_info = TOOLS.get(name)
if cmd_info is None:
print(f" ⚠️ 未知工具, 跳过测试")
results["skip"].append(name)
continue
cmd, desc = cmd_info
try:
r3 = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
output = r3.stdout + r3.stderr
if r3.returncode == 0 or "usage:" in output.lower() or "usage:" in r3.stdout.lower():
print(f" ✅ {desc}: OK (exit={r3.returncode})")
results["pass"].append(name)
else:
print(f" ⚠️ {desc}: 运行但返回码={r3.returncode}")
print(f" stderr: {r3.stderr[:150]}")
results["fail"].append((name, "runtime", r3.stderr[:150]))
except FileNotFoundError as e:
print(f" ❌ 命令未找到: {e}")
results["fail"].append((name, "not-found", str(e)))
except subprocess.TimeoutExpired:
print(f" ⚠️ 超时 (可能为交互式)")
results["pass"].append(name)
# Summary
print(f"\n{'='*60}")
print(f"📊 验证结果")
print(f"{'='*60}")
print(f" ✅ 通过: {len(results['pass'])}")
print(f" ❌ 失败: {len(results['fail'])}")
print(f" ⏭️ 跳过: {len(results['skip'])}")
for n in results["pass"]:
print(f" ✅ {n}")
for n, stage, err in results["fail"]:
print(f" ❌ {n} ({stage}): {err[:100]}")
for n in results["skip"]:
print(f" ⏭️ {n}")
# Cleanup
shutil.rmtree(venv_dir, ignore_errors=True)
print(f"\n🧹 已清理临时环境")
if results["fail"]:
sys.exit(1)