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:
Zapret Bot
2026-05-11 20:48:14 +04:00
parent 0cc4d9c817
commit 33ce39d354

View File

@@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# autotest.sh - Automatic strategy tester v3 # autotest.sh - Automatic strategy tester v4
# Modes: --auto, --list-all, interactive # Modes: --auto, --list-all, interactive
# FIXED: removed set -e which caused exit on ((i++)) when i=0
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/functions.sh" source "$SCRIPT_DIR/lib/functions.sh"
@@ -32,7 +31,7 @@ test_strategy() {
IFS="|" read -r url name <<< "$entry" IFS="|" read -r url name <<< "$entry"
if test_url "$url"; then if test_url "$url"; then
echo " $(print_green "[OK]") $name" echo " $(print_green "[OK]") $name"
((passed++)) passed=$((passed + 1))
else else
echo " $(print_red "[FAIL]") $name" echo " $(print_red "[FAIL]") $name"
fi fi
@@ -141,33 +140,53 @@ main() {
sleep 1 sleep 1
local working_strategies=() working_descs=() first_working="" local working_strategies=() working_descs=() first_working=""
local failed_strategies=() failed_descs=()
for strat in "${STRATEGIES[@]}"; do for strat in "${STRATEGIES[@]}"; do
if run_strategy_test "$strat"; then if run_strategy_test "$strat"; then
working_strategies+=("$strat") working_strategies+=("$strat")
working_descs+=("$(describe_strategy "$SCRIPT_DIR/general_${strat}.sh")") working_descs+=("$(describe_strategy "$SCRIPT_DIR/general_${strat}.sh")")
[[ -z "$first_working" ]] && first_working="$strat" [[ -z "$first_working" ]] && first_working="$strat"
else
failed_strategies+=("$strat")
failed_descs+=("$(describe_strategy "$SCRIPT_DIR/general_${strat}.sh")")
fi fi
done done
echo "" echo ""
echo "==============================================" 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 if [[ ${#working_strategies[@]} -gt 0 ]]; then
print_green " WORKING STRATEGIES FOUND: ${#working_strategies[@]}"
echo "==============================================" echo "=============================================="
echo "" print_green " WORKING STRATEGIES (${#working_strategies[@]}):"
local i=0 local i=0
for strat in "${working_strategies[@]}"; do while [[ $i -lt ${#working_strategies[@]} ]]; do
echo " $(print_green "[$((i+1))]") $strat${working_descs[$i]}" echo " $(print_green "$((i + 1)).") ${working_strategies[$i]}${working_descs[$i]}"
((i++)) i=$((i + 1))
done done
echo "=============================================="
echo "" echo ""
if [[ "$mode" == "--auto" ]]; then if [[ "$mode" == "--auto" ]]; then
install_strategy "$first_working" install_strategy "$first_working"
elif [[ "$mode" == "--list-all" ]]; then elif [[ "$mode" == "--list-all" ]]; then
echo "[*] To install a strategy, run: sudo ./service.sh → 1. Install Service" echo "[*] To install any working strategy, run:"
echo " Or directly: sudo ./run_strategy.sh ALT3" 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 else
echo "[*] Next steps:" echo "[*] Next steps:"
echo " 1. Test in browser: youtube.com, discord.com" 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 read -rp "Install first working strategy ($first_working)? [Y/n]: " ans
[[ "${ans:-Y}" == [yY]* ]] && install_strategy "$first_working" [[ "${ans:-Y}" == [yY]* ]] && install_strategy "$first_working"
fi 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" print_red " NO WORKING STRATEGY FOUND"
echo "==============================================" echo "=============================================="
echo "" echo ""
@@ -186,6 +221,7 @@ main() {
echo " - Modify strategy parameters in strategies/*.conf" echo " - Modify strategy parameters in strategies/*.conf"
echo " - Run diagnostics: sudo ./service.sh → 10. Run Diagnostics" echo " - Run diagnostics: sudo ./service.sh → 10. Run Diagnostics"
fi fi
echo "" echo ""
echo "[*] Auto-test complete." echo "[*] Auto-test complete."
echo "" echo ""