forked from Panniantong/Agent-Reach
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
92 lines (79 loc) · 3.15 KB
/
test.sh
File metadata and controls
92 lines (79 loc) · 3.15 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
#!/bin/bash
# Agent Reach 一键完整测试
# 用法: bash test-agent-reach.sh
# 在任何有 Python 3.10+ 的机器上跑就行
set -e
echo "╔════════════════════════════════════════════╗"
echo "║ 👁️ Agent Reach 完整测试 ║"
echo "╚════════════════════════════════════════════╝"
echo ""
# ── 1. 准备干净环境 ──
echo "📦 创建测试环境..."
TEST_DIR=$(mktemp -d)
python3 -m venv "$TEST_DIR/venv"
source "$TEST_DIR/venv/bin/activate"
# ── 2. 安装 ──
echo "📥 从 GitHub 安装..."
pip install -q https://github.com/Panniantong/agent-reach/archive/main.zip 2>&1 | tail -1
echo ""
# ── 3. 自动配置 ──
echo "⚙️ 运行 install..."
agent-reach install --env=auto 2>&1
echo ""
# ── 4. 诊断 ──
echo "🩺 运行 doctor..."
agent-reach doctor 2>&1
echo ""
# ── 5. 逐个测试 ──
PASS=0
FAIL=0
SKIP=0
test_it() {
local name="$1"
shift
echo -n " $name ... "
output=$(eval "$@" 2>&1) || true
if echo "$output" | grep -q "📖\|🔗\|http"; then
echo "✅"
PASS=$((PASS+1))
elif echo "$output" | grep -q "⚠️\|not installed\|not configured"; then
echo "⏭️ (跳过 — 缺依赖)"
SKIP=$((SKIP+1))
else
echo "❌"
echo " $(echo "$output" | head -2)"
FAIL=$((FAIL+1))
fi
}
echo "📖 阅读测试"
test_it "网页" "agent-reach read 'https://example.com'"
test_it "GitHub" "agent-reach read 'https://github.com/Panniantong/agent-reach'"
test_it "YouTube" "agent-reach read 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'"
test_it "B站" "agent-reach read 'https://www.bilibili.com/video/BV1d4411N7zD'"
test_it "RSS" "agent-reach read 'https://hnrss.org/frontpage'"
test_it "Twitter" "agent-reach read 'https://x.com/elonmusk/status/1893797839927353448'"
test_it "Reddit" "agent-reach read 'https://www.reddit.com/r/LocalLLaMA/hot'"
echo ""
echo "🔍 搜索测试"
test_it "全网搜索" "agent-reach search 'best AI agent framework' -n 2"
test_it "GitHub搜索" "agent-reach search-github 'yt-dlp' -n 2"
test_it "Twitter搜索" "agent-reach search-twitter 'AI agent' -n 2"
test_it "Reddit搜索" "agent-reach search-reddit 'machine learning' -n 2"
test_it "YouTube搜索" "agent-reach search-youtube 'AI tutorial' -n 2"
test_it "B站搜索" "agent-reach search-bilibili 'AI' -n 2"
test_it "小红书搜索" "agent-reach search-xhs 'AI' -n 2"
echo ""
echo "════════════════════════════════════════════"
echo " ✅ 通过: $PASS ❌ 失败: $FAIL ⏭️ 跳过: $SKIP"
echo "════════════════════════════════════════════"
# ── 6. 清理 ──
deactivate 2>/dev/null || true
rm -rf "$TEST_DIR"
if [ $FAIL -eq 0 ]; then
echo ""
echo "🎉 全部通过!"
else
echo ""
echo "⚠️ 有 $FAIL 个测试失败,请检查上面的输出"
exit 1
fi