pi 用 `/tmp/mut/` 复算后指出:48 也不对。他是对的,而且**不是记性问题、是口径问题**——
我把 9 个 `jobs*.json` 的条目**直接相加**,没做归一:同一个变异体在跨批重锚时被键了多次
(13 组重复、15 条冗余),最典型的是「计划不搬运模糊值」同时挂在 `jobs-b3`/`jobs-blur`/`jobs-blur2`
三个文件、三个不同 `test` 键上 —— 于是"按判据文件分组求和"必然把它算三次,
而"跑在新增判据上的是多少"在交叉归类下**没有唯一答案**(41 或 35)。
更根本的是 pi 指出的第二层:**那个统计脚本根本不在 `/tmp/mut/` 里**(他为了复算是现写的),
而且 `/tmp` 会被清、不在仓库里 ⇒ 变异体数字**只活在信里**。
这一路已经立过同形状的规则(余额打在 `RESULT` 行、权威源在文件里),这条当时漏了。
## 做了什么
- `client/electron/test/mutants/`:把 `mut.py`、`run.sh`、`jobs*.json`、`baseline.sha`
从 `/tmp` 挪进仓库(`/tmp` 会清、复核方够不着)。
- `mutants/summary.py`:**口径的唯一权威**,定义写死在代码里:
· 不同变异体 = 按 (file, pat, repl) 去重(`retired` 不计);
· 跑起来 = 锚点在该文件里**恰好命中 1 次**(与 mut.py 同一条件);
· `on_new_criteria` = 该变异体的**每一个** test 键都指向本批新增的两个判据文件
(口径 A —— 不因交叉归类虚高;另报口径 B 作参考,它只增不减,不拿来报数)。
- `run-all.mjs` 的 `RESULT` 行播报它,并**顺带自证基线**:跑不起 `summary.py` 时
**不静默**(打印 status 与 stderr 末行)——我第一版路径写错,只看到"计数未知",
真因(`can't open file …/test/test/mutants/summary.py`)被吞掉了。
- `mutants/test-keys.json`:`test` 键 → 判据文件的**唯一来源**(`mut.py` 与 `summary.py`
共用)。此前两处各写一份,分叉过一次:键名从旧名换成 API 名后 `summary.py` 那份没跟上,
于是所有锚点被判 `hits=-1`、报出"51 个变异体全部 skipped"。
- 无歧义口径下的**当前真值**:`mutants=48 ran=48 skipped=0 on_new_criteria=36 baseline=7/7✓`
(口径 B = 41;原始条目 66,其中 `retired` 5)。
- 清掉 pi 指出的三类脏数据:
· **过期条目**(锚点是修复前的旧写法,`hits=0`)标 `retired` 5 条 ——
它们**不是"没跑成的变异体"**,重锚后都跑过、都红了;留着只会把 skipped 一直抬高;
· **重复计数**(multipart 那条在两个文件里各一次)去重;
· **真 skip** 的 multipart 锚点切片成 `name: 'file',\n contentType: mimeType` ⇒ 真的跑起来了
(此前命中 2 次,因为 `ApiClient.ets` 有两个 multipart 构造器)。
- 修两处并发/竞争:`mut.py` 的 `tempfile.mktemp()`(Py3 起 deprecated,**TOCTOU**)→ `mkstemp`;
`run.sh` 的固定 `/tmp/mut/bak` → 按 `$$-$RANDOM` 唯一(并行跑会互相覆盖备份)。
## 未做(如实说)
- **`AdminUsersPage.ets` 有一处不是我做的改动留在工作树里**(11:20:48,我 11:21 的提交之后):
`Chip(text, bg, fg: string)` → `ResourceColor`。核实过是**正确的 ArkTS 修法**
(`Theme.surfaceMuted`/`textSubtle` 是 `Resource`、`chipNeutralBg` 是 `string`,
第 368 行的三目因此是 `Resource | string` ⇒ 旧签名**编译不过**)。
我**没有提交也没有回退**它 —— 工作树是共享的,不该替别人提交别人的活。
基线因此重算了(`baseline.sha` 顶部记了原因与哈希来源,重算本身是**有意动作**:
随手重算会把"某次变异没还原"永久掩盖掉)。
- Go 侧 `debt_registry_test.go` 仍未跑(沙箱无 Go 模块缓存),只做了 `gofmt`。
234 lines
7.9 KiB
JSON
234 lines
7.9 KiB
JSON
[
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/AdminUsers.ts",
|
||
"pat": "return role === 'admin';",
|
||
"repl": "return role !== undefined && role.trim().toLowerCase() === 'admin';",
|
||
"test": "admin",
|
||
"why": "角色判定放宽"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/AdminUsers.ts",
|
||
"pat": " if \\(!found\\) \\{\n out\\.push\\(item\\);\n \\}\n return out;",
|
||
"repl": " if (!found) {\n list.push(item);\n }\n return list;",
|
||
"test": "admin",
|
||
"why": "toggled 就地改入参"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/AdminUsers.ts",
|
||
"pat": "if \\(v === undefined \\|\\| v\\.length === 0\\) \\{",
|
||
"repl": "if (v === undefined) {",
|
||
"test": "admin",
|
||
"why": "空串不当从未登录"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/AdminUsers.ts",
|
||
"pat": " if \\(user\\.role === 'admin'\\) \\{\n return false;\n \\}\n",
|
||
"repl": "",
|
||
"test": "admin",
|
||
"why": "管理员也打受限徽标"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/AdminUsers.ts",
|
||
"pat": "return '操作失败(服务端没有给原因)';",
|
||
"repl": "return '操作失败';",
|
||
"test": "admin",
|
||
"why": "兜底句不说原因缺席"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/AdminUsers.ts",
|
||
"pat": " return message;\n \\}\n if \\(!isApiError",
|
||
"repl": " return '操作失败';\n }\n if (!isApiError",
|
||
"test": "admin",
|
||
"why": "吞掉服务端文案"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "const longest: number = Math\\.max\\(width, height\\);",
|
||
"repl": "const longest: number = width;",
|
||
"test": "prep",
|
||
"why": "缩放按宽算"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "const scale: number = Math\\.min\\(1, maxEdge / longest\\);",
|
||
"repl": "const scale: number = maxEdge / longest;",
|
||
"test": "prep",
|
||
"why": "小图被放大"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "second\\.maxEdge = RETRY_EDGE;",
|
||
"repl": "second.maxEdge = MAX_EDGE;",
|
||
"test": "prep",
|
||
"why": "退档不降分辨率"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "second\\.quality = RETRY_QUALITY;",
|
||
"repl": "second.quality = FIRST_QUALITY;",
|
||
"test": "prep",
|
||
"why": "退档不降质量"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "return actualBytes > MAX_UPLOAD_BYTES;",
|
||
"repl": "return actualBytes >= MAX_UPLOAD_BYTES;",
|
||
"test": "prep",
|
||
"why": "等于上限也退档"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "if \\(sizeBytes > MAX_SOURCE_BYTES\\) \\{",
|
||
"repl": "if (sizeBytes >= MAX_SOURCE_BYTES) {",
|
||
"test": "prep",
|
||
"why": "边界 >= 而不是 >"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "if \\(!mimeType\\.startsWith\\('image/'\\)\\) \\{",
|
||
"repl": "if (false) {",
|
||
"test": "prep",
|
||
"why": "不判类型"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "return '上传失败:' \\+ serverMessage;",
|
||
"repl": "return '上传失败';",
|
||
"test": "prep",
|
||
"why": "吞掉上传失败文案"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "export const MAX_UPLOAD_BYTES: number = 3_670_016;",
|
||
"repl": "export const MAX_UPLOAD_BYTES: number = 6_291_456;",
|
||
"test": "prep",
|
||
"why": "上限超过服务端 4MiB"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/model/ImagePrep.ts",
|
||
"pat": "export const MAX_EDGE: number = 2560;",
|
||
"repl": "export const MAX_EDGE: number = 4096;",
|
||
"test": "prep",
|
||
"why": "首档最长边改 4096"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/pages/AdminUsersPage.ets",
|
||
"pat": " if \\(isRestricted\\(user\\)\\) \\{",
|
||
"repl": " if (false) {",
|
||
"test": "admin",
|
||
"why": "去掉受限徽标"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/pages/AdminUsersPage.ets",
|
||
"pat": " onlyStatus\\.status = 'active';",
|
||
"repl": " onlyStatus.status = 'active';\n onlyStatus.display_name = this.editDisplayName;",
|
||
"test": "admin",
|
||
"why": "启停顺带发 display_name"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/pages/AdminUsersPage.ets",
|
||
"pat": " \\.backgroundColor\\(Theme\\.surface\\)\n \\.borderRadius\\(Theme\\.radiusCard\\)\n \\.onClick\\(\\(\\) => \\{ this\\.toggleEdit\\(user\\); \\}\\)",
|
||
"repl": " .backgroundColor('#123456')\n .onClick(() => { this.toggleEdit(user); })",
|
||
"test": "admin",
|
||
"why": "写死色值 + 去卡片圆角"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/pages/SettingsPage.ets",
|
||
"pat": " this\\.isAdmin = false;\n \\}",
|
||
"repl": " this.isAdmin = true;\n }",
|
||
"test": "admin",
|
||
"why": "身份读不到时乐观显示入口"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/pages/SettingsPage.ets",
|
||
"pat": " if \\(this\\.isAdmin\\) \\{",
|
||
"repl": " if (true) {",
|
||
"test": "admin",
|
||
"why": "管理入口不做门禁"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/pages/SettingsPage.ets",
|
||
"pat": " @State isAdmin: boolean = false;",
|
||
"repl": " @State isAdmin: boolean = true;",
|
||
"test": "admin",
|
||
"why": "isAdmin 初值 true"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/common/BackgroundPicker.ets",
|
||
"pat": "if \\(!overLimit\\) \\{\n\\s*break;",
|
||
"repl": "if (true) {\n break;",
|
||
"test": "prep",
|
||
"why": "永远只压第一档"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/common/BackgroundPicker.ets",
|
||
"pat": "if \\(packed === null \\|\\| overLimit\\)",
|
||
"repl": "if (packed === null)",
|
||
"test": "prep",
|
||
"why": "两档都超限不拒绝"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/common/BackgroundPicker.ets",
|
||
"pat": "overLimit = shouldRetryWithActual\\(usedBytes\\);",
|
||
"repl": "overLimit = false;",
|
||
"test": "prep",
|
||
"why": "结论恒 false"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/common/BackgroundPicker.ets",
|
||
"pat": "await packer\\.release\\(\\);",
|
||
"repl": "packer.release();",
|
||
"test": "prep",
|
||
"why": "packer.release 不 await"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/common/BackgroundPicker.ets",
|
||
"pat": "await head\\.release\\(\\);",
|
||
"repl": "head.release();",
|
||
"test": "prep",
|
||
"why": "head.release 不 await"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/common/BackgroundPicker.ets",
|
||
"pat": "desiredSize: \\{ width: size\\.width, height: size\\.height \\}",
|
||
"repl": "desiredSize: { width: info.size.width, height: info.size.height }",
|
||
"test": "prep",
|
||
"why": "按原图尺寸解码"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/common/BackgroundPicker.ets",
|
||
"pat": " quality: Math\\.round\\(quality \\* 100\\)",
|
||
"repl": " quality: quality",
|
||
"test": "prep",
|
||
"why": "quality 不换算"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/common/BackgroundPicker.ets",
|
||
"pat": " this\\.onUploaded\\(UPLOAD_OK_HINT\\);",
|
||
"repl": " this.bgKind = 'image';",
|
||
"test": "prep",
|
||
"why": "组件自己宣布成功"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/api/ApiClient.ets",
|
||
"pat": "name: 'file',\n contentType: mimeType",
|
||
"repl": "name: 'image',",
|
||
"test": "prep",
|
||
"why": "multipart 字段名不是 file(uploadBytes 那一处;此前锚点命中 2 次跑不起来,已切片)"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/api/AppearanceApi.ets",
|
||
"pat": "fileName, 'image/jpeg'\\);",
|
||
"repl": "fileName, 'application/octet-stream');",
|
||
"test": "prep",
|
||
"why": "上传 mime 发错"
|
||
},
|
||
{
|
||
"file": "client/harmony/entry/src/main/ets/pages/SettingsPage.ets",
|
||
"pat": " await store\\.syncFromServer\\(ctx, client\\);\n this\\.adoptSnapshot\\(store\\.current\\(\\), store\\.statusText\\(\\)\\);\n \\}\n\n /\\*\\* 把 store 里的快照复制进 @State",
|
||
"repl": " this.bgKind = 'image';\n }\n\n /** 把 store 里的快照复制进 @State",
|
||
"test": "prep",
|
||
"why": "上传成功后不重新同步"
|
||
}
|
||
]
|