forked from rtk-ai/rtk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-tracking.sh
More file actions
executable file
·79 lines (66 loc) · 2.46 KB
/
Copy pathtest-tracking.sh
File metadata and controls
executable file
·79 lines (66 loc) · 2.46 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
#!/usr/bin/env bash
# Test tracking end-to-end: run commands, verify they appear in rtk gain --history
set -euo pipefail
# Workaround for macOS bash pipe handling in strict mode
set +e # Allow errors in pipe chains to continue
PASS=0; FAIL=0; FAILURES=()
RED='\033[0;31m'; GREEN='\033[0;32m'; NC='\033[0m'
check() {
local name="$1" 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
}
echo "═══ RTK Tracking Validation ═══"
echo ""
# 1. Commandes avec filtrage réel — doivent apparaitre dans history
echo "── Optimized commands (token savings) ──"
rtk ls . >/dev/null 2>&1
check "rtk ls tracked" "rtk ls" rtk gain --history
rtk git status >/dev/null 2>&1
check "rtk git status tracked" "rtk git status" rtk gain --history
rtk git log -5 >/dev/null 2>&1
check "rtk git log tracked" "rtk git log" rtk gain --history
# Git passthrough (timing-only)
echo ""
echo "── Passthrough commands (timing-only) ──"
rtk git tag --list >/dev/null 2>&1
check "git passthrough tracked" "git tag --list" rtk gain --history
# gh commands (if authenticated)
echo ""
echo "── GitHub CLI tracking ──"
if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
rtk gh pr list >/dev/null 2>&1 || true
check "rtk gh pr list tracked" "rtk gh pr" rtk gain --history
rtk gh run list >/dev/null 2>&1 || true
check "rtk gh run list tracked" "rtk gh run" rtk gain --history
else
echo " SKIP gh (not authenticated)"
fi
# Stdin commands
echo ""
echo "── Stdin commands ──"
echo -e "line1\nline2\nline1\nERROR: bad\nline1" | rtk log >/dev/null 2>&1
check "rtk log stdin tracked" "rtk log" rtk gain --history
# Summary — verify passthrough doesn't dilute
echo ""
echo "── Summary integrity ──"
output=$(rtk gain 2>&1)
if echo "$output" | grep -q "Tokens saved"; then
PASS=$((PASS+1)); printf " ${GREEN}PASS${NC} rtk gain summary works\n"
else
FAIL=$((FAIL+1)); printf " ${RED}FAIL${NC} rtk gain summary\n"
fi
echo ""
echo "═══ Results: ${PASS} passed, ${FAIL} failed ═══"
if [ ${#FAILURES[@]} -gt 0 ]; then
echo "Failures: ${FAILURES[*]}"
fi
exit $FAIL