Initial public release

This commit is contained in:
jhaizhou
2026-10-12 16:51:08 +08:00
commit 46578a2b5d
997 changed files with 218713 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
# 改动文件 → 受影响的 uireg 局(uireg_pick.py 读;合入门槛 = 受影响局 + 核心局 + Mac 冒烟,整表只在出大包前 / 夜里浸泡)
# 列:路径通配(fnmatch,相对仓库根)<TAB> 局(空格分隔;* = 整表;- = 不挑局,只跑核心局)。从上往下匹配,取第一条命中的行(具体的写在前、通配的兜底写在后)。@uireg = 按 uireg.py 改动落在哪些局里。
# 新规矩:交来的分支只跑「这里挑出的局 + 它自己的专项」,两档整表只在合批候选头上跑一遍;批次叠放时用 uireg_pick.py --main <前一批候选头> 挑。
# 这里挑不到的东西靠专项补:秘境(dm_rift*)要真机专项;手柄(dm_padmode / hle_hid / dm_gamepad.m)要手柄局;资源定位(romfs_validate / asset_dl / main.m 启动段)要真机资源现场;
# 动 dm/ios 外壳启动路径(main.m、front_ios.m 的建视图 / 生命周期段)的分支,交回归前必须自己跑过真机 smoke.sh(bg-launch 两次退回:iPad 档进不了局、真机冒烟 0/3)。
# 新加局时顺手在这里登记;没登记的 dm/ 源文件,uireg_pick.py 记「未登记」并按整表处理(宁多跑不漏跑)。
dm/host/tests/* -
dm/host/Makefile -
dm/tools/patch_nso.py *
dm/PRODUCT *
dm/ios/tools/gen_romfs_overlay.py *
dm/i18n/* *
dm/ios/tools/dm_i18n.py *
dm/host/dm_i18n* *
dm/ios/tools/annot_strings.py k j rw1 rw2 kbb vt1
dm/host/dm_textbox* k j rw1 rw2 kbb vt1
dm/host/dm_runeword* k j rw1 rw2 rwp rwd d
dm/host/dm_vault* vf1 vf2 vt1 pg1 pg2 c s sb t u d cb
dm/host/dm_pages* pg1 pg2 vt1 c s sb
dm/ios/tools/wide_stash.py vf1 vf2 vt1 pg1 pg2 c s sb t u d cb
dm/ios/tools/gen_trove_art.py s sb t u d cb
dm/ios/tools/gen_widestash_art.py vf1 vf2 vt1 pg1 pg2 c s sb t u d cb
dm/ios/tools/gen_vault_table.py vt1
dm/host/dm_potpick* bd bdm p q b
dm/host/dm_lootfilter* bd bdm p q b
dm/host/dm_autobuff* bd bdm p q b
dm/host/dm_beltauto* ba bd bdm p q b
dm/host/dm_kills* kba kbb
dm/host/dm_elysium* v v2 kbb
dm/host/dm_bossrush* kbb bd
dm/host/dm_townwp* *
dm/host/dm_rift* kba kbb dc wp tp
dm/host/dm_unit.h kbb dc wp tp
dm/host/dm_pouch* t u s sb vt1 c
dm/host/dm_padmode* a f rf2 pk od pvb psel0 psel1 psel2 psel3
dm/host/hle_fs.c rf1 rf2 rf3 e pg2 vt1 v od
dm/host/hle_tact* a e od
dm/host/hle_hid* a f rf2 pk sl1
dm/ios/Sources/dm_gamepad.m a f rf2 pk
dm/host/romfs_validate* e pk rf2
dm/ios/Sources/asset_dl.m e pk rf2
dm/ios/Sources/main.m a e pk rf2 top od
dm/ios/run.sh e pk
dm/i18n/* a e k kba vt1 rf2
dm/host/dm_bright* a top
dm/host/dm_drophaptic* kbb
dm/host/dm_freetp* tp a p q f g
dm/host/dm_dropfilter* kbb
dm/host/dm_shoprefresh* b m p ra top me1 me3 pvb
dm/host/dm_world* ex tb tp dz top i b
dm/host/dm_actions* a g n
dm/host/dm_hud* a f pk bd bdm q g
dm/host/dm_uiscreen* a f pk bd q sb
dm/host/dm_cloudsync* rf3 e pg2 vt1 v
dm/host/dm_update* e
dm/host/dm_custom* e kbb
dm/host/hle_charname* e v
dm/host/dm_namegen* e v
dm/host/dm_textinput* e v vt1
dm/host/dm_cursor* a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 bd
dm/host/hle_touch* a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 bd
dm/host/touch_mac.c a c j s sb pg2 vt1 rw1
dm/ios/tools/touch_layout.py a c f g h j k m n p q s t u sb cb sl1 me1 me2 pg2 vt1 vf1 vf2 rw1 rw2 kba bd pk pvb
dm/ios/Sources/front_ios.m a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 bd pk
dm/ios/Sources/* a e pk rf2
dm/ios/NativeHUD/* a f pk bd g q
dm/host/diag.c -
dm/host/crash.c -
dm/host/hle_* *
dm/host/*.c *
dm/host/*.h *
dm/ios/tools/uireg/uireg.py @uireg
dm/ios/tools/* -
dm/verify/* -
docs/* -
*.md -
dm/ios/tools/merc_slots.py f ms
dm/ios/tools/gen_merc_art.py f ms
1 # 改动文件 → 受影响的 uireg 局(uireg_pick.py 读;合入门槛 = 受影响局 + 核心局 + Mac 冒烟,整表只在出大包前 / 夜里浸泡)
2 # 列:路径通配(fnmatch,相对仓库根)<TAB> 局(空格分隔;* = 整表;- = 不挑局,只跑核心局)。从上往下匹配,取第一条命中的行(具体的写在前、通配的兜底写在后)。@uireg = 按 uireg.py 改动落在哪些局里。
3 # 新规矩:交来的分支只跑「这里挑出的局 + 它自己的专项」,两档整表只在合批候选头上跑一遍;批次叠放时用 uireg_pick.py --main <前一批候选头> 挑。
4 # 这里挑不到的东西靠专项补:秘境(dm_rift*)要真机专项;手柄(dm_padmode / hle_hid / dm_gamepad.m)要手柄局;资源定位(romfs_validate / asset_dl / main.m 启动段)要真机资源现场;
5 # 动 dm/ios 外壳启动路径(main.m、front_ios.m 的建视图 / 生命周期段)的分支,交回归前必须自己跑过真机 smoke.sh(bg-launch 两次退回:iPad 档进不了局、真机冒烟 0/3)。
6 # 新加局时顺手在这里登记;没登记的 dm/ 源文件,uireg_pick.py 记「未登记」并按整表处理(宁多跑不漏跑)。
7 dm/host/tests/* -
8 dm/host/Makefile -
9 dm/tools/patch_nso.py *
10 dm/PRODUCT *
11 dm/ios/tools/gen_romfs_overlay.py *
12 dm/i18n/* *
13 dm/ios/tools/dm_i18n.py *
14 dm/host/dm_i18n* *
15 dm/ios/tools/annot_strings.py k j rw1 rw2 kbb vt1
16 dm/host/dm_textbox* k j rw1 rw2 kbb vt1
17 dm/host/dm_runeword* k j rw1 rw2 rwp rwd d
18 dm/host/dm_vault* vf1 vf2 vt1 pg1 pg2 c s sb t u d cb
19 dm/host/dm_pages* pg1 pg2 vt1 c s sb
20 dm/ios/tools/wide_stash.py vf1 vf2 vt1 pg1 pg2 c s sb t u d cb
21 dm/ios/tools/gen_trove_art.py s sb t u d cb
22 dm/ios/tools/gen_widestash_art.py vf1 vf2 vt1 pg1 pg2 c s sb t u d cb
23 dm/ios/tools/gen_vault_table.py vt1
24 dm/host/dm_potpick* bd bdm p q b
25 dm/host/dm_lootfilter* bd bdm p q b
26 dm/host/dm_autobuff* bd bdm p q b
27 dm/host/dm_beltauto* ba bd bdm p q b
28 dm/host/dm_kills* kba kbb
29 dm/host/dm_elysium* v v2 kbb
30 dm/host/dm_bossrush* kbb bd
31 dm/host/dm_townwp* *
32 dm/host/dm_rift* kba kbb dc wp tp
33 dm/host/dm_unit.h kbb dc wp tp
34 dm/host/dm_pouch* t u s sb vt1 c
35 dm/host/dm_padmode* a f rf2 pk od pvb psel0 psel1 psel2 psel3
36 dm/host/hle_fs.c rf1 rf2 rf3 e pg2 vt1 v od
37 dm/host/hle_tact* a e od
38 dm/host/hle_hid* a f rf2 pk sl1
39 dm/ios/Sources/dm_gamepad.m a f rf2 pk
40 dm/host/romfs_validate* e pk rf2
41 dm/ios/Sources/asset_dl.m e pk rf2
42 dm/ios/Sources/main.m a e pk rf2 top od
43 dm/ios/run.sh e pk
44 dm/i18n/* a e k kba vt1 rf2
45 dm/host/dm_bright* a top
46 dm/host/dm_drophaptic* kbb
47 dm/host/dm_freetp* tp a p q f g
48 dm/host/dm_dropfilter* kbb
49 dm/host/dm_shoprefresh* b m p ra top me1 me3 pvb
50 dm/host/dm_world* ex tb tp dz top i b
51 dm/host/dm_actions* a g n
52 dm/host/dm_hud* a f pk bd bdm q g
53 dm/host/dm_uiscreen* a f pk bd q sb
54 dm/host/dm_cloudsync* rf3 e pg2 vt1 v
55 dm/host/dm_update* e
56 dm/host/dm_custom* e kbb
57 dm/host/hle_charname* e v
58 dm/host/dm_namegen* e v
59 dm/host/dm_textinput* e v vt1
60 dm/host/dm_cursor* a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 bd
61 dm/host/hle_touch* a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 bd
62 dm/host/touch_mac.c a c j s sb pg2 vt1 rw1
63 dm/ios/tools/touch_layout.py a c f g h j k m n p q s t u sb cb sl1 me1 me2 pg2 vt1 vf1 vf2 rw1 rw2 kba bd pk pvb
64 dm/ios/Sources/front_ios.m a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 bd pk
65 dm/ios/Sources/* a e pk rf2
66 dm/ios/NativeHUD/* a f pk bd g q
67 dm/host/diag.c -
68 dm/host/crash.c -
69 dm/host/hle_* *
70 dm/host/*.c *
71 dm/host/*.h *
72 dm/ios/tools/uireg/uireg.py @uireg
73 dm/ios/tools/* -
74 dm/verify/* -
75 docs/* -
76 *.md -
77 dm/ios/tools/merc_slots.py f ms
78 dm/ios/tools/gen_merc_art.py f ms
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
# uireg 的起局脚本(真机 iPhone):UIREG_RUNNER=<本文件> python3 uireg.py iphone <局名…>。接口同 run_mac.sh(<标签> <上限秒> < 触点脚本)。
# 走 ../touch_e2e.sh:它自己取设备锁、按 pid 停 App、设备读本机配置(local_env.sh)。被测的是手机上已经装好的那个包——装包与本脚本之间放过锁的话,包可能已被别人换掉,
# 要保证是自己的包,就在外层先取设备锁把「装包 + 跑」包住(设备锁可重入)。
# 与 Mac 上的差别:只有 iphone 档;跑满上限秒才收(不提前收);只拉 boot.txt 与命令包日志——截图每张约 20 秒不拉,所以「只看截图」的项在真机上都是未判;
# 没有 d 局的专用存档(PW_SAVE 非空的局不跑)。
# UIREG_PULL="put_00.png put_01.png":额外拉回这几张截图(读画面的判据要用;每张约 20 秒,算在持锁时间里)。
# uireg run-start script (real-device iPhone): UIREG_RUNNER=<this file> python3 uireg.py iphone <run names...>. Same interface as run_mac.sh (<label> <limit seconds> < touch point script).
# Goes through ../touch_e2e.sh: it takes the device lock itself, stops the App by pid, and reads the device from the local config (local_env.sh). What is tested is the bundle already installed on the phone -- if the lock was released between installing and this script, the bundle may already have been replaced by someone else,
# so to make sure it is your own bundle, take the device lock in an outer layer first to wrap 'install + run' (the device lock is reentrant).
# Differences from the Mac: only the iphone profile; the run ends only after the full limit in seconds (no early end); only boot.txt and the command packet log are pulled -- screenshots take about 20 seconds each and are not pulled, so 'screenshot-only' items are all unjudged on the real device;
# there is no dedicated save for the d runs (runs with a non-empty PW_SAVE are not run).
# UIREG_PULL="put_00.png put_01.png": additionally pull back these screenshots (needed for criteria that read the picture; about 20 seconds each, counted in the lock hold time).
unset LANG LC_CTYPE; export LC_ALL=C # touch_e2e.sh 里「变量后紧跟中文标点」的行在 UTF-8 区域设置下会被 bash 3.2 当成变量名的一部分 | Lines in touch_e2e.sh where 'a variable is immediately followed by Chinese punctuation' are treated by bash 3.2 as part of the variable name under a UTF-8 locale
TAG=$1; CAP=$2; HERE=$(cd "$(dirname "$0")" && pwd)
O=${UIREG_OUT:-${DM_ROOT:-$HOME/dm-work}/run/uireg}/pw/$TAG; mkdir -p "$O"; cat > "$O/in.txt"
[ "${UIREG_MODE:-iphone}" = iphone ] || { echo "计时:真机只有 iphone 档,没跑" > "$O/timing.txt"; exit 2; }
[ -z "${PW_SAVE:-}" ] || { echo "计时:真机上没有存档 ${PW_SAVE},没跑" > "$O/timing.txt"; exit 2; }
rm -f "$O/boot.txt" "$O/boot_full.txt" "$O/c2s.jsonl" "$O/e2e_c2s.jsonl"
# 触点脚本的裸坐标按 667×375 的 16:9 画面写 → DM_TOUCH_REF 由 App 换算到真机屏;touch_e2e.sh 一定带按键脚本变量,这里给一条永不触发的占位键序,
# 并显式打开前端自动进选角页(DM_FE_AUTO,不带按键脚本时它缺省就开);命令包日志名与存档由 touch_e2e.sh 自己定
# The touch point script's bare coordinates are written for a 667×375 16:9 picture → converted by the App to the real-device screen via DM_TOUCH_REF; touch_e2e.sh always passes the key script variable, so a placeholder key sequence that never triggers is given here,
# and front-end auto-entry into the character select page is turned on explicitly (DM_FE_AUTO, which is on by default when no key script is passed); the command packet log name and the save are decided by touch_e2e.sh itself
J=$(python3 -c "
import json,sys
d={'DM_TOUCH_SCRIPT_START':'menu','DM_TOUCH_REF':'667x375','DM_FE_AUTO':'1'}
for kv in sys.argv[1].split():
k,v=kv.split('=',1)
if k not in ('DM_C2S_LOG','DM_SAVE_FRESH'): d[k]=v
print(json.dumps(d))" "${PW_ENV:-}")
t0=$(date +%s)
E2E_KEYS='B@OpenPanel:NoSuchPanelEver' E2E_ENV="$J" E2E_PULL="boot.txt c2s.jsonl ${UIREG_PULL:-}" bash "$HERE/../touch_e2e.sh" "$O/in.txt" "$O" "$CAP" > "$O/e2e.log" 2>&1
[ -f "$O/e2e_c2s.jsonl" ] && cp "$O/e2e_c2s.jsonl" "$O/c2s.jsonl"
# 包对不对读出来核:boot.txt 首行的构建号必须等于被测提交的提交时间戳(dm/ios/run.sh build 写进去的)。被测提交缺省 = 本脚本所在树的 HEAD,
# 包是从别的树出的就用 UIREG_EXPECT_COMMIT=<提交> 指明。不等 = 设备上跑的不是这一批的包(没装 / 被别人换了 / 树不干净出的包)→ 整局作废:日志换成一行红,各项都判不通。
# Whether the package is the right one is read out and checked: the build number on the first line of boot.txt must equal the commit timestamp of the
# commit under test (written in by dm/ios/run.sh build). The commit under test defaults to HEAD of the tree this script lives in;
# if the package was built from another tree, name it with UIREG_EXPECT_COMMIT=<commit>. A mismatch = the device is not running this batch's package
# (not installed / replaced by someone else / built from a dirty tree) → the whole run is void: the log is replaced by a single failure line and every item
# fails.
EXP=$(git -C "$HERE" log -1 --format=%ct ${UIREG_EXPECT_COMMIT:-} 2>/dev/null); GOT=$(LC_ALL=C grep -a -m1 -o 'boot: 版本 [^ ]* 构建 [0-9]*' "$O/boot.txt" 2>/dev/null | awk '{print $NF}')
if [ "${UIREG_BUILD_CHECK:-1}" = 1 ] && [ -f "$O/boot.txt" ] && [ "$GOT" != "$EXP" ]; then
mv "$O/boot.txt" "$O/boot_wrongpkg.txt"; echo "[dm] 【红】包不对,整局作废:设备上这一局的构建号 ${GOT:-读不到},期望 ${EXP:-读不到}(提交 $(git -C "$HERE" log -1 --format=%h ${UIREG_EXPECT_COMMIT:-} 2>/dev/null | cut -c1-9) 的提交时间戳);原日志在 boot_wrongpkg.txt" > "$O/boot.txt"
fi
# 真机跑满上限秒才收:脚本走完之后静置的那一段(会有「无进展」看门狗红行)不属于这一局,日志截到「note 结束」为止,与 Mac 上见到记号就收的范围一致;全文留在 boot_full.txt
# On the real device the run only ends after the full limit in seconds: the idle stretch after the script finishes (which gets 「无进展」(no progress) watchdog failure lines) does not belong to this run, so the log is cut at 「note 结束」(note end), matching the range on the Mac where the run ends as soon as the marker is seen; the full text is kept in boot_full.txt
if LC_ALL=C grep -a -q '\[script\] note 结束' "$O/boot.txt" 2>/dev/null; then mv "$O/boot.txt" "$O/boot_full.txt"; LC_ALL=C awk '{ print } /\[script\] note 结束/ { exit }' "$O/boot_full.txt" > "$O/boot.txt"; fi
echo "计时:真机整局墙钟 $(( $(date +%s) - t0 )) 秒(含排锁、推脚本、拉日志)" > "$O/timing.txt"
+89
View File
@@ -0,0 +1,89 @@
#!/bin/bash
# uireg 的起局脚本(Mac 上的 iOS 包,在本机跑):run_mac.sh <标签> <上限秒> < 触点脚本。约定见 uireg.py 文件头与「usage.md」。
# 玩家路径:只带触点脚本,不带按键脚本接管;PW_ENV(空格分隔的 K=V)原样加到起包环境;PW_SAVE 非空 = 换上容器 Data 下这份存档的副本,跑完挪回。
# 包按 UIREG_MODE 挑:iphone = $UIREG_APP(缺省 <树>/.iosdd_mac/DmMacSmoke.app,smoke_mac.sh 包好的那份);ipad / ipadfull = $UIREG_APP_IPAD(没有缺省,出法见usage.md)。
# 不拷包、不同步,直接从给的路径起(计时里「拷包」恒为 0)。要换包请另起目录名,包在跑的时候别动它的 Wrapper 那层:
# 系统把 <包>/Wrapper 挂载出去跑,挂着时源目录被删或整体替换,会留下卸不掉的失效挂载点,那个路径从此 open 不了。
# Run launcher script for uireg (the iOS app on Mac, run on this machine): run_mac.sh <tag> <limit seconds> < touch point script. Conventions are in the uireg.py file header and usage.md.
# Player path: only a touch point script, no key script taking over; PW_ENV (space-separated K=V) is added as-is to the app launch environment; non-empty PW_SAVE = swap in a copy of this save under the container's Data, and move it back after the run.
# The app is picked by UIREG_MODE: iphone = $UIREG_APP (default <tree>/.iosdd_mac/DmMacSmoke.app, the one packaged by smoke_mac.sh); ipad / ipadfull = $UIREG_APP_IPAD (no default, see usage.md for how to produce it).
# No copying or syncing of the app, it is launched directly from the given path (the 「拷包」(copy app) entry in the timing is always 0). To switch apps use another directory name, and do not touch the app's Wrapper layer while it is running:
# the system mounts <app>/Wrapper out to run it; if the source directory is deleted or replaced wholesale while mounted, a stale mount point that cannot be unmounted is left behind, and that path can never be opened again.
set -u
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../local_env.sh" # 本机配置(包名、团队号、设备号) | Local config (package name, team ID, device ID)
B=${DM_BUNDLE_ID:?先在本机配置里设 DM_BUNDLE_ID(App 包名,见 dm/ios/local.env.example)}
TAG=$1; CAP=$2; HERE=$(cd "$(dirname "$0")" && pwd)
O=${UIREG_OUT:-${DM_ROOT:-$HOME/dm-work}/run/uireg}/pw/$TAG; mkdir -p "$O"; cat > "$O/script.txt"; : > "$O/launch.log"
fail(){ echo "$*" | tee "$O/fail.txt"; echo "计时:${1}" > "$O/timing.txt"; exit 2; }
case ${UIREG_MODE:-iphone} in
iphone) W=${UIREG_APP:-$(git -C "$HERE" rev-parse --show-toplevel 2>/dev/null)/.iosdd_mac/DmMacSmoke.app};;
*) W=${UIREG_APP_IPAD:-};;
esac
[ -x "$W/Wrapper/DmIOS.app/DmIOS" ] || fail "没有包(画面档 ${UIREG_MODE:-iphone}):${W:-未设 UIREG_APP_IPAD}"
C=""; for m in "$HOME"/Library/Containers/*/.com.apple.containermanagerd.metadata.plist; do
[ "$(/usr/libexec/PlistBuddy -c 'Print :MCMMetadataIdentifier' "$m" 2>/dev/null)" = "$B" ] && C="$(dirname "$m")/Data"; done
D="$C/Documents"; [ -n "$C" ] && [ -d "$D" ] || fail "本机没有 $B 的容器(先跑一次 smoke_mac.sh 1)"
# 同一台 Mac 上同包只能起一个实例:与 Mac 冒烟 / 触屏用例共用 macsmoke 锁(可重入:外层已持锁的调用不再排队)
# Only one instance of the same app can be started on one Mac: shares the macsmoke lock with the Mac smoke test / touch cases (reentrant: a call whose outer layer already holds the lock does not queue again)
T_B=$(date +%s); export DM_DEVLOCK_DIR=${DM_ROOT:-$HOME/dm-work}/run/ios/macsmoke.lock; source "$HERE/../devlock.sh"; devlock_acquire "${SMOKE_OWNER:-未署名} 界面回归 $TAG"; T_C=$(date +%s)
# 只认本包(bundle id = $B):同机还可能跑着回归多实例的重签包 <包名>.reg<N>(各自独立容器),按可执行文件后缀认会把它们当成本包、收尾时一起杀掉。
# 查不到 bundle id 的(刚起、系统还没登记)照旧算本包,只排除明确是别的 bundle 的
# Only this package is recognized (bundle id = $B): the same machine may also be running the regression multi-instance re-signed packages <package name>.reg<N> (each with its own container); matching by executable suffix would take them as this package and kill them along at wrap-up.
# Those whose bundle id cannot be found (just launched, not yet registered by the system) still count as this package; only those clearly belonging to another bundle are excluded
pids() { local p b; for p in $(ps -axo pid=,comm= | awk '{ pid=$1; $1=""; sub(/^ /,""); if ($0 ~ /\/Wrapper\/DmIOS\.app\/DmIOS$/) print pid }'); do
b=$(lsappinfo info -only bundleID -app "$p" 2>/dev/null | sed -n 's/.*="\(.*\)"$/\1/p'); [ -z "$b" ] || [ "$b" = "$B" ] && echo "$p"; done; }
stop_all(){ local p; for p in $(pids); do kill -TERM "$p" 2>/dev/null; done; sleep 1; for p in $(pids); do kill -KILL "$p" 2>/dev/null; done; }
pre=$(pids | tr '\n' ' '); [ -z "$pre" ] || { devlock_release; fail "本机已有 $B 的实例在跑(pid ${pre},非本次启动)"; }
# 换存档的收尾:跑过的那份留在 Data 下(save.uireg_ran,只留最近一份),原存档挪回 Documents/save。挪不回 = 容器里的正式存档不在原位,之后所有本机包都受影响:
# 报红(fail.txt + 退出码 4)并写明原存档在哪,不静默(只读副本挪不走,原存档留在 swap 目录里没人知道)
# 换存档一律换进测试存档目录 Documents/save.test 并带 DM_SAVE_TEST=1 起局,不碰产品存档 Documents/save:挂产品存档目录的局会连真实 iCloud,
# 登着真实账号的机器上换进去的测试角色会被同步上云。跑完再查一遍日志,出现同步动作就报红。
# Wrap-up of a save swap: the copy that was run stays under Data (save.uireg_ran, only the latest one kept), and the original save moves back to Documents/save. Failing to move it back = the real save in the container is not in place, which affects every local package afterwards:
# report a failure (fail.txt + exit code 4) and state where the original save is, never silently (a read-only copy cannot be moved away, and nobody would know the original save was left in the swap directory)
# A save swap always swaps into the test save directory Documents/save.test and starts the run with DM_SAVE_TEST=1, without touching the product save Documents/save: a run that mounts the product save directory connects to real iCloud,
# and on a machine signed in to a real account the swapped-in test character would be synced to the cloud. After the run the log is checked once more, and any sync action is reported as a failure.
SV="$D/save.test"; SWAP=""; BAD=""; restore(){ [ -n "$SWAP" ] || return 0; chmod -R u+w "$SV" 2>/dev/null; rm -rf "$C/save.uireg_ran" "$SV.work"
if mv "$SV" "$C/save.uireg_ran" && mv "$SWAP" "$SV"; then SWAP=""; else BAD=1; echo "【红】换存档后挪不回:原测试存档在 ${SWAP},Documents/save.test 不是原来那份,手工核对后挪回" | tee "$O/fail.txt"; [ -f "$O/timing.txt" ] && sed -i '' '1s/$/ 【红】换存档后挪不回,见 fail.txt/' "$O/timing.txt"; fi; } # timing.txt 那行 uireg.py 会抄进表头 | uireg.py copies the timing.txt line into the table header
trap 'stop_all; restore; savekey_out "$C"; devlock_release; [ -z "$BAD" ] || exit 4' EXIT; trap 'exit 143' INT TERM
# 存档钥匙(../save_key.sh):带 DM_SAVE_KEY 的换进自己那份测试存档;带 DM_SAVE_TEST=1 接着用却不带钥匙的不起。换存档的局(PW_SAVE)自带存档,不走钥匙
# Save key (../save_key.sh): runs with DM_SAVE_KEY swap in their own test save; runs continuing with DM_SAVE_TEST=1 but without a key are not started. Save-swap runs (PW_SAVE) bring their own save and do not use a key
source "$HERE/../launch_guard.sh"; launch_guard_pre "$C"; source "$HERE/../save_key.sh"; [ -n "${PW_SAVE:-}" ] || savekey_in "$C" "${PW_ENV:-}" || fail "存档钥匙不许起这一局(见上一行红字)"
if [ -n "${PW_SAVE:-}" ]; then
[ -d "$C/$PW_SAVE" ] || fail "容器 Data 下没有存档 ${PW_SAVE}(d 局专用,备法见usage.md)"
# SWAP 等原存档真的挪走了才置(先置的话,挪不走时收尾会把没动过的原存档当成「跑过的那份」挪走);副本一律加写权限:
# 外来存档目录常是只读的,原样拷进来游戏的存档事务清不掉它生成的 save.work,之后任何包启动都 FATAL
# SWAP is set only once the original save has really been moved away (if set first, when the move fails the cleanup would move away the untouched original save as 'the one that was run'); copies always get write permission added:
# external save directories are often read-only, and copied in as-is the game's save transaction cannot clear the save.work it generates, after which any bundle FATALs on launch
S1="$C/save.uireg_swap_$$"; [ -d "$SV" ] || mkdir -p "$SV"; mv "$SV" "$S1" || fail "换存档失败:原测试存档挪不走"; SWAP="$S1"; rm -rf "$SV.work"
cp -R "$C/$PW_SAVE" "$SV" && chmod -R u+w "$SV" || fail "换存档失败:副本拷不进去"
fi
caffeinate -u -t 3 >/dev/null 2>&1 # 屏幕睡着时取不到可绘制表面,游戏主线程会卡在取图 | While the screen is asleep no drawable surface can be obtained, and the game's main thread gets stuck acquiring the drawable
RID=u$(date +%H%M%S); awk -v r="$RID" '$2=="shot"{$3=r"_"$3} {print}' "$O/script.txt" > "$D/touch_script.txt"
EX=(); for kv in ${PW_ENV:-}; do EX+=(--env "$kv"); done; [ -z "${PW_SAVE:-}" ] || EX+=(--env DM_SAVE_TEST=1)
# 本机起包的总闸(../cloud_guard.sh):每一局都带「不同步」开关,自己指了本地云端目录的 iCloud 用例除外;跑完核启动日志
# Master gate for launching the package on this Mac (../cloud_guard.sh): every run carries the "no sync" switch, except iCloud cases that specify a local cloud directory themselves; the launch log is checked after the run
source "$HERE/../cloud_guard.sh"; cloud_guard_env "$D" "${PW_ENV:-}" || fail "总闸不许起这一局(见上一行红字)"; [ -z "$CG_ENV" ] || EX+=(--env "$CG_ENV")
# DM_UIMSG=1:界面消息行(UIMSG …)只有带了它才打进日志,前端 / 确认框 / 暂停菜单那批判据靠这些行;DM_WATCH:到点自己退出的兜底
# open 后 10 秒没有 boot.txt = 这次没起来:收掉重起一次,再不行整局判失败,不等满上限
# DM_UIMSG=1: UI message lines (UIMSG ...) are written to the log only with it, and the criteria for the front end / confirmation box / pause menu batch rely on these lines; DM_WATCH: the fallback that exits by itself when time is up
# No boot.txt 10 seconds after open = it did not start this time: kill it and start again once, and if that fails too the whole run is judged failed without waiting out the limit
launch(){ mv "$D/boot.txt" "$D/boot_prev.txt" 2>/dev/null
open -n "$W" ${EX[@]+"${EX[@]}"} --env DM_TOUCH_SCRIPT=touch_script.txt --env DM_TOUCH_SCRIPT_START=menu --env DM_UIMSG=1 --env "DM_WATCH=$((CAP + 60))" --args -mode boot "${LG_ARGS[@]}" >> "$O/launch.log" 2>&1
local i; for i in $(seq 20); do [ -s "$D/boot.txt" ] && return 0; sleep 0.5; done; return 1; }
TRY=1
if ! launch; then stop_all; TRY=2; launch || { launch_guard_blocked "$B" "两次 open 各等 10 秒" 2>&1 | tee "$O/fail.txt"; echo "计时:拷包 0 排锁 $((T_C - T_B)) 启动失败(两次都没有 boot.txt)" | tee "$O/timing.txt"; exit 3; }; fi
T_D=$(date +%s)
# 见到脚本末行的记号就收;上限秒只是兜底
# End the run as soon as the marker on the script's last line is seen; the limit in seconds is only a fallback
END=$((T_D + CAP)); while [ "$(date +%s)" -lt "$END" ]; do LC_ALL=C grep -a -q '\[script\] note 结束' "$D/boot.txt" 2>/dev/null && break; [ -n "$(pids)" ] || break; sleep 0.5; done; T_E=$(date +%s)
stop_all
cp "$D/boot.txt" "$O/boot.txt" 2>/dev/null; [ -f "$D/pwc2s.jsonl" ] && mv "$D/pwc2s.jsonl" "$O/c2s.jsonl"
# 真实 iCloud 闸:本该不同步的局出现了同步动作 = 连了真云端,这一局作废
# Real iCloud gate: a sync action appearing in a run that should not sync = it connected to the real cloud, and this run is void
cloud_guard_check "$O/boot.txt" || { BAD=1; echo "【红】这一局出现了 iCloud 同步动作,结果作废,立刻核云端目录" | tee "$O/fail.txt"; }; cloud_guard_clean "$D"
# 换存档的局:进局后日志里的角色名(宿主每次进局都打「刷怪积分牌:「<角色名>」…」)必须是换进来那份存档里的角色,不是 = 挂的不是换进去的那份
# Save-swap runs: the character name in the log after entering the run (the host prints 「刷怪积分牌:「<角色名>」…」(kill board: "<character name>"...) on every run entry) must be the character in the swapped-in save; if it is not = the save mounted is not the one swapped in
if [ -n "${PW_SAVE:-}" ]; then WHO=$(LC_ALL=C sed -n 's/.*刷怪积分牌:「\([^」]*\)」.*/\1/p' "$O/boot.txt" 2>/dev/null | tail -1)
if [ -n "$WHO" ] && [ ! -f "$C/$PW_SAVE/$WHO/$WHO.d2s" ]; then BAD=1; echo "【红】换存档没生效:进局的角色「${WHO}」不在 ${PW_SAVE} 里,这一局不算" | tee "$O/fail.txt"; fi; fi
for f in "$D/${RID}"_*; do [ -f "$f" ] && mv "$f" "$O/$(basename "$f" | sed "s/^${RID}_//")"; done
echo "计时:拷包 0 排锁 $((T_C - T_B)) 起包 $((T_D - T_C)) 运行 $((T_E - T_D)) 收尾 $(( $(date +%s) - T_E )) 启动次数 $TRY" | tee "$O/timing.txt"
File diff suppressed because it is too large Load Diff
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
# 按改动挑局:git diff 基点..被测头 的文件 → affected.tsv → 受影响局;开跑前查基点。
# 合入门槛从简 = Mac 冒烟 + 一档受影响局;没有受影响局时跑核心局;--core 时再并上核心局。整表只放夜里。
# 用法:uireg_pick.py <被测提交或分支> [--main main]
# 输出最后一行「局:…」给脚本用(含 * 表示要整表);退出码 0 = 可以跑,3 = 基点旧且主干改动碰到受影响局(先变基,不跑注定失败的局)。
# Pick runs by change: files from git diff base..head under test → affected.tsv → affected runs; check the base before starting.
# The merge threshold kept simple = Mac smoke test + affected runs in one mode; when there are no affected runs, run the core runs; with --core the core runs are added on top. The full table runs only at night.
# Usage: uireg_pick.py <commit or branch under test> [--main main]
# The last output line 「局:…」(runs: …) is for scripts (containing * means the full table is needed); exit code 0 = OK to run, 3 = the base is old and mainline changes touch affected runs (rebase first, do not run runs that are bound to fail).
import sys, os, re, fnmatch, subprocess
CORE = "e k s sb t pk rf2 pg2 vt1 j".split() # 核心局:前端 / 镶嵌与符文之语 / 储藏箱存取与按钮 / 魔盒 / iPad 身体框 / 重开 / 个人仓库翻页 / 编年史仓库;单档运行合计约 6.5 分钟 | core runs: front end / socketing and runewords / stash deposit-withdraw and buttons / cube / iPad body box / restart / personal stash paging / chronicle vault; about 6.5 minutes in total for a single-mode pass
H = os.path.dirname(os.path.abspath(__file__))
def git(*a): return subprocess.run(["git", *a], capture_output=True, text=True, check=True).stdout
def rules():
r = []
for ln in open(os.path.join(H, "affected.tsv"), encoding="utf-8"):
if not ln.strip() or ln.startswith("#"): continue
pat, games = ln.rstrip("\n").split("\t", 1); r.append((pat, games.split()))
return r
def uireg_games(base, head): # uireg.py 改动落在哪些局:改动行号 → 往上找最近的 G("名" | which runs a uireg.py change falls into: changed line number → search upward for the nearest G("name"
out = git("diff", "-U0", base, head, "--", "dm/ios/tools/uireg/uireg.py")
if not out: return set()
src = git("show", f"{head}:dm/ios/tools/uireg/uireg.py").split("\n"); gs = set()
for m in re.finditer(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@", out, re.M):
a, n = int(m.group(1)), int(m.group(2) or 1)
for ln in range(a, a + max(n, 1)):
for j in range(min(ln, len(src)) - 1, -1, -1):
g = re.search(r'\bG\("([a-z0-9]+)"', src[j])
if g: gs.add(g.group(1)); break
return gs
def classify(files, base, head, R):
pick, why, unreg = set(), [], []
for f in files:
hit = next(((p, g) for p, g in R if fnmatch.fnmatch(f, p)), None)
if hit is None:
if f.startswith("dm/"): unreg.append(f); pick.add("*"); why.append(f"{f} → 未登记,按整表")
continue
p, g = hit
if g == ["-"]: why.append(f"{f} → 只跑核心局({p})"); continue
if g == ["@uireg"]: u = uireg_games(base, head); pick |= u; why.append(f"{f} → 改了这些局的脚本:{' '.join(sorted(u)) or '无'}"); continue
pick |= set(g); why.append(f"{f} → {' '.join(g)}({p})")
return pick, why, unreg
def main():
a = [x for x in sys.argv[1:] if not x.startswith("--")]; head = a[0] if a else "HEAD"
mainref = sys.argv[sys.argv.index("--main") + 1] if "--main" in sys.argv else "main"
R = rules(); mb = git("merge-base", head, mainref).strip()
files = [f for f in git("diff", "--name-only", mb, head).split("\n") if f]
pick, why, unreg = classify(files, mb, head, R)
ahead = int(git("rev-list", "--count", f"{mb}..{mainref}").strip() or 0)
print(f"被测 {git('rev-parse', '--short', head).strip()},基点 {mb[:9]},主干 {mainref} 领先基点 {ahead} 个提交;改动文件 {len(files)} 个")
for w in why: print(" " + w)
rc = 0
if ahead:
mfiles = [f for f in git("diff", "--name-only", mb, mainref).split("\n") if f]
mp, mwhy, _ = classify(mfiles, mb, mainref, R)
mp.discard("@uireg")
sel = pick | set(CORE)
clash = "*" in mp or ("*" in pick and mp) or (mp & sel)
if clash:
rc = 3; print(f"【红】基点旧:主干在基点之后改了受影响局用到的东西({' '.join(sorted(mp & sel)) if '*' not in mp else '整表级改动'}),先变基到 {git('rev-parse', '--short', mainref).strip()} 再跑:")
for w in mwhy:
if not w.endswith("只跑核心局(-)") and "→ 只跑核心局" not in w: print(" 主干 " + w)
else: print("基点虽旧,主干的改动不碰这次要跑的局,可以跑")
full = "*" in pick
aff = sorted(pick - {"*"}); core = "--core" in sys.argv or not aff
games = ["*"] if full else aff + ([c for c in CORE if c not in pick] if core else [])
print(f"受影响局:{'整表' if full else ' '.join(sorted(pick)) or '无'}" + (f";并上核心局:{' '.join(CORE)}" if not full and core else "") + (f";未登记文件 {len(unreg)} 个(请补进 affected.tsv)" if unreg else ""))
print("局:" + " ".join(games)); sys.exit(rc)
if __name__ == "__main__": main()
+204
View File
@@ -0,0 +1,204 @@
# uireg — scripted regression of the touch UI
中文:[usage.zh-CN.md](usage.zh-CN.md)
Taps through the touch UI item by item and outputs one "expected → actual result" line per item. What is under test is the iOS package itself, driven only by touch scripts (which take the same path as real fingers, see "Touch scripts" in [../../README.md](../../README.md)); the criteria read the log of that run.
**About saves first**: the whole regression suite is written against one specific multi-character save. This save is not provided with the repository and cannot be distributed. The smoke test save that can be generated from the repository is only enough for the smoke test. See "Which saves are needed" below; without that save, the in-game state and tap positions of most runs do not match.
## Files
| File | Purpose |
|---|---|
| `uireg.py` | All cases and criteria: generates the touch script of each run, calls the runner script, reads the log and produces the result table |
| `run_mac.sh` | Runner script (default): runs the iOS package on a Mac, on this machine |
| `run_dev.sh` | Runner script: runs the already installed package on a real iPhone |
| `uireg_pick.py`, `affected.tsv` | Pick the affected runs according to the changed files |
## Prerequisites
1. Being able to run the iOS package on a Mac: first get `tools/make_fixture.sh` and `tools/smoke_mac.sh 1` working once, following "Smoke test" in [../../README.md](../../README.md). After that this machine has the wrapped package (`.iosdd_mac/DmMacSmoke.app` under the repository root; if the source was not obtained with git clone, it is under the directory the smoke test script was run from), this app's container, and the game assets inside the container.
2. The local configuration `dm/ios/local.env` has `DM_BUNDLE_ID`.
3. Some criteria read screenshots and need `python3` to be able to `import PIL` (Pillow). It still runs without it; those items report `未判` (not judged).
All steps can be done on this machine alone; no second Mac is needed.
## How to run
```bash
# run from the repository root
python3 dm/ios/tools/uireg/uireg.py iphone # all runs
python3 dm/ios/tools/uireg/uireg.py iphone b # only run b
python3 dm/ios/tools/uireg/uireg.py iphone a c e # several runs
```
The first argument is the screen profile:
| Screen profile | Meaning | Which package is used |
|---|---|---|
| `iphone` | iPhone aspect ratio | `UIREG_APP`, default `.iosdd_mac/DmMacSmoke.app` under the repository root (if the source was not obtained with git clone there is no default and you have to give it) |
| `ipadfull` | iPad true full screen (the default picture on iPad: 3D fills the whole screen, and the UI is a 16:9 block anchored to the bottom) | `UIREG_APP_IPAD`, must be given |
| `ipad` | iPad 16:9 with borders | Same as above |
One run = launch the app once, go through one script, exit. Runs are independent of each other and can be run individually. Runs are serial with respect to each other: a given bundle ID can have only one instance on one Mac, and the runner script uses the lock `$DM_ROOT/run/ios/macsmoke.lock` to queue with the Mac smoke test.
### How to read the results
- After each run finishes, one line is printed: wall-clock time, timing segments, number of red lines in the log.
- The last line: `# 共 N 项:通 A、不通 B、未判 C;合计墙钟 … 秒;表 <path>` (N items in total: A passed, B failed, C not judged; total wall-clock … seconds; table `<path>`), followed by every item that did not pass or was not judged.
- The result table: `$UIREG_OUT/tables/<screen profile>_<MMDD_HHMM>/表.md`.
- The artifacts of each run: `$UIREG_OUT/pw/<prefix>_<screen profile>_<run name>/`, containing `boot.txt` (the log of that run), `script.txt` (the touch script actually used), screenshots, and `timing.txt`.
There are two kinds of `未判` (not judged): the item only left a screenshot and has no log criterion; or the criterion has to read a screenshot but cannot read it. Both need a person to look at the picture before a conclusion can be drawn, and are not treated as passed.
The criterion of each item only looks at the part of the log after that item's marker. What counts as a red line is not only lines containing `【红】` (red) but also `FATAL`, the watchdog, GPU command buffer errors and so on; the regular expression is `LOGRED` in `uireg.py`.
## Which saves are needed
### Standard save
Most runs launch with `DM_SAVE_FRESH=warlock`: the app makes a fresh copy of its bundled standard save and uses that, without touching the real save. The standard save is brought into the app from `$DM_ROOT/data/switch/save_ref_warlock/0000000000000001/0/` when the package is built.
The script assumes that the character select list of this save has four characters, and each run selects by row number:
| Row | The character the script assumes | Examples of runs that use it |
|---|---|---|
| 1 | Level 76 Paladin | `i`, `me1`, `me2`, `sl1`, `rf1` |
| 2 | Level 1 Warlock (this row is selected by default) | Most runs |
| 3 | Another character | `e` (only selects it on the character select page), `wd1` |
| 4 | Level 88 Sorceress, with a mercenary | `f`, `q`, `tp`, `cb`, `pg1`, `bdm`, `rf2`, `me3` |
Many tap positions and criteria also depend on things these characters already have (scrolls in the inventory, equipment worn, stash contents, waypoints already opened).
**This four-character save is not in the repository; you need to provide your own.** The smoke test save generated by `tools/make_fixture.sh` has only two newly created characters and is placed in the same directory; which runs can pass when the regression is run with it has not been verified. To run the whole suite, you have to prepare a save that satisfies the table above yourself, put it in that directory, and rebuild the package.
The items, gold and positions each run needs do not come from the save; they are given on the spot after entering the game by test switches (`DM_TEST_GIVE` and others, written in the definition of each run in `uireg.py`), and the random seed and game time are fixed, so the same save yields the same in-game state on every run.
### Dedicated saves
The runs below do not use the standard save but swap in a dedicated save instead. These are likewise not in the repository; you need to provide your own. The directory names are hard-coded in the script and have no meaning of their own:
| Directory name | Runs that use it | Contents the script assumes |
|---|---|---|
| `save.pw_rune_stack` (the name can be changed with `UIREG_STACK_SAVE`) | `d`, `t`, `u` | Warlock; the rune page of the stash has one stack of 12 runes |
| `save.rg_act4done` | `g1`–`g4` | A character that has completed Act IV |
| `save.rg_act4` | `ex` | A character in Act IV with the waypoint opened |
| `save.rg_joejoe` | `tb`, `dz` | A character in Act II; the script goes from the waypoint in town to the Canyon of the Magi; `dz` also needs the quest staff in the inventory |
| `save.sl_player` | `vf1` | A character with items in both the personal stash and the shared stash |
Where to put them: place the save directory under the `Data` directory of this app's container on the Mac (at the same level as `Documents`); the directory must be writable. Before such a run starts, `run_mac.sh` moves the existing `Documents/save` in the container aside and puts in a copy of the dedicated save, then moves it back when the run is finished; should it fail to move it back, it reports red and states where the original save is.
When the corresponding directory does not exist, that run fails immediately and states in `fail.txt` which save is missing, without affecting other runs.
## Which runs exist
A run name is the first argument of `G("…")` in `uireg.py`; below they are grouped by content. For exactly what each item taps and what it judges, the definition of that run in `uireg.py` is authoritative.
| Run | Contents |
|---|---|
| `e` | Character select page, character creation, naming (creates a new character and enters the game) |
| `v` | Create a character after ticking the additional mode on the character creation page, enter the game, open the stash and look at the shared page |
| `a` | Swapping gear in equipment slots, bottom bar and panel tabs, minimap, stick, casting skills in the wild, pause menu and settings page |
| `b` | NPC dialogue menu, buying and selling on the merchant page, single tap / drag and drop / double tap / long press in the inventory |
| `c` | Stash drag and drop and tabs, gold amount box, tapping outside the box while several kinds of dialog are open |
| `s`, `sb` | Put a rune into the stash and take it out again; tap every button of the stash one by one |
| `d`, `t`, `u` | Taking items from a stacked slot: the basic gesture, with the Horadric Cube in the inventory, with only one free slot left in the inventory (dedicated save) |
| `g`, `h` | Skill binding; the `综合技能` (general skills) page of the skill tree |
| `i`, `f`, `q`, `bdm` | Mercenary: hiring and reviving, inventory drag and drop with a mercenary, double-tapping a belt potion to feed the mercenary |
| `j`, `k` | Socketing; making one runeword |
| `rw1`, `rw2`, `rwp`, `rwd` | Runeword list: opening by long press, paging and details, one-tap crafting |
| `m`, `n`, `p`, `ra` | Merchant page: dragging onto the merchant panel to sell, long press on the shelf to buy in bulk, long press on a potion to refill the belt, repair all |
| `me1`–`me4` | Two-row / three-row / four-row dialogue menus when different characters face the same NPC |
| `sl1`, `sl2`, `sl3` | Imbuing, adding sockets, personalizing. `sl2` and `sl3` are marked in the script comments as drafts that have not actually been run yet |
| `cb` | With the Horadric Cube page open, double tap to send items into / out of the Horadric Cube |
| `bd`, `ba` | Belt: double tap on an empty slot to fill up, automatic belt refill when opening the inventory |
| `pk`, `g1`–`g4`, `ex`, `tb`, `tp`, `dz` | Tapping things in the world: the tappable range of a chest, the upper, middle and lower sections of a portal, exits, the town portal, the quest pedestal (most need dedicated saves) |
| `wp` | Entering the game lands next to the town waypoint |
| `rf1`–`rf3` | One-tap restart from the pause menu, restarting three times in a row per run |
| `pg1`, `pg2` | Paging through the personal stash |
| `vt1`, `vf1`, `vf2` | The sixth tab of the stash (the collection page added by the shell): deposit, withdraw, search, switching back and forth between tabs |
| `kba`, `kbb` | Kill statistics panel: tap each widget one by one; look at the statistics after kills |
| `wd1`, `wd2` | No-progress watchdog: no false positive when returning to the front end and sitting idle; it still triggers when nothing moves at all after launch |
| `dc` | Death in the wild → tap `继续` (Continue) on the death screen → revive in town |
| `top` | Exists only in the `ipadfull` profile: the minimap and area name at the true top of the screen, and the title bars of the panels |
The scope when no run name is given:
- `iphone`, `ipadfull`: everything in the table above (`top` only in `ipadfull`).
- `ipad` (the bordered profile is not the default picture on iPad): runs only the part related to the screen aspect ratio, automatically skipping `d g h j k t u v m n p ra q pk g1–g4 ex tb tp`, and skipping the casting-in-the-wild part within run `a`. They can still be run when named explicitly.
- The tap positions of `g1`–`g4` have only been measured for the two sets `iphone` and `ipadfull`.
## Environment variables
| Variable | Meaning | Default |
|---|---|---|
| `UIREG_RUNNER` | Runner script | `run_mac.sh` in the same directory |
| `UIREG_OUT` | Output root directory | `$DM_ROOT/run/uireg` |
| `UIREG_APP` | The package for the `iphone` profile (`<name>.app`, containing `Wrapper/DmIOS.app`) | `.iosdd_mac/DmMacSmoke.app` under the repository root |
| `UIREG_APP_IPAD` | The package for the `ipad` / `ipadfull` profiles | None, must be given |
| `UIREG_STACK_SAVE` | Directory name of the dedicated save for runs `d`, `t`, `u` | `save.pw_rune_stack` |
| `UIREG_EXTRA_ENV` | Environment variables added to the app for every run (space-separated `K=V`) | Unset |
| `UIREG_FORBID` | Regular expression: if it appears anywhere in the log of a run, the run counts as failed | Unset |
| `UIREG_REQUIRE` | Regular expression: must appear in the log of the run; the result states the number of occurrences (used to confirm that a certain switch really took effect) | Unset |
| `UIREG_TAG` | Prefix of each run's artifact directory name (keeps two regression passes apart when they queue one after the other) | `ur` |
| `SMOKE_OWNER` | The name shown while queueing for the lock | `未署名` (unsigned) |
## Packages for the iPad profiles
The repository has no separate script for building an iPad package. The procedure is the same as the two packaging steps in `tools/smoke_mac.sh`, with just one more build setting:
1. The same `xcodebuild` command, with `DM_DEVICE_FAMILY=1,2` added at the end (adds iPad to the device family; the project targets only iPhone by default, see `../../project.yml`).
2. Wrap it the same way as `<name>.app/Wrapper/DmIOS.app`, plus the `WrappedBundle` symlink.
Use a new directory name each time you build a package, then give the path to `UIREG_APP_IPAD`.
## Rules for swapping packages
When a Mac runs an iOS package, the system mounts `<package>/Wrapper` in order to run it. If this directory is deleted or replaced wholesale while it is mounted, a stale mount point that cannot be unmounted is left behind; that path can no longer be opened from then on, and only a reboot clears it. So:
- Do not touch the package while it is running.
- To swap packages, use a different directory name; or only do incremental updates of same-named files, without deleting or wholesale replacing `Wrapper`.
`run_mac.sh` itself does not copy the package; it launches directly from the given path.
## Running on a real device
```bash
UIREG_RUNNER=dm/ios/tools/uireg/run_dev.sh python3 dm/ios/tools/uireg/uireg.py iphone a c
```
`run_dev.sh` runs **the package that is already installed** on the phone through `../touch_e2e.sh`; the prerequisites are the same as for the real-device smoke test (see "Real-device smoke test" in [../../README.md](../../README.md)). Differences from running on a Mac:
- Only the `iphone` profile.
- Runs that need dedicated saves are not run.
- Each run is collected only after running for the full limit in seconds; the log is cut off at the marker for the end of the script, and the full text is saved separately as `boot_full.txt`.
- By default only the log is pulled back, not the screenshots, so items that need screenshots are all `未判` (not judged) on a real device. To pull certain screenshots, name them with `UIREG_PULL="<file name> <file name>"`.
- It is not responsible for installing the package. To guarantee that what is under test is the package you just installed yourself, take the device lock in an outer layer first and wrap "install + run" together (the device lock is reentrant, `../devlock.sh`).
## Picking runs by change
```bash
python3 dm/ios/tools/uireg/uireg_pick.py <commit or branch under test> --main <main branch>
```
It compares which files have changed since the fork point between the commit under test and the main branch, lists which runs should be run according to `affected.tsv` (path glob → affected runs), and the last line, `局:…` (runs: …), gives the names of the runs to run. `*` means the whole table has to be run; source files under `dm/` that are not registered are treated as the whole table. With `--core`, or when there are no affected runs at all, a set of core runs defined in the script is merged in. When adding a new run, remember to register it in `affected.tsv`.
## The run attached after the Mac smoke test
When `tools/smoke_mac.sh` is run with `SMOKE_UIREG=1`, one pass of `iphone b` is additionally run after the smoke test passes:
- It runs in the background and does not affect the smoke test's own result or exit code.
- It uses a cloned copy of the package of this smoke test, so smoke-testing again or re-wrapping right afterwards cannot touch the copy it has open.
- When it finishes, it adds one line to the smoke test record `$DM_ROOT/run/ios/smoke_ledger.tsv`, where the result column is `Mac:界面回归b:OK` or `Mac:界面回归b:RED` (`界面回归` = UI regression). The condition for passing: all items that have a criterion pass, and the log has 0 red lines; `未判` (not judged) items are not counted.
- If it is red, the artifacts are left under `uireg/` in the result directory of that smoke test, and the next smoke test gives a one-line reminder at its start.
Note that run `b` likewise depends on the standard save described above.
## Conventions for writing your own runner script
If you want the same set of cases to run in another environment, you can write another runner script and point `UIREG_RUNNER` at it:
- Invocation: `bash $UIREG_RUNNER <tag> <limit seconds>`, with the touch script given on standard input.
- Environment variables passed in: `PW_ENV` (space-separated `K=V`, added as is to the app's launch environment), `PW_SAVE` (directory name of the dedicated save to swap in; empty for most runs), `UIREG_MODE` (screen profile; pick the package according to it), `UIREG_OUT`.
- Put the outputs in `$UIREG_OUT/pw/<tag>/`: `boot.txt` (required), screenshots (using the original names given by `shot` in the script), `timing.txt` (one line of text starting with `计时:` (timing:), which is copied as is into the result table), `c2s.jsonl` (a record of the command packets the game sends; may be absent).
- The last line of the touch script is `<seconds> note 结束` (`结束` = end): the run can be collected as soon as `[script] note 结束` appears in the log, and the limit in seconds is only a fallback.
+204
View File
@@ -0,0 +1,204 @@
# uireg — 触摸界面的脚本化回归
English: [usage.md](usage.md)
把触摸界面逐项点一遍,每项出一行「期望 → 真结果」。被测的是 iOS 包本身,只用触点脚本驱动(和真手指走同一条路,见 [../../README.zh-CN.md](../../README.zh-CN.md)「触点脚本」),判据读这一局的日志。
**先说存档**:整套回归是照着一份特定的多角色存档写的,这份存档不随仓库提供,也不能分发。仓库里能生成的冒烟存档只够跑冒烟。详见下面「需要什么存档」;没有那份存档时,多数局的现场和点位对不上。
## 文件
| 文件 | 作用 |
|---|---|
| `uireg.py` | 全部用例与判据:生成每一局的触点脚本、调起局脚本、读日志出结果表 |
| `run_mac.sh` | 起局脚本(缺省):在本机跑 Mac 上的 iOS 包 |
| `run_dev.sh` | 起局脚本:在真机 iPhone 上跑已装好的包 |
| `uireg_pick.py`、`affected.tsv` | 按改动的文件挑出受影响的局 |
## 前提
1. 能在 Mac 上跑 iOS 包:先按 [../../README.zh-CN.md](../../README.zh-CN.md)「冒烟」跑通一次 `tools/make_fixture.sh` 和 `tools/smoke_mac.sh 1`。这之后本机就有包好的包(仓库根目录下 `.iosdd_mac/DmMacSmoke.app`;源码不是用 git 克隆来的话,它在你运行冒烟脚本时所在的目录下)、这个 App 的容器,以及容器里的游戏资源。
2. 本机配置 `dm/ios/local.env` 里有 `DM_BUNDLE_ID`。
3. 部分判据要读截图,需要 `python3` 能 `import PIL`(Pillow)。没有也能跑,这些项会报「未判」。
全部步骤都可以只在本机做,不需要第二台 Mac。
## 跑法
```bash
# 在仓库根目录执行
python3 dm/ios/tools/uireg/uireg.py iphone # 全部局
python3 dm/ios/tools/uireg/uireg.py iphone b # 只跑 b 局
python3 dm/ios/tools/uireg/uireg.py iphone a c e # 跑几局
```
第一个参数是画面档:
| 画面档 | 含义 | 用哪个包 |
|---|---|---|
| `iphone` | iPhone 比例 | `UIREG_APP`,缺省是仓库根目录下的 `.iosdd_mac/DmMacSmoke.app`(源码不是用 git 克隆来的话没有缺省值,要自己给) |
| `ipadfull` | iPad 真全屏(iPad 上的缺省画面:3D 铺满整屏,界面是贴底的一块 16:9) | `UIREG_APP_IPAD`,必须给 |
| `ipad` | iPad 16:9 留边 | 同上 |
一局 = 启动一次 App、走一段脚本、退出。各局互相独立,可以单独跑。局与局之间串行:同一个包名在一台 Mac 上只能有一个实例,起局脚本用 `$DM_ROOT/run/ios/macsmoke.lock` 这把锁和 Mac 冒烟排队。
### 结果怎么看
- 每跑完一局打印一行:墙钟时间、计时分段、日志里的红行数。
- 最后一行:`# 共 N 项:通 A、不通 B、未判 C;合计墙钟 … 秒;表 <路径>`,后面跟着每个没通过或未判的项。
- 结果表:`$UIREG_OUT/tables/<画面档>_<月日_时分>/表.md`。
- 每局的现场:`$UIREG_OUT/pw/<前缀>_<画面档>_<局名>/`,里面有 `boot.txt`(这一局的日志)、`script.txt`(实际用的触点脚本)、截图、`timing.txt`。
「未判」有两种:这一项只留了截图、没有日志判据;或者判据要读截图但读不出来。两种都要人看图才能下结论,不会被当成通过。
每一项的判据只看日志里该项记号之后的那一段。红行的口径不只是带「【红】」的行,还包括 `FATAL`、看门狗、GPU 命令缓冲出错等,正则在 `uireg.py` 的 `LOGRED`。
## 需要什么存档
### 标准存档
多数局启动时带 `DM_SAVE_FRESH=warlock`:App 把自带的标准存档拷一份新的来用,不碰真实存档。标准存档是出包时从 `$DM_ROOT/data/switch/save_ref_warlock/0000000000000001/0/` 带进 App 的。
脚本假定这份存档的选角列表里有四个角色,并且各局按行号去选:
| 行 | 脚本假定的角色 | 用到它的局举例 |
|---|---|---|
| 1 | 76 级圣骑士 | `i`、`me1`、`me2`、`sl1`、`rf1` |
| 2 | 1 级术士(缺省选这一行) | 大多数局 |
| 3 | 另一个角色 | `e`(只在选角页选中它)、`wd1` |
| 4 | 88 级法师,带佣兵 | `f`、`q`、`tp`、`cb`、`pg1`、`bdm`、`rf2`、`me3` |
许多点位和判据还依赖这些角色身上现成的东西(背包里的卷轴、身上的装备、仓库内容、已开的小站)。
**这份四角色存档不在仓库里,需要自备。** `tools/make_fixture.sh` 生成的冒烟存档只有两个新建的角色,放在同一个目录;用它跑回归,哪些局能过没有验证过。要跑整套,得自己准备一份满足上表的存档放到那个目录,再重新出包。
各局需要的物品、金币、站位不靠存档,由测试开关在进局后当场给出(`DM_TEST_GIVE` 等,写在 `uireg.py` 每一局的定义里),并固定了随机种子与游戏时间,所以同一份存档每次跑出来的现场相同。
### 专用存档
下面几局不用标准存档,而是换上一份专用存档。它们同样不在仓库里,要自备;目录名是脚本里写死的,名字本身没有含义:
| 目录名 | 用它的局 | 脚本假定的内容 |
|---|---|---|
| `save.pw_rune_stack`(可用 `UIREG_STACK_SAVE` 改名) | `d`、`t`、`u` | 术士;箱子的符文页里有一叠 12 个符文 |
| `save.rg_act4done` | `g1`–`g4` | 第四幕已通关的角色 |
| `save.rg_act4` | `ex` | 在第四幕、小站已开的角色 |
| `save.rg_joejoe` | `tb`、`dz` | 在第二幕的角色,脚本从城里的小站去法师峡谷;`dz` 还要背包里带着任务法杖 |
| `save.sl_player` | `vf1` | 个人仓库与共享仓库里都有物品的角色 |
放法:把存档目录放到 Mac 上这个 App 容器的 `Data` 目录下(和 `Documents` 同级),目录要可写。`run_mac.sh` 在这一局开始前把容器里现有的 `Documents/save` 挪开,换上专用存档的副本,跑完再挪回;万一挪不回会报红并写明原存档在哪。
没有对应目录时,这一局直接失败并在 `fail.txt` 里写明缺哪份存档,不影响别的局。
## 有哪些局
局名是 `uireg.py` 里 `G("…")` 的第一个参数,下面按内容分组。具体每一项点什么、判什么,以 `uireg.py` 里该局的定义为准。
| 局 | 内容 |
|---|---|
| `e` | 选角页、建角、起名(会新建一个角色并进局) |
| `v` | 勾选建角页上的附加模式后建角,进局开箱看共享页 |
| `a` | 装备位换装、底栏与面板页签、小地图、摇杆、野外技能施放、暂停菜单与设置页 |
| `b` | NPC 对话菜单、商人页买卖、物品栏的单击 / 拖放 / 双击 / 长按 |
| `c` | 储藏箱拖放与页签、金币数量框、几种弹框开着时点框外 |
| `s`、`sb` | 符文放进储藏箱再取出;储藏箱每个按钮逐个点 |
| `d`、`t`、`u` | 从成叠的格子里取件:基本手法、背包里带着魔盒时、背包只剩一格时(专用存档) |
| `g`、`h` | 技能绑定;技能树的「综合技能」页 |
| `i`、`f`、`q`、`bdm` | 雇佣兵:雇佣与复活、带佣兵时物品栏拖放、双击腰带药水喂佣兵 |
| `j`、`k` | 镶嵌;做一个符文之语 |
| `rw1`、`rw2`、`rwp`、`rwd` | 符文之语清单:长按打开、分页与详情、一键合成 |
| `m`、`n`、`p`、`ra` | 商人页:拖到商人面板卖出、货架长按大量购买、长按药水补腰带、全部修理 |
| `me1`–`me4` | 不同角色面对同一个 NPC 时两行 / 三行 / 四行的对话菜单 |
| `sl1`、`sl2`、`sl3` | 灌魔、打孔、个性化。`sl2`、`sl3` 在脚本注释里标明是还没实际跑过的草稿 |
| `cb` | 魔盒页开着时双击把物品送进 / 送出魔盒 |
| `bd`、`ba` | 腰带:空格双击补满、开背包自动补腰带 |
| `pk`、`g1`–`g4`、`ex`、`tb`、`tp`、`dz` | 点世界里的东西:箱子的可点范围、传送门上中下几段、出口、回城门、任务底座(多数要专用存档) |
| `wp` | 进局落在城镇小站旁 |
| `rf1`–`rf3` | 暂停菜单的一键重开,每局连开三次 |
| `pg1`、`pg2` | 个人仓库翻页 |
| `vt1`、`vf1`、`vf2` | 储藏箱的第六个页签(外壳加的收藏页):存入、取出、搜索、页签来回切 |
| `kba`、`kbb` | 击杀统计面板:各控件逐个点;击杀之后看统计 |
| `wd1`、`wd2` | 无进展看门狗:回到前端静置不误判;启动后一直不动仍会判定 |
| `dc` | 野外死亡 → 点死亡画面的「继续」→ 复活回城 |
| `top` | 只在 `ipadfull` 档存在:屏幕真顶部的小地图与地名、各面板标题栏 |
不写局名时的范围:
- `iphone`、`ipadfull`:上表全部(`top` 只在 `ipadfull`)。
- `ipad`(留边档不是 iPad 的缺省画面):只跑和画面比例有关的那部分,自动跳过 `d g h j k t u v m n p ra q pk g1–g4 ex tb tp`,`a` 局里跳过野外施放那一段。点名仍然可以跑。
- `g1`–`g4` 的点位只量了 `iphone` 和 `ipadfull` 两套。
## 环境变量
| 变量 | 含义 | 缺省 |
|---|---|---|
| `UIREG_RUNNER` | 起局脚本 | 同目录 `run_mac.sh` |
| `UIREG_OUT` | 产物根目录 | `$DM_ROOT/run/uireg` |
| `UIREG_APP` | `iphone` 档的包(`<名>.app`,里面是 `Wrapper/DmIOS.app`) | 仓库根目录下 `.iosdd_mac/DmMacSmoke.app` |
| `UIREG_APP_IPAD` | `ipad` / `ipadfull` 档的包 | 无,必须给 |
| `UIREG_STACK_SAVE` | `d`、`t`、`u` 局专用存档的目录名 | `save.pw_rune_stack` |
| `UIREG_EXTRA_ENV` | 每局都加给 App 的环境变量(空格分隔的 `K=V`) | 不设 |
| `UIREG_FORBID` | 正则:整局日志里出现就算不通 | 不设 |
| `UIREG_REQUIRE` | 正则:整局日志里必须出现,结果里写出现次数(用来确认某个开关真的生效了) | 不设 |
| `UIREG_TAG` | 每局现场目录名的前缀(两遍回归先后排队时分开放) | `ur` |
| `SMOKE_OWNER` | 排锁时显示的名字 | 未署名 |
## iPad 档的包
仓库里没有单独出 iPad 包的脚本。做法和 `tools/smoke_mac.sh` 里出包的那两步相同,只多一项构建设置:
1. 同样的 `xcodebuild` 命令,末尾加 `DM_DEVICE_FAMILY=1,2`(设备族里加上 iPad;工程缺省只面向 iPhone,见 `../../project.yml`)。
2. 同样包成 `<名>.app/Wrapper/DmIOS.app`,外加 `WrappedBundle` 软链。
每次出包用一个新的目录名,然后把路径给 `UIREG_APP_IPAD`。
## 换包的规矩
Mac 跑 iOS 包时,系统把 `<包>/Wrapper` 挂载出去运行。挂着的时候这层目录被删或被整体替换,会留下卸不掉的失效挂载点,那个路径从此打不开,只有重启能清。所以:
- 包在跑的时候不动它。
- 要换包就换一个目录名;或者只做同名文件的增量更新,不删、不整体替换 `Wrapper`。
`run_mac.sh` 自己不拷包,直接从给的路径启动。
## 在真机上跑
```bash
UIREG_RUNNER=dm/ios/tools/uireg/run_dev.sh python3 dm/ios/tools/uireg/uireg.py iphone a c
```
`run_dev.sh` 通过 `../touch_e2e.sh` 在手机上跑**已经装好的那个包**,前提与真机冒烟相同(见 [../../README.zh-CN.md](../../README.zh-CN.md)「真机冒烟」)。和 Mac 上的差别:
- 只有 `iphone` 档。
- 要专用存档的局不跑。
- 每局跑满上限秒才收;日志截到脚本结束的记号为止,全文另存为 `boot_full.txt`。
- 缺省只拉回日志,不拉截图,所以要看截图的项在真机上都是「未判」。要拉某几张截图,用 `UIREG_PULL="<文件名> <文件名>"` 点名。
- 它不负责装包。要保证被测的是自己刚装的包,在外层先取设备锁,把「装包 + 跑」包在一起(设备锁可重入,`../devlock.sh`)。
## 按改动挑局
```bash
python3 dm/ios/tools/uireg/uireg_pick.py <被测提交或分支> --main <主干分支>
```
它比较被测提交与主干的分叉点之后改了哪些文件,按 `affected.tsv`(路径通配 → 受影响的局)列出该跑哪些局,最后一行 `局:…` 就是要跑的局名。`*` 表示要跑整表;没有登记的 `dm/` 下的源文件按整表处理。加 `--core`,或者没有任何受影响的局时,会并上脚本里的一组核心局。新加一局时记得在 `affected.tsv` 里登记。
## 挂在 Mac 冒烟后面的那一局
`tools/smoke_mac.sh` 带 `SMOKE_UIREG=1` 时,冒烟通过后会加跑一遍 `iphone b`:
- 放在后台跑,不影响冒烟自己的结果和退出码。
- 用的是这次冒烟的包的一份克隆副本,所以紧接着再冒烟、重新包装都碰不到它正开着的那份。
- 跑完往冒烟记录 `$DM_ROOT/run/ios/smoke_ledger.tsv` 补一行,结果列是 `Mac:界面回归b:OK` 或 `Mac:界面回归b:RED`。通过的条件:有判据的项全通,且日志红行为 0;「未判」不计。
- 红了,现场留在那次冒烟结果目录的 `uireg/` 下,下一次冒烟开头会提示一句。
注意 `b` 局同样依赖上面说的标准存档。
## 自己写起局脚本时的约定
想让同一套用例跑在别的环境上,可以另写一个起局脚本,用 `UIREG_RUNNER` 指过去:
- 调用方式:`bash $UIREG_RUNNER <标签> <上限秒>`,触点脚本从标准输入给。
- 传入的环境变量:`PW_ENV`(空格分隔的 `K=V`,原样加到 App 的启动环境)、`PW_SAVE`(要换上的专用存档目录名,多数局为空)、`UIREG_MODE`(画面档,据此挑包)、`UIREG_OUT`。
- 产物放到 `$UIREG_OUT/pw/<标签>/`:`boot.txt`(必需)、截图(用脚本里 `shot` 给的原名)、`timing.txt`(一行以「计时:」开头的文字,会原样抄进结果表)、`c2s.jsonl`(游戏发出的命令包记录,可以没有)。
- 触点脚本的最后一行是 `<秒> note 结束`:日志里出现 `[script] note 结束` 就可以收,上限秒只是兜底。