nex_animation/scripts/ui/gateprobe.py

415 lines
26 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""反向验证:证明八道闸门的十四条判据「坏了会响、好了不响」(2026-11 第七轮起常驻)。
`gridcheck` / `rhythmcheck` / `tagcheck` / `btnrowcheck` / `footercheck` / `btnclustercheck` /
`tableaudit` 量像素,`semanticcheck` 量辅助技术语义与真实按键——八道闸门自己也需要被体检一次:豁免写宽一格、阈值调松一档,
闸门就会永远安静地返回 0,而页面该修的地方一个都没修。
这里不碰源码、不触发 HMR——直接在页面上种两块 fixture:
· `pb-*`(bad) :故意造出十六种缺陷——同族子块该用栅格却自然排列、流程条横向滚动、
同一行裸控件没坐进控件行(中心差 35px)、同一容器两档纵向间距、
收缩错位、标签铺语义色块、按钮组被劈成 2+1、
格子里并排内容越出单元格、整句散文当只读标签捅出容器右缘、
卡头行里还剩一整块没挪走却先把标题切成两行、
header 里那组横排按钮被劈成 2+1(第 17 轮删掉的旧豁免不许复活)、
浮层底部三颗按钮挤成 2+1(footercheck 管的那一族)、
不带任何类名的一簇按钮挤成 2+1(btnclustercheck 管的那一族)、
`div[role=button]` 没补 tabindex 的鼠标热区、带 `data-clickable` 却没键盘
路径的可点行、我们自己写的 `role=tab` 没进走位清单
(三条都是 semanticcheck 管的那一族)
——十六条缺陷,每条判据必须**点名**到它;
· `pg-*`(good):故意造出十九种**合法**形态(卡底 mt-auto 钉底、整块居中的排版、
正文 max-w-[72ch] 栏宽、.nex-chipbar 胶囊流、
容器自适应的流程条、让位后与字段同行的复选框、
放得下的「进度条 + 百分数」单元格、
kit Tag 自己收窄成 ellipsis 的长标签、
右端整块掉到第二行之后标题拿到整行的卡头、
整组竖排等宽的按钮组(现行唯一那条豁免)、
整组竖排等宽的浮层底部(ActionGroup 翻竖排之后的形状)、
补了 `tabindex=0` 的自定义控件、原生 `button`、热区里那颗 pointer 图标、
有按钮的行连同它里面的图标、自绘的 `role=img`、antd v5 的图标根节点、
antd 自己的页签(阶段 2 的既定修法与 antd 内部结构,闸门必须放行)。
任何一条对不上就退出 1——说明闸门瞎了或者过敏,先修闸门再谈页面。
同一块夹具会被几条判据分别评,所以夹具种数(16 bad + 19 good)与判据条数(14)本来就对不上:
末行 `GATEPROBE_OK 14/14` 数的是**判据**,别拿它去核对 fixture 个数。
用法:
.venv/bin/python scripts/ui/gateprobe.py
"""
import importlib.util
import os
import pathlib
import sys
from playwright.sync_api import sync_playwright
HERE = pathlib.Path(__file__).resolve().parent
BASE = os.environ.get("NEX_BASE", "http://127.0.0.1:5173")
USER = os.environ.get("NEX_USER", "admin")
PWD = os.environ.get("NEX_PASS", "admin1234")
def load(mod_name: str):
"""按路径加载闸门模块,直接复用它们的探针 JS,避免同一份判据写两遍。"""
spec = importlib.util.spec_from_file_location(mod_name, HERE / f"{mod_name}.py")
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
tagcheck = load("tagcheck")
rhythmcheck = load("rhythmcheck")
gridcheck = load("gridcheck")
btnrowcheck = load("btnrowcheck")
footercheck = load("footercheck")
btnclustercheck = load("btnclustercheck")
tableaudit = load("tableaudit")
semanticcheck = load("semanticcheck")
FIXTURE = r"""() => {
const old = document.getElementById('nex-gateprobe'); if (old) old.remove();
const host = document.createElement('div');
host.id = 'nex-gateprobe';
host.style.cssText = 'padding:24px;display:flex;flex-direction:column;gap:0';
host.innerHTML = `
<div class="pb-gap" style="display:flex;flex-direction:column;width:400px">
<div style="height:30px"></div>
<div style="height:30px;margin-top:8px"></div>
<div style="height:30px;margin-top:20px"></div>
</div>
<span class="ant-tag pb-tag" style="display:inline-block;width:120px;height:24px;
background:#f6ffed;color:#237804;border:1px solid #b7eb8f">反向验证标签</span>
<div class="pb-rag" style="display:flex;flex-direction:column;align-items:flex-start;width:400px">
<div style="width:400px;height:30px"></div>
<div style="width:150px;height:30px"></div>
<div style="width:250px;height:30px"></div>
</div>
<div class="pb-grid" style="display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:900px">
<input class="ant-input" style="width:120px" value="甲" />
<input class="ant-input" style="width:300px" value="乙" />
<input class="ant-input" style="width:160px" value="丙" />
</div>
<div class="pg-pin" style="display:flex;flex-direction:column;height:200px;width:400px">
<div style="height:40px"></div>
<div style="height:40px"></div>
<div class="mt-auto" style="height:40px"></div>
</div>
<div class="pg-center" style="display:flex;flex-direction:column;align-items:center;width:400px">
<div style="width:400px;height:30px;align-self:center"></div>
<div style="width:150px;height:30px;align-self:center"></div>
<div style="width:200px;height:30px;align-self:center"></div>
</div>
<div class="pg-measure" style="display:flex;flex-direction:column;width:400px">
<div style="height:30px"></div>
<div style="height:30px;max-width:200px"></div>
<div style="height:30px;max-width:240px"></div>
</div>
<div class="nex-action-group pb-btn" style="display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:260px">
<button class="ant-btn" style="width:120px;height:32px">甲</button>
<button class="ant-btn" style="width:120px;height:32px">乙</button>
<button class="ant-btn" style="width:120px;height:32px">丙</button>
</div>
<!-- 判据① 唯一的豁免(第 17 轮起):竖排等宽里子项本来就在不同水平线,必须放行 -->
<div class="nex-action-group ant-flex-vertical pg-stack"
style="display:flex;flex-direction:column;gap:8px;width:260px">
<button class="ant-btn" style="width:260px;height:32px">甲</button>
<button class="ant-btn" style="width:260px;height:32px">乙</button>
</div>
<!-- 被删掉的那条「<header> 里的组在 <1024 允许分行」不许悄悄回来:
坐在 header 里的横排组被劈成 2+1,一样要响 -->
<header><div class="nex-action-group pb-header"
style="display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:260px">
<button class="ant-btn" style="width:120px;height:32px">甲</button>
<button class="ant-btn" style="width:120px;height:32px">乙</button>
<button class="ant-btn" style="width:120px;height:32px">丙</button>
</div></header>
<div class="nex-chipbar pg-chipbar" style="display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:900px">
<span class="nex-chip ant-tag ant-tag-checkable" style="display:inline-block;width:80px;height:24px">甲</span>
<span class="nex-chip ant-tag ant-tag-checkable" style="display:inline-block;width:210px;height:24px">乙乙乙</span>
<span class="nex-chip ant-tag ant-tag-checkable" style="display:inline-block;width:120px;height:24px">丙丙</span>
</div>
<div role="list" class="pb-rail" style="display:flex;flex-direction:row;gap:8px;width:400px;
overflow-x:auto">
<div style="flex:none;width:200px;height:30px">完整视频</div>
<div style="flex:none;width:200px;height:30px">音效</div>
<div style="flex:none;width:200px;height:30px">字幕</div>
<div style="flex:none;width:200px;height:30px">交付包</div>
</div>
<div role="list" class="pg-rail" style="display:grid;width:900px;gap:8px;
grid-template-columns:repeat(auto-fill,minmax(140px,1fr))">
<div style="min-width:0;height:30px">完整视频</div>
<div style="min-width:0;height:30px">音效</div>
<div style="min-width:0;height:30px">字幕</div>
<div style="min-width:0;height:30px">交付包</div>
</div>
<div class="ant-row nex-form-row pb-ctl" style="display:flex;width:700px">
<div class="ant-col" style="width:300px">
<div class="ant-form-item">
<div class="ant-form-item-label" style="height:30px;line-height:30px;padding:0">环境声</div>
<div class="ant-form-item-control"><div class="ant-form-item-control-input"
style="height:32px"><input class="ant-input" style="width:100%" value="底噪"></div></div>
</div>
</div>
<div class="ant-col" style="width:300px">
<label class="ant-checkbox-wrapper" style="display:inline-block;margin-top:0;height:auto">启用字幕</label>
</div>
</div>
<div class="ant-row nex-form-row pg-ctl" style="display:flex;width:700px">
<div class="ant-col" style="width:300px">
<div class="ant-form-item">
<div class="ant-form-item-label" style="height:30px;line-height:30px;padding:0">环境声</div>
<div class="ant-form-item-control"><div class="ant-form-item-control-input"
style="height:32px"><input class="ant-input" style="width:100%" value="底噪"></div></div>
</div>
</div>
<div class="ant-col" style="width:300px">
<label class="ant-checkbox-wrapper" style="display:flex;align-items:center;height:32px;margin-top:30px">启用字幕</label>
</div>
</div>
<div class="nex-taggroup" style="width:220px"><span class="ant-tag pb-spill"
style="white-space:nowrap">反向验证长标签整句散文当只读标签必然捅出容器右缘</span></div>
<div class="nex-taggroup" style="width:220px"><span class="ant-tag nex-tag pg-spill"
><span class="nex-tag-text">合法长标签整句散文当只读标签由 kit 收在容器内</span></span></div>
<div class="ant-card" style="width:320px"><div class="ant-card-head-title">pb-tspill</div>
<div class="ant-table-wrapper"><div class="ant-table-content">
<table style="table-layout:fixed;width:300px"><tbody class="ant-table-tbody"><tr>
<td style="width:300px;padding:8px;white-space:nowrap;text-align:right">
<div style="display:inline-block;width:284px;height:6px;background:#1677ff"></div>
<small class="pb-tspill">100%</small>
</td>
</tr></tbody></table>
</div></div>
</div>
<div class="ant-card" style="width:320px"><div class="ant-card-head-title">pg-tspill</div>
<div class="ant-table-wrapper"><div class="ant-table-content">
<table style="table-layout:fixed;width:300px"><tbody class="ant-table-tbody"><tr>
<td style="width:300px;padding:8px;white-space:nowrap;text-align:right">
<div style="display:inline-block;width:220px;height:6px;background:#1677ff"></div>
<small class="pg-tspill">100%</small>
</td>
</tr></tbody></table>
</div></div>
</div>
<!-- 判据②(btnrowcheck.HEAD):320 的卡头里标题只剩 82px,
「还有一整块可以挪下去」却把标题切成两行 = 必须响 -->
<div class="ant-card nex-panel" style="width:320px"><div class="ant-card-head">
<div class="ant-card-head-wrapper" style="display:flex;flex-wrap:wrap">
<div class="ant-card-head-title" style="flex:1 1 0">
<span>pb-head镜头质检结论汇总清单表</span></div>
<div class="ant-card-extra" style="flex:0 0 auto;width:190px">重新质检 / 导出报告</div>
</div></div>
</div>
<!-- 浮层底部(footercheck):和页头同一个毛病,只是它长在抽屉里。
300 宽 260 内宽里三颗 120 的按钮挤成 2+1 = 必须响 -->
<div class="ant-drawer-footer pb-footer"
style="width:300px;padding:12px 20px;display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end">
<button class="ant-btn" style="width:120px;height:32px">甲</button>
<button class="ant-btn" style="width:120px;height:32px">乙</button>
<button class="ant-btn" style="width:120px;height:32px">丙</button>
</div>
<!-- 裸按钮簇(btnclustercheck):没有 kit 类名、不是浮层底部,前两道按钮闸结构上扫不到。
260px 里三颗 120 的按钮挤成 2+1 = 必须响(证明这把新尺子真的在看 DOM) -->
<div class="pb-cluster" style="width:260px;display:flex;flex-wrap:wrap;gap:8px">
<button class="ant-btn" style="width:120px;height:32px">甲</button>
<button class="ant-btn" style="width:120px;height:32px">乙</button>
<button class="ant-btn" style="width:120px;height:32px">丙</button>
</div>
<!-- 同一簇整组换行、每颗占满内宽(ActionGroup 的竖排档就是这个形状)= 必须放行 -->
<div class="pg-cluster" style="width:260px;display:flex;flex-wrap:wrap;gap:8px">
<button class="ant-btn" style="width:100%;height:32px">甲</button>
<button class="ant-btn" style="width:100%;height:32px">乙</button>
<button class="ant-btn" style="width:100%;height:32px">丙</button>
</div>
<!-- 底部交给 ActionGroup 之后窄屏的样子:整组竖排等宽 = 必须放行 -->
<div class="ant-drawer-footer pg-footer"
style="width:300px;padding:12px 20px;display:flex;flex-direction:column;gap:8px">
<button class="ant-btn" style="width:100%;height:32px">甲</button>
<button class="ant-btn" style="width:100%;height:32px">乙</button>
</div>
<!-- 同一句长标题,右端整块掉到第二行(kit 的 nex-head-stack 就是这个形状):
标题拿到整行,折行是排版 = 必须放行 -->
<div class="ant-card nex-panel" style="width:320px"><div class="ant-card-head">
<div class="ant-card-head-wrapper" style="display:flex;flex-wrap:wrap;row-gap:8px">
<div class="ant-card-head-title" style="flex:1 1 auto">
<span>pg-head模型配置已迁移至独立管理中心请前往模型控制台</span></div>
<div class="ant-card-extra" style="flex:1 1 100%">重新质检 / 导出报告</div>
</div></div>
</div>`;
(document.querySelector('main') || document.body).appendChild(host);
/* 语义热区的夹具必须种在 **body 直下**(第 8.5 轮的教训):semanticcheck 的 HOTSPOT
只审我们自己写的标记,main 是 `.ant-layout-content`、整棵树又裹在 `.ant-app` 里,
夹具种进 main 就会被「这是 antd 的东西」顺手放过——夹具假绿比没夹具更糟。
它同时是这条判据的**视力表**:这一族空转过一次(12 路由 × 3 视口恒 0),
靠的就是这对 fixture 报出来的。 */
const old2 = document.getElementById('nex-gateprobe-sem'); if (old2) old2.remove();
const host2 = document.createElement('div');
host2.id = 'nex-gateprobe-sem';
host2.style.cssText = 'display:flex;flex-direction:column;gap:8px;width:400px';
host2.innerHTML = `
<!-- 名字故意两两不互为前缀:hay 是子串匹配,pb-sem / pb-sem2 那种命名会让
「A 被点名」其实是 B 命中的,夹具就白造了 -->
<!-- ① div + role=button + cursor:pointer,没给 tabindex:鼠标点得动、Tab 到不了 = 必须点名 -->
<div class="pb-sema" role="button" style="cursor:pointer;height:32px;line-height:32px">
反向验证热区</div>
<!-- ② 同一个热区补上 tabindex=0(阶段 2 的修法)= 必须放行 -->
<div class="pg-sema" role="button" tabindex="0"
style="cursor:pointer;height:32px;line-height:32px">补过 tabindex 的热区</div>
<!-- ③ 原生 button = 天生可聚焦,必须放行(证明这条没在乱咬原生标签) -->
<button class="pg-semb" type="button" style="cursor:pointer;height:32px">原生按钮</button>
<!-- ④ 带 data-clickable(阶段 2 的热区约定)却没键盘路径 = 我们食言了,必须点名;
它里面那颗 pointer 图标只报最外层 = 必须放行 -->
<div class="pb-semb" data-clickable style="cursor:pointer;height:32px;line-height:32px">
可点的行<span class="pg-semc" style="cursor:pointer">行里的图标</span></div>
<!-- ⑤ 同样是 data-clickable 热区,但行里坐着一颗真按钮:键盘走得到那颗按钮
= 整行连同行里的图标都必须放行(噪声①/②,别把可点行报成两处) -->
<div class="pg-semd" data-clickable style="cursor:pointer;height:36px;line-height:36px">
有按钮的行<button class="pg-seme" type="button">打开</button></div>
<!-- ⑥ 我们自绘的 role=img(pointer、没 tabindex):HOTSPOT 的承诺是
「鼠标点得着的东西键盘也到得了」,这只对**交互角色**成立;img 只是语义标注,
要求它自己有 Tab 序列是判据越界(第 8.5 轮实测:每主题 5 条纯噪声)。
必须「收进候选、但不进硬档」。 -->
<span class="pg-semf nex-iconmark" role="img" style="cursor:pointer;display:block;height:20px">自绘的图标标注</span>
<!-- ⑦ antd v5 的图标根节点 class="anticon anticon-appstore",**不含 ant- 子串**:
认不出它就把 antd 自己的东西当成我们写的标记(实测每主题 5 条假阳性)。必须整个不收。 -->
<span class="pg-simg anticon anticon-appstore" role="img" style="cursor:pointer;display:block;height:20px">antd 图标</span>
<!-- ⑧ 页签走位清单(TAB 的输入):我们自己写的 role=tab 必须在册(否则 TAB 就是瞎的),
antd 的 .ant-tabs-tab-btn 必须不在册——它是 rc-tabs 自己的 DOM,
tabindex 归 antd 管(实测每主题 3 条假阳性,根因是自己的类名撞了 SHELL 名单被抢先豁免)。 -->
<div class="pb-semt" role="tab" tabindex="0" style="cursor:pointer;height:28px;line-height:28px">我们的页签</div>
<div class="pg-semt ant-tabs-tab-btn" role="tab" tabindex="0"
style="cursor:pointer;height:28px;line-height:28px">antd 的页签</div>
`;
document.body.appendChild(host2);
return [...host.querySelectorAll('[class]'), ...host2.querySelectorAll('[class]')].length;
}"""
def names(rows, key):
"""把检出结果摊平成「元素标记串」,再用 fixture 的类名点名。
`key` 可以是字段名,也可以是函数:tableaudit 的 PROBE 会把页面上**每一张**表
都返回(不管有没有违规),按 `title` 摊平的话合法 fixture 也会出现在串里,
「必须放行」永远对不上——所以给它一个只摊平违规明细的函数。
"""
# COLLECT 这类探针一次返回一整个 dict(热区/Tab 目标/aria/live/状态各一桶),
# 不是行数组。直接 for r in dict 摊到的是**键名**(字符串),r.get 当场 AttributeError。
if isinstance(rows, dict):
rows = [rows]
if callable(key):
return " | ".join(str(x) for r in rows for x in key(r))
return " | ".join(str(r.get(key, "")) for r in rows)
def main() -> int:
fails = []
with sync_playwright() as pw:
b = pw.chromium.launch()
pg = b.new_context(viewport={"width": 1440, "height": 1600}).new_page()
pg.set_default_timeout(20000)
pg.goto(BASE + "/login")
pg.wait_for_selector("#login-user")
pg.fill("#login-user", USER)
pg.fill("#login-pass", PWD)
pg.click("button[type=submit]")
pg.wait_for_url(lambda u: "/login" not in u, timeout=20000)
pg.goto(BASE + "/assets")
pg.wait_for_timeout(1400)
n = pg.evaluate(FIXTURE)
pg.wait_for_timeout(300)
print("fixture nodes:", n)
checks = [
("tagcheck", tagcheck.JS, "el", [("pb-tag", True), ("ant-input", False)]),
# 整句散文当只读标签、捅出容器右缘必须响;换成 kit Tag(max-width+ellipsis 自己收窄)必须放行
("tagcheck.SPILL", tagcheck.SPILL, "el",
[("pb-spill", True), ("pg-spill", False)]),
("rhythmcheck.GAP", rhythmcheck.GAP, "el",
[("pb-gap", True), ("pg-pin", False)]),
("rhythmcheck.RAG", rhythmcheck.RAG, "el",
[("pb-rag", True), ("pg-center", False), ("pg-measure", False)]),
("gridcheck", gridcheck.JS, "el",
[("pb-grid", True), ("pg-chipbar", False),
# 流程条横滚必须响;容器自适应 grid 铺开的流程条必须放行
("pb-rail", True), ("pg-rail", False),
# 同行裸复选框贴着标签行(中心差 35px)必须响;
# 让出标签块、坐进 32px 控件行的必须放行(glue ⑥ 的形态)
("pb-ctl", True), ("pg-ctl", False)]),
# 按钮组被劈成 2+1 必须响;栅格那块(三种宽度三种控件的横排)与胶囊流不是它管的
("btnrowcheck", btnrowcheck.JS, "el",
[("pb-btn", True), ("pb-grid", False), ("pg-chipbar", False)]),
# 唯一那条豁免必须放行;旧那条「父级是 header 的组在 <1024 允许分行」
# 第 17 轮删了,这里钉住它不许悄悄复活:header 里的横排组被劈成 2+1 一样要响
("btnrowcheck.exempt", btnrowcheck.JS, "el",
[("pg-stack", False), ("pb-header", True)]),
# 卡头标题被切成两行(行里还剩着一整块没挪走)必须响;
# 右端整块掉到下一行、标题拿到整行的必须放行——判据②的两面
("btnrowcheck.HEAD", btnrowcheck.HEAD, "el",
[("pb-head", True), ("pg-head", False)]),
# 浮层底部(第 17 轮补):抽屉/对话框吸底那几条按钮以前不在任何闸门的路线表里,
# 现在 Overlay.DRAWER_ACTIONS = ActionGroup,底部由 footercheck 开层量。
# 摊平用函数:只看判据算下来真违规的那几条的类名。
("footercheck", footercheck.JS,
(lambda r: [r["cls"]] if r.get("bad") else []),
[("pb-footer", True), ("pg-footer", False)]),
# 裸按钮簇(第 17 轮续):不带任何 kit 类名的一组按钮被劈成 2+1 必须响;
# 整簇换行、每颗占满内宽必须放行——这把尺子的价值全在「不认类名」,
# 没有这对 fixture,它绿了也证明不了自己在看东西。
("btnclustercheck", btnclustercheck.JS,
(lambda r: [r["cls"]] if r.get("bad") else []),
[("pb-cluster", True), ("pg-cluster", False)]),
# 格子里并排内容越出单元格 / 互相压叠必须响,放得下必须放行。
# 摊平用函数:只看 spill 明细里的元素标识,不看那些本来就没违规的表名。
("tableaudit", tableaudit.PROBE,
lambda r: [it["k"] for it in r.get("spill", [])],
[("pb-tspill", True), ("pg-tspill", False)]),
# 键盘可达(第 8.5 轮补):pointer 热区没 tabindex 必须响;
# 补了 tabindex=0 的自定义控件与原生 button 必须放行——
# 前者钉住阶段 2 的修法不许退化,后者证明这条不是「见 div 就咬」。
# 摊平用函数:hotspots 只带 sig,别的判据返回的形状不一样。
("semanticcheck.HOTSPOT", semanticcheck.COLLECT,
(lambda r: [h["sig"] for h in r.get("hotspots", [])]),
[("pb-sema", True), ("pb-semb", True),
("pg-sema", False), ("pg-semb", False),
("pg-semc", False), ("pg-semd", False),
# antd 的图标根节点连候选都不该进:收进来就等于把 antd 的 DOM 当我们的契约
("pg-simg", False)]),
# 同一个判据的**硬档**单独验一遍:软/硬分档写错(role 非空就算硬)时,
# 上面那条看不出差别——它只比候选清单,而 pg-semf 本来就该在候选里。
("semanticcheck.HOTSPOT-hard", semanticcheck.COLLECT,
(lambda r: [h["sig"] for h in r.get("hotspots", []) if h.get("hard")]),
[("pb-sema", True), ("pb-semb", True),
("pg-sema", False), ("pg-semb", False), ("pg-semc", False),
("pg-semd", False), ("pg-semf", False)]),
# TAB 的输入是「自定义角色元素清单」。两头都要钉:
# 我们写的页签漏了 = TAB 永远查不到它(判据瞎);
# antd 自己的页签混进来 = 每次走位都报它找不到(假阳性,实测每主题 3 条)。
("semanticcheck.TABTARGET", semanticcheck.COLLECT,
(lambda r: [t["sig"] for t in r.get("tabTargets", [])]),
[("pb-semt", True), ("pg-semt", False)]),
]
for label, js, key, expectations in checks:
rows = pg.evaluate(js)
hay = names(rows, key)
for marker, should_fire in expectations:
hit = marker in hay
ok = hit == should_fire
print(f"{'OK ' if ok else 'FAIL'} {label:<18} {marker:<12} "
f"{'必须点名' if should_fire else '必须放行'} "
f"→ {'点名了' if hit else '没点名'}")
if not ok:
fails.append(f"{label}/{marker}")
print(" 实际:", hay[:400])
b.close()
if fails:
print("GATEPROBE_FAIL", " ".join(fails))
print("→ 闸门本身出问题:不是漏检(豁免写宽了)就是误报(豁免没生效),先修闸门")
return 1
print(f"GATEPROBE_OK {len(checks)}/{len(checks)} 闸门坏了会响、好了不响")
return 0
if __name__ == "__main__":
sys.exit(main())