48 lines
2.5 KiB
Bash
48 lines
2.5 KiB
Bash
#!/bin/bash
|
|
# iOS 添加用例批量调试:每个用例前用 WDA terminate/launch 复位到首页,跑完记录结果。
|
|
# WDA 须已在 localhost:8100。失败不阻塞,继续下一个。
|
|
set -u
|
|
cd "$(dirname "$0")/.."
|
|
export PLATFORM=ios SOAK_MODE=1
|
|
BUNDLE=com.wohand.wohand
|
|
LOG=reports/ios-adds.log
|
|
: > "$LOG"
|
|
|
|
reset_home(){
|
|
local sid
|
|
sid=$(curl -s --max-time 5 http://localhost:8100/status 2>/dev/null | grep -oE '"sessionId" *: *"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/')
|
|
[ -z "$sid" ] && { echo "[reset] 无 WDA session(WDA 掉了?)" | tee -a "$LOG"; return 1; }
|
|
curl -s -X POST "http://localhost:8100/session/$sid/wda/apps/terminate" -H 'Content-Type: application/json' -d "{\"bundleId\":\"$BUNDLE\"}" >/dev/null 2>&1
|
|
sleep 1
|
|
curl -s -X POST "http://localhost:8100/session/$sid/wda/apps/launch" -H 'Content-Type: application/json' -d "{\"bundleId\":\"$BUNDLE\"}" >/dev/null 2>&1
|
|
sleep 3
|
|
}
|
|
|
|
# BLE 类添加(不依赖 WiFi 配网),先跑这些
|
|
ADDS=(
|
|
"meter_plus|npx vitest run tests/meter/meter_plus_connect.test.ts"
|
|
"remote|npx vitest run tests/remote/remote_connect.test.ts"
|
|
"motion_sensor|npx vitest run tests/sensor/motion_sensor_connect.test.ts"
|
|
"contact_sensor|npx vitest run tests/sensor/contact_sensor_connect.test.ts"
|
|
"find_card|npx vitest run tests/find_card/find_card_connect.test.ts"
|
|
"outdoor_meter|npx vitest run tests/meter/outdoor_meter_connect.test.ts"
|
|
"meter_pro|npx vitest run tests/meter/meter_pro_connect.test.ts"
|
|
"presence|npx vitest run tests/sensor/presence_sensor_connect.test.ts"
|
|
"safety_alarm|npx vitest run tests/safety_alarm/safety_alarm_connect.test.ts"
|
|
"curtain|npx vitest run tests/curtain/curtain_connect.test.ts"
|
|
"curtain3|CURTAIN_DEVICE='Curtain3 2B' npx vitest run tests/curtain/curtain_connect.test.ts"
|
|
"curtain3_2025|npx vitest run tests/curtain/curtain3_2025_connect.test.ts"
|
|
"keypad_touch|npx vitest run tests/keypad/keypad_touch_connect.test.ts"
|
|
"keypad_vision|npx vitest run tests/keypad/keypad_vision_connect.test.ts"
|
|
)
|
|
|
|
echo "===== $(date '+%F %T') iOS 添加批量开始 =====" | tee -a "$LOG"
|
|
for entry in "${ADDS[@]}"; do
|
|
name="${entry%%|}"; name="${entry%%|*}"; cmd="${entry#*|}"
|
|
echo "----- $(date +%T) [$name] -----" | tee -a "$LOG"
|
|
reset_home
|
|
eval "$cmd" > /tmp/ios-add-one.log 2>&1
|
|
grep -E '✓ \[PASS\]|✗ \[FAIL\]|○ \[SKIP\]|结果:|relay:|未触发|not found|cannot|品类' /tmp/ios-add-one.log | grep -ivE "deprecat" | tail -6 | tee -a "$LOG"
|
|
done
|
|
echo "===== $(date '+%F %T') 完成 =====" | tee -a "$LOG"
|