-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·182 lines (148 loc) · 4.8 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·182 lines (148 loc) · 4.8 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
#!/usr/bin/env bash
# test.sh — Run main.py --testing with different flag combinations.
#
# Usage:
# ./test.sh # Run all tests
# ./test.sh preflight # Check LLM, embedding, book APIs
# ./test.sh pipeline # Full run, all test books
# ./test.sh filter # Filter flag tests
# ./test.sh tracker # Skip/force behavior
# ./test.sh quick # Single easy book
# ./test.sh region # UK region fallback
# ./test.sh cleaning # Title cleaning tests
# ./test.sh hard # Books expected to fail
set -e
DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$DIR"
GREEN='\033[32m'
RED='\033[31m'
CYAN='\033[36m'
BOLD='\033[1m'
RESET='\033[0m'
PASS=0
FAIL=0
run_test() {
local name="$1"
shift
echo ""
echo -e "${CYAN}--- TEST: ${name} ---${RESET}"
echo -e " cmd: python main.py --testing $*"
if python main.py --testing "$@"; then
echo -e " ${GREEN}OK${RESET}"
((PASS++))
else
echo -e " ${RED}FAILED${RESET}"
((FAIL++))
fi
}
clean() {
rm -f processed_test.json
}
# ============================================================
# Suites
# ============================================================
test_preflight() {
echo -e "\n${BOLD}========== SUITE: preflight — check services ==========${RESET}"
if python3 preflight.py; then
((PASS++))
else
((FAIL++))
fi
}
test_pipeline() {
echo -e "\n${BOLD}========== SUITE: pipeline — full run, all books ==========${RESET}"
clean
run_test "all books, force" --force
}
test_filter() {
echo -e "\n${BOLD}========== SUITE: filter — author/series/title flags ==========${RESET}"
clean
run_test "filter --author Flanagan" --force --author "Flanagan"
clean
run_test "filter --author Tolkien" --force --author "Tolkien"
clean
run_test "filter --series Dune" --force --series "Dune"
clean
run_test "filter --title Hobbit" --force --title "Hobbit"
clean
run_test "filter --author Tolkien --title Hobbit" --force --author "Tolkien" --title "Hobbit"
clean
run_test "filter --author Herbert --series Dune" --force --author "Herbert" --series "Dune"
clean
run_test "filter --author NonexistentAuthor (expect 0 total)" --force --author "Zzzzzzzz"
}
test_tracker() {
echo -e "\n${BOLD}========== SUITE: tracker — skip/force behavior ==========${RESET}"
clean
run_test "tracker: first run (populates)" --force --title "Hail Mary"
run_test "tracker: second run (should skip)" --title "Hail Mary"
run_test "tracker: third run with --force (should reprocess)" --force --title "Hail Mary"
}
test_quick() {
echo -e "\n${BOLD}========== SUITE: quick — single easy book ==========${RESET}"
clean
run_test "quick: The Hobbit" --force --title "The Hobbit" --author "Tolkien"
}
test_region() {
echo -e "\n${BOLD}========== SUITE: region — UK region fallback ==========${RESET}"
clean
run_test "region: Icebound Land (needs UK)" --force --title "Icebound"
}
test_cleaning() {
echo -e "\n${BOLD}========== SUITE: cleaning — titles that need clean_title ==========${RESET}"
clean
run_test "cleaning: 'Dune 01 - Dune'" --force --title "Dune 01"
clean
run_test "cleaning: series suffix" --force --title "Lost Stories"
clean
run_test "cleaning: MI prefix" --force --title "City of Fallen"
}
test_hard() {
echo -e "\n${BOLD}========== SUITE: hard — books expected to fail ==========${RESET}"
clean
run_test "hard: Tolkien Reads and Sings (obscure)" --force --title "Tolkien Reads"
clean
run_test "hard: Oakleaf Bearers (AU title)" --force --title "Oakleaf"
clean
run_test "hard: Poems and Songs (should not false-match)" --force --title "Poems and Songs"
}
# ============================================================
# Main
# ============================================================
SUITE="${1:-all}"
case "$SUITE" in
all)
test_preflight
test_pipeline
test_filter
test_tracker
test_quick
test_region
test_cleaning
test_hard
;;
preflight) test_preflight ;;
pipeline) test_pipeline ;;
filter) test_filter ;;
tracker) test_tracker ;;
quick) test_quick ;;
region) test_region ;;
cleaning) test_cleaning ;;
hard) test_hard ;;
*)
echo "Unknown suite: $SUITE"
echo "Available: all, preflight, pipeline, filter, tracker, quick, region, cleaning, hard"
exit 1
;;
esac
# Summary
echo ""
echo -e "${BOLD}============================================${RESET}"
if [ "$FAIL" -eq 0 ]; then
echo -e " ${GREEN}ALL $PASS TESTS PASSED${RESET}"
else
echo -e " ${RED}$FAIL FAILED${RESET} / $((PASS + FAIL)) total"
fi
echo -e "${BOLD}============================================${RESET}"
clean
[ "$FAIL" -eq 0 ]