fix(autotest): remove set -e that killed script on ((i++)); add full summary report with working+failed strategies; fix version norm + headless xdg-open
This commit is contained in:
62
autotest.sh
62
autotest.sh
@@ -1,8 +1,7 @@
|
||||
#!/bin/bash
|
||||
# autotest.sh - Automatic strategy tester v3
|
||||
# autotest.sh - Automatic strategy tester v4
|
||||
# Modes: --auto, --list-all, interactive
|
||||
|
||||
set -e
|
||||
# FIXED: removed set -e which caused exit on ((i++)) when i=0
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/lib/functions.sh"
|
||||
@@ -32,7 +31,7 @@ test_strategy() {
|
||||
IFS="|" read -r url name <<< "$entry"
|
||||
if test_url "$url"; then
|
||||
echo " $(print_green "[OK]") $name"
|
||||
((passed++))
|
||||
passed=$((passed + 1))
|
||||
else
|
||||
echo " $(print_red "[FAIL]") $name"
|
||||
fi
|
||||
@@ -141,33 +140,53 @@ main() {
|
||||
sleep 1
|
||||
|
||||
local working_strategies=() working_descs=() first_working=""
|
||||
local failed_strategies=() failed_descs=()
|
||||
|
||||
for strat in "${STRATEGIES[@]}"; do
|
||||
if run_strategy_test "$strat"; then
|
||||
working_strategies+=("$strat")
|
||||
working_descs+=("$(describe_strategy "$SCRIPT_DIR/general_${strat}.sh")")
|
||||
[[ -z "$first_working" ]] && first_working="$strat"
|
||||
else
|
||||
failed_strategies+=("$strat")
|
||||
failed_descs+=("$(describe_strategy "$SCRIPT_DIR/general_${strat}.sh")")
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=============================================="
|
||||
if [[ ${#working_strategies[@]} -gt 0 ]]; then
|
||||
print_green " WORKING STRATEGIES FOUND: ${#working_strategies[@]}"
|
||||
echo "=============================================="
|
||||
echo ""
|
||||
|
||||
# Summary report
|
||||
echo "[*] TEST SUMMARY"
|
||||
echo ""
|
||||
echo " Total tested: ${#STRATEGIES[@]}"
|
||||
echo " Working: ${#working_strategies[@]}"
|
||||
echo " Failed: ${#failed_strategies[@]}"
|
||||
echo ""
|
||||
|
||||
# Working strategies
|
||||
if [[ ${#working_strategies[@]} -gt 0 ]]; then
|
||||
echo "=============================================="
|
||||
print_green " WORKING STRATEGIES (${#working_strategies[@]}):"
|
||||
local i=0
|
||||
for strat in "${working_strategies[@]}"; do
|
||||
echo " $(print_green "[$((i+1))]") $strat — ${working_descs[$i]}"
|
||||
((i++))
|
||||
while [[ $i -lt ${#working_strategies[@]} ]]; do
|
||||
echo " $(print_green "$((i + 1)).") ${working_strategies[$i]} — ${working_descs[$i]}"
|
||||
i=$((i + 1))
|
||||
done
|
||||
echo "=============================================="
|
||||
echo ""
|
||||
|
||||
if [[ "$mode" == "--auto" ]]; then
|
||||
install_strategy "$first_working"
|
||||
elif [[ "$mode" == "--list-all" ]]; then
|
||||
echo "[*] To install a strategy, run: sudo ./service.sh → 1. Install Service"
|
||||
echo " Or directly: sudo ./run_strategy.sh ALT3"
|
||||
echo "[*] To install any working strategy, run:"
|
||||
echo " sudo ./service.sh"
|
||||
echo " → 1. Install Service"
|
||||
echo " → Pick the number matching the strategy above"
|
||||
echo ""
|
||||
echo "[*] Or run directly without systemd:"
|
||||
echo " sudo ./run_strategy.sh ALT3 (replace ALT3 with your choice)"
|
||||
else
|
||||
echo "[*] Next steps:"
|
||||
echo " 1. Test in browser: youtube.com, discord.com"
|
||||
@@ -176,7 +195,23 @@ main() {
|
||||
read -rp "Install first working strategy ($first_working)? [Y/n]: " ans
|
||||
[[ "${ans:-Y}" == [yY]* ]] && install_strategy "$first_working"
|
||||
fi
|
||||
else
|
||||
fi
|
||||
|
||||
# Failed strategies (show only in list-all mode for completeness)
|
||||
if [[ ${#failed_strategies[@]} -gt 0 ]] && [[ "$mode" == "--list-all" ]]; then
|
||||
echo ""
|
||||
echo "=============================================="
|
||||
print_red " FAILED STRATEGIES (${#failed_strategies[@]}):"
|
||||
local j=0
|
||||
while [[ $j -lt ${#failed_strategies[@]} ]]; do
|
||||
echo " $((j + 1)). ${failed_strategies[$j]} — ${failed_descs[$j]}"
|
||||
j=$((j + 1))
|
||||
done
|
||||
echo "=============================================="
|
||||
fi
|
||||
|
||||
if [[ ${#working_strategies[@]} -eq 0 ]]; then
|
||||
echo ""
|
||||
print_red " NO WORKING STRATEGY FOUND"
|
||||
echo "=============================================="
|
||||
echo ""
|
||||
@@ -186,6 +221,7 @@ main() {
|
||||
echo " - Modify strategy parameters in strategies/*.conf"
|
||||
echo " - Run diagnostics: sudo ./service.sh → 10. Run Diagnostics"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[*] Auto-test complete."
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user