forked from rtk-ai/rtk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-aristote.sh
More file actions
executable file
·227 lines (171 loc) · 8.71 KB
/
Copy pathtest-aristote.sh
File metadata and controls
executable file
·227 lines (171 loc) · 8.71 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/usr/bin/env bash
#
# RTK Smoke Tests — Aristote Project (Vite + React + TS + ESLint)
# Tests RTK commands in a real JS/TS project context.
# Usage: bash scripts/test-aristote.sh
#
set -euo pipefail
ARISTOTE="/Users/florianbruniaux/Sites/MethodeAristote/aristote-school-boost"
PASS=0
FAIL=0
SKIP=0
FAILURES=()
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
assert_ok() {
local name="$1"; shift
local output
if output=$("$@" 2>&1); then
PASS=$((PASS + 1))
printf " ${GREEN}PASS${NC} %s\n" "$name"
else
FAIL=$((FAIL + 1))
FAILURES+=("$name")
printf " ${RED}FAIL${NC} %s\n" "$name"
printf " cmd: %s\n" "$*"
printf " out: %s\n" "$(echo "$output" | head -3)"
fi
}
assert_contains() {
local name="$1"; local needle="$2"; shift 2
local output
if output=$("$@" 2>&1) && echo "$output" | grep -q "$needle"; then
PASS=$((PASS + 1))
printf " ${GREEN}PASS${NC} %s\n" "$name"
else
FAIL=$((FAIL + 1))
FAILURES+=("$name")
printf " ${RED}FAIL${NC} %s\n" "$name"
printf " expected: '%s'\n" "$needle"
printf " got: %s\n" "$(echo "$output" | head -3)"
fi
}
# Allow non-zero exit but check output
assert_output() {
local name="$1"; local needle="$2"; shift 2
local output
output=$("$@" 2>&1) || true
if echo "$output" | grep -q "$needle"; then
PASS=$((PASS + 1))
printf " ${GREEN}PASS${NC} %s\n" "$name"
else
FAIL=$((FAIL + 1))
FAILURES+=("$name")
printf " ${RED}FAIL${NC} %s\n" "$name"
printf " expected: '%s'\n" "$needle"
printf " got: %s\n" "$(echo "$output" | head -3)"
fi
}
skip_test() {
local name="$1"; local reason="$2"
SKIP=$((SKIP + 1))
printf " ${YELLOW}SKIP${NC} %s (%s)\n" "$name" "$reason"
}
section() {
printf "\n${BOLD}${CYAN}── %s ──${NC}\n" "$1"
}
# ── Preamble ─────────────────────────────────────────
RTK=$(command -v rtk || echo "")
if [[ -z "$RTK" ]]; then
echo "rtk not found in PATH. Run: cargo install --path ."
exit 1
fi
if [[ ! -d "$ARISTOTE" ]]; then
echo "Aristote project not found at $ARISTOTE"
exit 1
fi
printf "${BOLD}RTK Smoke Tests — Aristote Project${NC}\n"
printf "Binary: %s (%s)\n" "$RTK" "$(rtk --version)"
printf "Project: %s\n" "$ARISTOTE"
printf "Date: %s\n\n" "$(date '+%Y-%m-%d %H:%M')"
# ── 1. File exploration ──────────────────────────────
section "Ls & Find"
assert_ok "rtk ls project root" rtk ls "$ARISTOTE"
assert_ok "rtk ls src/" rtk ls "$ARISTOTE/src"
assert_ok "rtk ls --depth 3" rtk ls --depth 3 "$ARISTOTE/src"
assert_contains "rtk ls shows components/" "components" rtk ls "$ARISTOTE/src"
assert_ok "rtk find *.tsx" rtk find "*.tsx" "$ARISTOTE/src"
assert_ok "rtk find *.ts" rtk find "*.ts" "$ARISTOTE/src"
assert_contains "rtk find finds App.tsx" "App.tsx" rtk find "*.tsx" "$ARISTOTE/src"
# ── 2. Read ──────────────────────────────────────────
section "Read"
assert_ok "rtk read tsconfig.json" rtk read "$ARISTOTE/tsconfig.json"
assert_ok "rtk read package.json" rtk read "$ARISTOTE/package.json"
assert_ok "rtk read App.tsx" rtk read "$ARISTOTE/src/App.tsx"
assert_ok "rtk read --level aggressive" rtk read --level aggressive "$ARISTOTE/src/App.tsx"
assert_ok "rtk read --max-lines 10" rtk read --max-lines 10 "$ARISTOTE/src/App.tsx"
# ── 3. Grep ──────────────────────────────────────────
section "Grep"
assert_ok "rtk grep import" rtk grep "import" "$ARISTOTE/src"
assert_ok "rtk grep with type filter" rtk grep "useState" "$ARISTOTE/src" -t tsx
assert_contains "rtk grep finds components" "import" rtk grep "import" "$ARISTOTE/src"
# ── 4. Git ───────────────────────────────────────────
section "Git (in Aristote repo)"
# rtk git doesn't support -C, use git -C via subshell
assert_ok "rtk git status" bash -c "cd $ARISTOTE && rtk git status"
assert_ok "rtk git log" bash -c "cd $ARISTOTE && rtk git log"
assert_ok "rtk git branch" bash -c "cd $ARISTOTE && rtk git branch"
# ── 5. Deps ──────────────────────────────────────────
section "Deps"
assert_ok "rtk deps" rtk deps "$ARISTOTE"
assert_contains "rtk deps shows package.json" "package.json" rtk deps "$ARISTOTE"
# ── 6. Json ──────────────────────────────────────────
section "Json"
assert_ok "rtk json tsconfig" rtk json "$ARISTOTE/tsconfig.json"
assert_ok "rtk json package.json" rtk json "$ARISTOTE/package.json"
# ── 7. Env ───────────────────────────────────────────
section "Env"
assert_ok "rtk env" rtk env
assert_ok "rtk env --filter NODE" rtk env --filter NODE
# ── 8. Tsc ───────────────────────────────────────────
section "TypeScript (tsc)"
if command -v npx >/dev/null 2>&1 && [[ -d "$ARISTOTE/node_modules" ]]; then
assert_output "rtk tsc (in aristote)" "error\|✅\|TS" rtk tsc --project "$ARISTOTE"
else
skip_test "rtk tsc" "node_modules not installed"
fi
# ── 9. ESLint ────────────────────────────────────────
section "ESLint (lint)"
if command -v npx >/dev/null 2>&1 && [[ -d "$ARISTOTE/node_modules" ]]; then
assert_output "rtk lint (in aristote)" "error\|warning\|✅\|violations\|clean" rtk lint --project "$ARISTOTE"
else
skip_test "rtk lint" "node_modules not installed"
fi
# ── 10. Build (Vite) ─────────────────────────────────
section "Build (Vite via rtk next)"
if [[ -d "$ARISTOTE/node_modules" ]]; then
# Aristote uses Vite, not Next — but rtk next wraps the build script
# Test with a timeout since builds can be slow
skip_test "rtk next build" "Vite project, not Next.js — use npm run build directly"
else
skip_test "rtk next build" "node_modules not installed"
fi
# ── 11. Diff ─────────────────────────────────────────
section "Diff"
# Diff two config files that exist in the project
assert_ok "rtk diff tsconfigs" rtk diff "$ARISTOTE/tsconfig.json" "$ARISTOTE/tsconfig.app.json"
# ── 12. Summary & Err ────────────────────────────────
section "Summary & Err"
assert_ok "rtk summary ls" rtk summary ls "$ARISTOTE/src"
assert_ok "rtk err ls" rtk err ls "$ARISTOTE/src"
# ── 13. Gain ─────────────────────────────────────────
section "Gain (after above commands)"
assert_ok "rtk gain" rtk gain
assert_ok "rtk gain --history" rtk gain --history
# ══════════════════════════════════════════════════════
# Report
# ══════════════════════════════════════════════════════
printf "\n${BOLD}══════════════════════════════════════${NC}\n"
printf "${BOLD}Results: ${GREEN}%d passed${NC}, ${RED}%d failed${NC}, ${YELLOW}%d skipped${NC}\n" "$PASS" "$FAIL" "$SKIP"
if [[ ${#FAILURES[@]} -gt 0 ]]; then
printf "\n${RED}Failures:${NC}\n"
for f in "${FAILURES[@]}"; do
printf " - %s\n" "$f"
done
fi
printf "${BOLD}══════════════════════════════════════${NC}\n"
exit "$FAIL"