test(suite): 自检 3(判据不得埋在 process.exit 之后)+ TMPDIR 固化 + API 同名不同义表
## 自检 3(pi 提议)
自检 1/2 管"文件没接线",管不到"检查写在 `process.exit()` 之后"—— 而那正是实际发生的
第 4 例(4 条玻璃判据被并发写入落到文件末尾)。成因是**结构性**的(并发写入总是往文件末尾
追加),所以它一定会再发生,而它下一次仍然不报错。静态扫一遍即可:`process.exit(` 之后
若再出现 `check(`,直接判红并指出文件。变异验证:往 `theme.test.mjs` 尾部追加一条 check → 判红。
## TMPDIR 固化(pi 建议,采纳)
"记得加 TMPDIR"这种约定活不过两次踩坑(hvigor、fpm 各一次)。所以不再靠口径:
- `npm run build:linux` 自带 `mkdir -p .tmp && TMPDIR=${TMPDIR:-$PWD/.tmp}`;
- `BUILD.md` 的 deb 一节写明这条前置与原因(`/tmp` 是 tmpfs、占内存、常年近满)。
## `docs/API.md`:`total` 不是总封数 + 同名不同义表
`GET /me/mail/inbox` 的 `total` 是**未读总数**(`repo.CountUnread`),不是本页/全部邮件数 ——
鸿蒙端曾因此写出「共 7 封」和「未读 7」两行自相矛盾的字。在人类接口开头加了醒目提示,
并新增一张表:`total`(未读数)/ `status`(邮件=unread|read,会话=active|archived)/
`status` 与 `is_read` 同义不同名。
## 验证
`npm test` 退出码 0:9 个判据文件全绿 + vitest 258/258(安装包已按判据要求重打,
AppImage 与 deb 均为最新)。
This commit is contained in:
@ -18,7 +18,7 @@
|
||||
* 在它进套件之前一直是隐身状态。加了这条,**新增判据忘了接线会直接红**。
|
||||
*/
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { existsSync, readdirSync } from 'node:fs';
|
||||
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
@ -59,6 +59,31 @@ if (ghosts.length || unwired.length) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* 自检 3:判据不得写在 `process.exit()` **之后**(pi 提议,2026-09-14)。
|
||||
*
|
||||
* 自检 1/2 管的是"文件没接线",管不到"检查写在了退出之后" —— 而那正是实际发生过的
|
||||
* 第 4 例:4 条玻璃判据被并发写入落到了文件末尾、`process.exit()` 后面,
|
||||
* 于是**一条都不执行、也不计入通过/失败**,输出看起来完全正常。
|
||||
* 这种事的成因是结构性的(并发写入总是往文件末尾追加),所以它一定会再发生,
|
||||
* 而它下一次仍然不报错 —— 静态扫一遍最省事。
|
||||
*/
|
||||
const buried = [];
|
||||
for (const [file, flags] of SUITE) {
|
||||
if (flags.includes('--test')) {
|
||||
continue; // node:test 那几条没有 process.exit,结构上不会踩这个
|
||||
}
|
||||
const src = readFileSync(join(ROOT, file), 'utf8');
|
||||
const exitAt = src.lastIndexOf('process.exit(');
|
||||
if (exitAt >= 0 && /(^|\n)\s*check\(/.test(src.slice(exitAt))) {
|
||||
buried.push(file);
|
||||
}
|
||||
}
|
||||
if (buried.length) {
|
||||
console.error(`判据写在 process.exit() 之后,永远不会跑(挪到汇总之前):${buried.join('、')}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const reds = [];
|
||||
for (const [file, flags] of SUITE) {
|
||||
console.log(`\n========== ${file} ==========`);
|
||||
|
||||
Reference in New Issue
Block a user