dsh-plugin-mesh 0.0.0-stage → 0.3.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1199 -2
- package/client/client.js +958 -0
- package/cordis.patch.yml +80 -0
- package/install.sh +142 -0
- package/lib/_rehearsal-peer.mjs +229 -0
- package/lib/_selftest-capabilities.mjs +631 -0
- package/lib/_selftest-client.mjs +249 -0
- package/lib/_selftest-discovery.mjs +51 -0
- package/lib/_selftest-newsession.mjs +124 -0
- package/lib/_selftest-prompt.mjs +97 -0
- package/lib/_selftest-tsnet-live.mjs +169 -0
- package/lib/_selftest-tsnet-tailnet.mjs +418 -0
- package/lib/_selftest-tsnet.mjs +647 -0
- package/lib/capabilities.js +786 -0
- package/lib/conversation.js +59 -0
- package/lib/discovery.js +744 -0
- package/lib/identity.js +136 -0
- package/lib/index.js +2079 -0
- package/lib/prompt.js +50 -0
- package/lib/scan.js +118 -0
- package/lib/tsnet/bridge.js +71 -0
- package/lib/tsnet/checksums.js +19 -0
- package/lib/tsnet/download.js +384 -0
- package/lib/tsnet/manager.js +655 -0
- package/package.json +118 -4
- package/scripts/__pycache__/mesh-tsnet-merge.cpython-312.pyc +0 -0
- package/scripts/_selftest-tsnet-merge.py +168 -0
- package/scripts/build-sidecar.sh +372 -0
- package/scripts/check-loadable.mjs +154 -0
- package/scripts/check-tarball.mjs +106 -0
- package/scripts/check-tdz.mjs +78 -0
- package/scripts/check-version.mjs +32 -0
- package/scripts/fix-android-tls-align.py +87 -0
- package/scripts/mesh-tsnet-merge.py +345 -0
- package/scripts/mesh-tsnet-onboarding.md +98 -0
- package/scripts/publish-assets.py +213 -0
- package/scripts/push-via-api.py +262 -0
- package/scripts/release-plugin.sh +129 -0
- package/scripts/restart-dsh.sh +308 -0
- package/scripts/submit-to-awesome.py +212 -0
- package/scripts/verify-lan-mirror.mjs +57 -0
- package/sidecar/androidbin_linux.go +39 -0
- package/sidecar/androidnet_linux.go +414 -0
- package/sidecar/androidnet_other.go +15 -0
- package/sidecar/go.mod +51 -0
- package/sidecar/go.sum +239 -0
- package/sidecar/main.go +850 -0
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 能力采集与名片携带的自测(Placement 步骤 ①)。
|
|
3
|
+
*
|
|
4
|
+
* 纯逻辑 + 一次真实采集,**不碰网络**(不发组播、不开端口)——
|
|
5
|
+
* 与 `npm run selftest` 同样的约束,跑多少次都不会污染真实网络。
|
|
6
|
+
*
|
|
7
|
+
* node lib/_selftest-capabilities.mjs
|
|
8
|
+
*/
|
|
9
|
+
import { strict as assert } from "node:assert";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import {
|
|
13
|
+
augmentedPath,
|
|
14
|
+
capabilityAge,
|
|
15
|
+
collectCapabilities,
|
|
16
|
+
collectRuntimes,
|
|
17
|
+
currentCapabilities,
|
|
18
|
+
describePeerCapabilities,
|
|
19
|
+
isCapabilityStale,
|
|
20
|
+
parseVersion,
|
|
21
|
+
parseMacGpu,
|
|
22
|
+
parseNvidiaGpu,
|
|
23
|
+
parseWindowsGpu,
|
|
24
|
+
sanitizeCapabilities,
|
|
25
|
+
setCapabilitiesForTest,
|
|
26
|
+
startCapabilities,
|
|
27
|
+
summarizeCapabilities,
|
|
28
|
+
CAPABILITY_STALE_MS,
|
|
29
|
+
// 只为自测导出:形状守卫与 Windows 目录清单的真实机器很难复现,靠注入平台来测
|
|
30
|
+
__isEmptyButFailed,
|
|
31
|
+
__pathLookupUnreliable,
|
|
32
|
+
__extraPathDirs,
|
|
33
|
+
__storeAliasDir,
|
|
34
|
+
__hasUncertainProbe,
|
|
35
|
+
__probeFailCount,
|
|
36
|
+
} from "./capabilities.js";
|
|
37
|
+
import { MeshDiscovery, APP_TAG } from "./discovery.js";
|
|
38
|
+
|
|
39
|
+
let passed = 0;
|
|
40
|
+
let failed = 0;
|
|
41
|
+
|
|
42
|
+
function test(name, fn) {
|
|
43
|
+
try {
|
|
44
|
+
fn();
|
|
45
|
+
passed += 1;
|
|
46
|
+
console.log(` ✓ ${name}`);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
failed += 1;
|
|
49
|
+
console.log(` ✗ ${name}`);
|
|
50
|
+
console.log(` ${err?.message ?? err}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function testAsync(name, fn) {
|
|
55
|
+
try {
|
|
56
|
+
await fn();
|
|
57
|
+
passed += 1;
|
|
58
|
+
console.log(` ✓ ${name}`);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
failed += 1;
|
|
61
|
+
console.log(` ✗ ${name}`);
|
|
62
|
+
console.log(` ${err?.message ?? err}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log("\n── parseVersion:只取主.次,取第一个匹配 ──");
|
|
67
|
+
|
|
68
|
+
test("node 的 v 前缀", () => assert.equal(parseVersion("v20.19.3"), "20.19"));
|
|
69
|
+
test("Python 的「Python 」前缀", () => assert.equal(parseVersion("Python 3.12.1"), "3.12"));
|
|
70
|
+
test("go 的复合输出不会取到架构数字", () => assert.equal(parseVersion("go version go1.25.1 darwin/amd64"), "1.25"));
|
|
71
|
+
test("docker 的逗号尾巴", () => assert.equal(parseVersion("Docker version 28.0.1, build 068a01e"), "28.0"));
|
|
72
|
+
test("java 的引号包裹", () => assert.equal(parseVersion('openjdk version "17.0.9" 2023-10-17'), "17.0"));
|
|
73
|
+
test("只有主版本号", () => assert.equal(parseVersion("ffmpeg version 6"), "6"));
|
|
74
|
+
test("没有数字 → 空串", () => assert.equal(parseVersion("command not found"), ""));
|
|
75
|
+
test("空输入 → 空串", () => assert.equal(parseVersion(""), ""));
|
|
76
|
+
test("null → 空串(不抛)", () => assert.equal(parseVersion(null), ""));
|
|
77
|
+
|
|
78
|
+
console.log("\n── GPU 解析:这组测试是为了一个真实踩过的回归 ──");
|
|
79
|
+
|
|
80
|
+
test("parseMacGpu 能从 system_profiler 真实输出里抠出型号与显存", () => {
|
|
81
|
+
const fixture = [
|
|
82
|
+
"Graphics/Displays:",
|
|
83
|
+
" Intel Iris Graphics 6100:",
|
|
84
|
+
" Chipset Model: Intel Iris Graphics 6100",
|
|
85
|
+
" Type: GPU",
|
|
86
|
+
" VRAM (Dynamic, Max): 1536 MB",
|
|
87
|
+
" Vendor: Intel",
|
|
88
|
+
].join("\n");
|
|
89
|
+
const g = parseMacGpu(fixture);
|
|
90
|
+
assert.equal(g.name, "Intel Iris Graphics 6100");
|
|
91
|
+
assert.equal(g.vramMb, 1536);
|
|
92
|
+
assert.equal(g.present, true);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("parseNvidiaGpu 解析 CSV", () => {
|
|
96
|
+
const g = parseNvidiaGpu("NVIDIA GeForce RTX 4090, 24564");
|
|
97
|
+
assert.equal(g.name, "NVIDIA GeForce RTX 4090");
|
|
98
|
+
assert.equal(g.vramMb, 24564);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("parseWindowsGpu 取第一行(多显卡时)", () => {
|
|
102
|
+
const g = parseWindowsGpu("Intel(R) UHD Graphics\r\nNVIDIA GeForce MX150");
|
|
103
|
+
assert.equal(g.name, "Intel(R) UHD Graphics");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("传入非字符串(对象)→ 返回 null「未知」,不是「确定没有」也不是乱码", () => {
|
|
107
|
+
// ⚠️ 这就是真实踩到的回归:runProbe 的返回值从 string 改成 {output,error}
|
|
108
|
+
// 之后 collectGpu 漏改,把**对象**交给了解析函数。旧实现里 String(对象) 变成
|
|
109
|
+
// "[object Object]":Mac 上被报成 present:false("确定没有 GPU"),
|
|
110
|
+
// Android 上报出型号 "[object Object]"。
|
|
111
|
+
// 正确行为:我们自己的 bug 只能降级成"未知",绝不能伪装成对端的事实。
|
|
112
|
+
for (const fn of [parseMacGpu, parseNvidiaGpu, parseWindowsGpu]) {
|
|
113
|
+
for (const junk of [{ output: "x", error: "" }, null, undefined, 42, ["a"]]) {
|
|
114
|
+
assert.equal(fn(junk), null, `${fn.name}(${JSON.stringify(junk)}) 应为 null`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("解析不出型号 → null「未知」,不是 {present:false}「确定没有」", () => {
|
|
120
|
+
// 契约:解析函数只报"认出来的卡"。认不出来 = 我们没得出结论 = null。
|
|
121
|
+
// 报 {present:false,name:""} 有两个代价:① headless Mac / VM 的
|
|
122
|
+
// system_profiler 输出(只有 Display 段、无 Chipset Model)会被当成"确定没 GPU";
|
|
123
|
+
// ② 接收侧 sanitizeCapabilities 见 name 为空会把整块 gpu 折成 null,
|
|
124
|
+
// 于是"确定没有"被悄悄提升成"未知"——语义在中途被改写。
|
|
125
|
+
assert.equal(parseMacGpu(""), null);
|
|
126
|
+
assert.equal(parseNvidiaGpu(""), null);
|
|
127
|
+
assert.equal(
|
|
128
|
+
parseMacGpu("Graphics/Displays:\n\n Displays:\n DELL U2720Q:\n Resolution: 3840 x 2160\n"),
|
|
129
|
+
null,
|
|
130
|
+
"有输出但没有 Chipset Model 行 → 没解析出型号 → null",
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("解析出型号 → present:true(契约里的那个真值)", () => {
|
|
135
|
+
assert.equal(parseMacGpu(" Chipset Model: Intel Iris Graphics 6100\n VRAM (Dynamic, Max): 1536 MB\n").present, true);
|
|
136
|
+
assert.equal(parseNvidiaGpu("NVIDIA GeForce RTX 4090, 24564").present, true);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("nvidia 支路:**报错文本不许变成显卡型号**(对端指出的反向口子)", () => {
|
|
140
|
+
// runProbe 把 stdout 与 stderr 合并成 output,所以 nvidia-smi 把错误打到 stdout
|
|
141
|
+
// (或 shim 吐一行提示)时,那行文字会被当成"真实型号"报给 Placement,
|
|
142
|
+
// 而 sanitizeCapabilities 不拦它(名字非空即保留)。
|
|
143
|
+
for (const junk of [
|
|
144
|
+
"no gpu here",
|
|
145
|
+
"ERROR: nvidia-smi not found",
|
|
146
|
+
"command not found",
|
|
147
|
+
"nvidia-smi: command not found",
|
|
148
|
+
]) {
|
|
149
|
+
assert.equal(parseNvidiaGpu(junk), null, `${JSON.stringify(junk)} 不是 CSV 数据行,应为 null`);
|
|
150
|
+
}
|
|
151
|
+
// 正常形状仍然要能解析(回归)
|
|
152
|
+
assert.deepEqual(parseNvidiaGpu("Tesla T4, 15360"), { present: true, name: "Tesla T4", vramMb: 15360 });
|
|
153
|
+
// 有逗号但第二段不是数 → 更像提示文本
|
|
154
|
+
assert.equal(parseNvidiaGpu("foobar, not-a-number"), null);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("骗过 sanitize 的假型号:确认净化层确实不拦(所以必须上游收口)", () => {
|
|
158
|
+
const seen = sanitizeCapabilities({ gpu: { present: true, name: "ERROR: nvidia-smi failed", vramMb: 0 } });
|
|
159
|
+
assert.equal(seen.gpu.name, "ERROR: nvidia-smi failed", "净化层只看名字非空 → 上游不挡就会一路报出去");
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
await testAsync("真实采集:本机必须拿到一个像样的 GPU 名字(回归守卫)", async () => {
|
|
163
|
+
const caps = await collectCapabilities();
|
|
164
|
+
if (process.platform !== "darwin" && process.platform !== "win32") {
|
|
165
|
+
console.log(" 跳过断言(本平台不一定有 GPU)");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
assert.ok(caps.gpu, `darwin/win32 上应能探到 GPU,实际 ${JSON.stringify(caps.gpu)}`);
|
|
169
|
+
assert.ok(caps.gpu.name, "GPU 名字不该为空");
|
|
170
|
+
assert.ok(
|
|
171
|
+
!caps.gpu.name.includes("[object"),
|
|
172
|
+
`GPU 名字被序列化成了对象:${caps.gpu.name} —— 多半是把 runProbe 的 {output} 整个传给了解析函数`,
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
console.log("\n── sanitizeCapabilities:来自网络的数据不能直接信 ──");
|
|
177
|
+
|
|
178
|
+
test("null / undefined / 字符串 / 数组 一律 → null(表示「未知」)", () => {
|
|
179
|
+
assert.equal(sanitizeCapabilities(null), null);
|
|
180
|
+
assert.equal(sanitizeCapabilities(undefined), null);
|
|
181
|
+
assert.equal(sanitizeCapabilities("python3.11"), null);
|
|
182
|
+
assert.equal(sanitizeCapabilities([{ runtimes: {} }]), null);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("正常名片被保留", () => {
|
|
186
|
+
const c = sanitizeCapabilities({
|
|
187
|
+
os: "darwin 21.6.0",
|
|
188
|
+
arch: "x64",
|
|
189
|
+
cpuCores: 4,
|
|
190
|
+
memMb: 8192,
|
|
191
|
+
runtimes: { python: "3.12", node: "20.19" },
|
|
192
|
+
gpu: { present: true, name: "Intel Iris", vramMb: 1536 },
|
|
193
|
+
workspaceHints: ["~/projects"],
|
|
194
|
+
capabilitiesAt: 1792000000000,
|
|
195
|
+
});
|
|
196
|
+
assert.equal(c.cpuCores, 4);
|
|
197
|
+
assert.equal(c.memMb, 8192);
|
|
198
|
+
assert.equal(c.runtimes.python, "3.12");
|
|
199
|
+
assert.equal(c.gpu.name, "Intel Iris");
|
|
200
|
+
assert.equal(c.gpu.vramMb, 1536);
|
|
201
|
+
assert.deepEqual(c.workspaceHints, ["~/projects"]);
|
|
202
|
+
assert.equal(c.capabilitiesAt, 1792000000000);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test("版本号里的非数字点字符被剥掉(防注入可执行内容)", () => {
|
|
206
|
+
const c = sanitizeCapabilities({ runtimes: { python: "3.11; rm -rf / --no-preserve-root" } });
|
|
207
|
+
assert.equal(c.runtimes.python, "3.11");
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test("控制字符被剥掉", () => {
|
|
211
|
+
const c = sanitizeCapabilities({ os: "linux\u0000\u001b[31m 6.1", runtimes: {} });
|
|
212
|
+
assert.ok(!c.os.includes("\u0000"), "os 里不该有 NUL");
|
|
213
|
+
assert.ok(!c.os.includes("\u001b"), "os 里不该有 ESC");
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test("超长字符串被截断", () => {
|
|
217
|
+
const c = sanitizeCapabilities({ runtimes: { ["x".repeat(200)]: "1.0" }, os: "y".repeat(500) });
|
|
218
|
+
assert.ok(Object.keys(c.runtimes).every((k) => k.length <= 24), "运行时名应限长 24");
|
|
219
|
+
assert.ok(c.os.length <= 60, `os 应限长 60,实际 ${c.os.length}`);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test("运行时数量封顶 24", () => {
|
|
223
|
+
const many = {};
|
|
224
|
+
for (let i = 0; i < 200; i += 1) many[`rt${i}`] = "1.0";
|
|
225
|
+
assert.equal(Object.keys(sanitizeCapabilities({ runtimes: many }).runtimes).length, 24);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test("workspaceHints 封顶 8 条", () => {
|
|
229
|
+
const hints = Array.from({ length: 50 }, (_, i) => `/p${i}`);
|
|
230
|
+
assert.equal(sanitizeCapabilities({ runtimes: {}, workspaceHints: hints }).workspaceHints.length, 8);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test("负数 / NaN / Infinity 的数值字段归 0,不会变成 NaN 传下去", () => {
|
|
234
|
+
const c = sanitizeCapabilities({ cpuCores: -5, memMb: Number.NaN, runtimes: {} });
|
|
235
|
+
assert.equal(c.cpuCores, 0);
|
|
236
|
+
assert.equal(c.memMb, 0);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test("缺 capabilitiesAt → 0(而不是当前时间)", () => {
|
|
240
|
+
assert.equal(sanitizeCapabilities({ runtimes: {} }).capabilitiesAt, 0);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
test("没有名字的 gpu → null(不是 {present:false})", () => {
|
|
244
|
+
assert.equal(sanitizeCapabilities({ runtimes: {}, gpu: { present: true, name: "" } }).gpu, null);
|
|
245
|
+
assert.equal(sanitizeCapabilities({ runtimes: {}, gpu: "nvidia" }).gpu, null);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
console.log("\n── 过期判定:null ≠ 过期,这是最容易写错的地方 ──");
|
|
249
|
+
|
|
250
|
+
test("没报能力(null)不算过期 —— 它是「未知」", () => {
|
|
251
|
+
assert.equal(isCapabilityStale(null), false);
|
|
252
|
+
assert.equal(capabilityAge(null), Number.POSITIVE_INFINITY);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test("刚采的不过期,远超阈值的过期", () => {
|
|
256
|
+
const now = 1792000000000;
|
|
257
|
+
assert.equal(isCapabilityStale({ capabilitiesAt: now }, now), false);
|
|
258
|
+
assert.equal(isCapabilityStale({ capabilitiesAt: now - CAPABILITY_STALE_MS + 1000 }, now), false);
|
|
259
|
+
assert.equal(isCapabilityStale({ capabilitiesAt: now - CAPABILITY_STALE_MS - 1000 }, now), true);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test("capabilitiesAt=0(对端没给时间戳)算过期,不算「刚采的」", () => {
|
|
263
|
+
assert.equal(isCapabilityStale({ capabilitiesAt: 0 }, 1792000000000), true);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
console.log("\n── summarizeCapabilities ──");
|
|
267
|
+
|
|
268
|
+
test("null → 空串", () => assert.equal(summarizeCapabilities(null), ""));
|
|
269
|
+
test("无运行时 → 空串", () => assert.equal(summarizeCapabilities({ runtimes: {} }), ""));
|
|
270
|
+
test("带 GPU 时追加 gpu: 段", () => {
|
|
271
|
+
const s = summarizeCapabilities({ runtimes: { python: "3.12" }, gpu: { name: "Intel Iris" } });
|
|
272
|
+
assert.ok(s.includes("python3.12"), s);
|
|
273
|
+
assert.ok(s.includes("gpu:Intel Iris"), s);
|
|
274
|
+
});
|
|
275
|
+
test("按 max 截断", () => {
|
|
276
|
+
const rt = {};
|
|
277
|
+
for (let i = 0; i < 20; i += 1) rt[`rt${i}`] = "1.0";
|
|
278
|
+
assert.equal(summarizeCapabilities({ runtimes: rt }, { max: 3 }).split(" · ").length, 3);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
console.log("\n── augmentedPath:只许加,绝不许减 ──");
|
|
282
|
+
|
|
283
|
+
test("原 PATH 的每一项都还在(补全不能把已有路径挤掉)", () => {
|
|
284
|
+
const before = String(process.env.PATH ?? "").split(":").filter(Boolean);
|
|
285
|
+
const after = new Set(augmentedPath().split(":").filter(Boolean));
|
|
286
|
+
for (const d of before) assert.ok(after.has(d), `补全后丢了 ${d}`);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test("没有重复项", () => {
|
|
290
|
+
const parts = augmentedPath().split(":").filter(Boolean);
|
|
291
|
+
assert.equal(new Set(parts).size, parts.length, "PATH 里不该有重复目录");
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
console.log("\n── Windows 上的 PATH 补全(真机是 darwin,靠注入平台验)──");
|
|
295
|
+
|
|
296
|
+
test("win32 用分号分隔,不能写成冒号", () => {
|
|
297
|
+
// 写死冒号会让整个 Windows PATH 变成"一个目录名",比不补还糟。
|
|
298
|
+
const raw = "C:\\Windows;C:\\Windows\\system32";
|
|
299
|
+
const out = augmentedPath(raw, "win32");
|
|
300
|
+
assert.ok(out.includes(raw), `原 PATH 必须原样保留,实际 ${out}`);
|
|
301
|
+
assert.ok(!out.split(";")[0].includes("C:\\Windows:C:"), "不该用冒号把 Windows 路径连起来");
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
test("POSIX 仍用冒号(回归)", () => {
|
|
305
|
+
const out = augmentedPath("/usr/bin:/bin", "darwin");
|
|
306
|
+
assert.ok(out.includes("/usr/bin"), `原 PATH 必须保留,实际 ${out}`);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
console.log("\n── 形状守卫:一个都没探到 ≠ 确定没装 ──");
|
|
310
|
+
|
|
311
|
+
test("空 runtimes + 有失败项 → 判为「未探准」(win32 实测形状)", () => {
|
|
312
|
+
// 这是文超-win 报回来的真实形状:runtimes={} 且 runtimesIncomplete=false,
|
|
313
|
+
// 等于宣称"确定没装任何运行时",而它自己就跑在 Node 上。
|
|
314
|
+
assert.equal(__isEmptyButFailed({ runtimes: {}, errors: { node: "ENOENT", git: "ENOENT" } }), true);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
test("真的一尘不染(空 runtimes 且无失败项)→ 不算未探准", () => {
|
|
318
|
+
assert.equal(__isEmptyButFailed({ runtimes: {}, errors: {} }), false);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
test("探到过东西 → ENOENT 仍可信,不触发守卫", () => {
|
|
322
|
+
assert.equal(__isEmptyButFailed({ runtimes: { node: "20.19" }, errors: { rustc: "ENOENT" } }), false);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
console.log("\n── 补全生效判据:兜底没做成时,ENOENT 不许当结论 ──");
|
|
326
|
+
|
|
327
|
+
test("本机 darwin:extraPathDirs 能真的加进目录 → 判可靠(rustc/adb 确实没装)", () => {
|
|
328
|
+
// 这一格是对端 hos 那个"any error → incomplete"方案的**反例**:
|
|
329
|
+
// 我这台 runtimes 非空、2 项 ENOENT,但两个都**真的没装**,
|
|
330
|
+
// 若按"有失败就 incomplete"会误报。
|
|
331
|
+
//
|
|
332
|
+
// ⚠️ 只在 darwin 上断言:原先写死 "darwin",在 Windows 上 darwin 那套
|
|
333
|
+
// /opt/homebrew、/usr/local、~/.cargo 一个都不存在 → 判据(正确地)返回 true
|
|
334
|
+
// → 假红(对端 文超-win 实测 62 通过 / 2 失败)。判据本身是**自校验式**的,
|
|
335
|
+
// 错的是断言把"开发机是 Mac"当成了不变量。平台中立的不变式由下一条用例覆盖。
|
|
336
|
+
if (process.platform !== "darwin") return;
|
|
337
|
+
assert.equal(__pathLookupUnreliable("darwin"), false, "本机补全生效,找不到即为真没装");
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
test("自校验式判据:问的是「我们自己的兜底有没有起作用」,不是硬编码根", () => {
|
|
341
|
+
// 对端实测过:它的 runtimes 住在 /data/data/com.dsharnessmobile.shell/files/usr/bin,
|
|
342
|
+
// **不在任何常见白名单里**。硬编码白名单会因此假阳性判残缺;
|
|
343
|
+
// 而 extraPathDirs() 是否真的加进目录与平台布局无关,是自校验的。
|
|
344
|
+
//
|
|
345
|
+
// ⚠️ 判据里**不能注入平台来伪造另一台机器的文件系统**:extraPathDirs('win32')
|
|
346
|
+
// 在 Mac 上只反映"Mac 上有没有 C:\ 那些目录"。所以这里只断言机制本身
|
|
347
|
+
// (返回布尔 + 与 extraPathDirs 是否为空一致),不假装能在 Mac 上模拟 Android。
|
|
348
|
+
assert.equal(typeof __pathLookupUnreliable(process.platform), "boolean");
|
|
349
|
+
assert.equal(
|
|
350
|
+
__pathLookupUnreliable(process.platform),
|
|
351
|
+
__extraPathDirs(process.platform).filter((d) => !__storeAliasDir.test(d)).length === 0,
|
|
352
|
+
"判据必须精确等价于「补全一个目录都没加进去」(Store 别名目录除外)",
|
|
353
|
+
);
|
|
354
|
+
// 本机 darwin 上 win32 那套 %ProgramFiles% 路径确实都不存在 → 判不可靠(可证)。
|
|
355
|
+
assert.equal(__pathLookupUnreliable("win32"), true);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
test("Store 别名目录(WindowsApps)不算「补全真的生效」的证据", () => {
|
|
359
|
+
// 对端 文超-win 实测:该目录里 18 个 .exe **全部**是 0 字节 + ReparsePoint 的
|
|
360
|
+
// Store 别名存根(python.exe / winget.exe / …),spawn 得 exit=9009、空输出;
|
|
361
|
+
// 而它几乎存在于每台 Win10/11 上。文超-win 的 win32 候选表**去掉它恰好为 0、
|
|
362
|
+
// 带上它为 1** —— 不排除,本判据在 Windows 上就恒判"可信",假阴性原样复发。
|
|
363
|
+
//
|
|
364
|
+
// 为什么直接测规则而不用端到端:Mac 上根本没有 WindowsApps 目录,
|
|
365
|
+
// `__pathLookupUnreliable("win32")` 无论对错都返回 true —— 端到端用例在开发机
|
|
366
|
+
// 上**永远是绿的**,抓不到这个 bug。
|
|
367
|
+
assert.ok(__storeAliasDir.test(String.raw`C:\Users\86189\AppData\Local\Microsoft\WindowsApps`));
|
|
368
|
+
assert.ok(__storeAliasDir.test("C:/Users/x/AppData/Local/Microsoft/WindowsApps"));
|
|
369
|
+
assert.ok(!__storeAliasDir.test(String.raw`C:\Program Files\nodejs`));
|
|
370
|
+
assert.ok(!__storeAliasDir.test(String.raw`C:\tools\WindowsApps\extra`), "只排除该目录本身,不误伤子目录");
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
test("对端 Android:6 项 ENOENT 确实都没装(它自查 command -v 确认)", () => {
|
|
374
|
+
// 对端跑过 command -v:go/docker/rustc/java/ffmpeg/adb **全部 absent**,
|
|
375
|
+
// 所以它那台**没有缺陷**。这条用例记的是"它曾经被误判成活反例"这件事:
|
|
376
|
+
// isEmptyButFailed 要求 runtimes 为空 → 它非空 → 不触发,而那**是对的**。
|
|
377
|
+
const theirs = {
|
|
378
|
+
runtimes: { node: "24.18", python: "3.14", git: "2.56" },
|
|
379
|
+
errors: { go: "ENOENT", docker: "ENOENT", rustc: "ENOENT", java: "ENOENT", ffmpeg: "ENOENT", adb: "ENOENT" },
|
|
380
|
+
};
|
|
381
|
+
assert.equal(__isEmptyButFailed(theirs), false, "它 runtimes 非空 → 形状守卫不触发(正确)");
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
await testAsync("真实机器上:runtimesIncomplete 必须与三项判据一致(不能硬编码 false)", async () => {
|
|
385
|
+
const caps = await collectCapabilities();
|
|
386
|
+
for (const [name, err] of Object.entries(caps.probeErrors ?? {})) {
|
|
387
|
+
assert.ok(!String(err).startsWith("throw:"), `${name} 探测抛异常了:${err}`);
|
|
388
|
+
}
|
|
389
|
+
// 原先这里断言恒 false("安静环境下不该有不确定项")。这条在 Windows 上假红:
|
|
390
|
+
// **PATH 兜底没生效本身就是不确定项** —— 对端 文超-win 实测 runtimes={} + 9 项
|
|
391
|
+
// ENOENT → isEmptyButFailed 为 true → runtimesIncomplete=true 是**正确**结论
|
|
392
|
+
// (它的名片不该断言"确定什么都没装")。所以按判据反推期望值,而不是写死。
|
|
393
|
+
const expected =
|
|
394
|
+
__hasUncertainProbe(caps.probeErrors) ||
|
|
395
|
+
__isEmptyButFailed({ runtimes: caps.runtimes, errors: caps.probeErrors }) ||
|
|
396
|
+
__pathLookupUnreliable(process.platform);
|
|
397
|
+
assert.equal(
|
|
398
|
+
caps.runtimesIncomplete,
|
|
399
|
+
expected,
|
|
400
|
+
`runtimesIncomplete 与判据不一致:${JSON.stringify(caps.probeErrors)}`,
|
|
401
|
+
);
|
|
402
|
+
console.log(` 未采到:${JSON.stringify(caps.probeErrors)}(runtimesIncomplete=${caps.runtimesIncomplete})`);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
console.log("\n── 名片携带与向后兼容(MeshDiscovery)──");
|
|
406
|
+
|
|
407
|
+
/** 造一个不发组播的 discovery,只用来测 upsert/project。 */
|
|
408
|
+
function makeDiscovery({ ttlMs = 60_000 } = {}) {
|
|
409
|
+
return new MeshDiscovery({
|
|
410
|
+
id: "selftest-self",
|
|
411
|
+
port: 45900,
|
|
412
|
+
meta: { machine: "selftest-self", user: "tester", profile: "selftest", version: "0.1.0" },
|
|
413
|
+
intervalMs: 60_000,
|
|
414
|
+
ttlMs,
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
test("selfRecord 带 capabilities 字段(首轮采集前是 null)", () => {
|
|
419
|
+
setCapabilitiesForTest(null);
|
|
420
|
+
const d = makeDiscovery();
|
|
421
|
+
const rec = d.selfRecord();
|
|
422
|
+
assert.ok("capabilities" in rec, "名片里必须有 capabilities 键");
|
|
423
|
+
assert.equal(rec.capabilities, null);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
test("采集完成后 selfRecord 自动带上真实能力(不依赖任何 setMeta 调用)", () => {
|
|
427
|
+
const fake = { runtimes: { python: "3.12" }, capabilitiesAt: Date.now(), cpuCores: 4, memMb: 8192 };
|
|
428
|
+
setCapabilitiesForTest(fake);
|
|
429
|
+
const d = makeDiscovery();
|
|
430
|
+
// 这里刻意**不做任何额外调用** —— 自测的就是"能力只有一个数据源、
|
|
431
|
+
// 不会因为忘了推 meta 而静默为空"
|
|
432
|
+
assert.deepEqual(d.selfRecord().capabilities, fake);
|
|
433
|
+
assert.deepEqual(d.selfRecord({ forMulticast: true }).capabilities, fake);
|
|
434
|
+
setCapabilitiesForTest(null);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
test("能力刷新后名片立刻跟着变(无需重启、无需重新 start)", () => {
|
|
438
|
+
const d = makeDiscovery();
|
|
439
|
+
setCapabilitiesForTest({ runtimes: { python: "3.10" }, capabilitiesAt: 1, cpuCores: 2, memMb: 4096 });
|
|
440
|
+
assert.equal(d.selfRecord().capabilities.runtimes.python, "3.10");
|
|
441
|
+
setCapabilitiesForTest({ runtimes: { python: "3.13" }, capabilitiesAt: 2, cpuCores: 2, memMb: 4096 });
|
|
442
|
+
assert.equal(d.selfRecord().capabilities.runtimes.python, "3.13", "刷新后名片必须跟着变");
|
|
443
|
+
setCapabilitiesForTest(null);
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
test("旧版本对端(名片里没有 capabilities)不报错,且被标成「未知」而不是「什么都没装」", () => {
|
|
447
|
+
const d = makeDiscovery();
|
|
448
|
+
d.note({ v: 1, app: APP_TAG, id: "old-peer", machine: "old", host: "10.0.0.9", port: 45917, ts: Date.now() }, "10.0.0.9");
|
|
449
|
+
const p = d.get("old-peer");
|
|
450
|
+
assert.ok(p, "对端应被登记");
|
|
451
|
+
assert.equal(p.capabilities, null, "旧对端的能力应是 null(未知)");
|
|
452
|
+
assert.equal(p.capabilitiesStale, false, "null 不是「过期」");
|
|
453
|
+
assert.equal(p.capabilitySummary, "", "没有能力时摘要为空");
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
test("新对端的能力被净化后存入,并给出摘要", () => {
|
|
457
|
+
const d = makeDiscovery();
|
|
458
|
+
d.note(
|
|
459
|
+
{
|
|
460
|
+
app: APP_TAG,
|
|
461
|
+
id: "new-peer",
|
|
462
|
+
machine: "new",
|
|
463
|
+
host: "10.0.0.10",
|
|
464
|
+
port: 45917,
|
|
465
|
+
ts: Date.now(),
|
|
466
|
+
capabilities: {
|
|
467
|
+
cpuCores: 8,
|
|
468
|
+
memMb: 16384,
|
|
469
|
+
runtimes: { python: "3.11", docker: "24.0" },
|
|
470
|
+
capabilitiesAt: Date.now(),
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
"10.0.0.10",
|
|
474
|
+
);
|
|
475
|
+
const p = d.get("new-peer");
|
|
476
|
+
assert.equal(p.capabilities.cpuCores, 8);
|
|
477
|
+
assert.equal(p.capabilities.runtimes.python, "3.11");
|
|
478
|
+
assert.ok(p.capabilitySummary.includes("python3.11"), p.capabilitySummary);
|
|
479
|
+
assert.equal(p.capabilitiesStale, false);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
test("晚到的旧能力包不会覆盖较新的(两条通道各送一份时会发生)", () => {
|
|
483
|
+
const d = makeDiscovery();
|
|
484
|
+
const now = Date.now();
|
|
485
|
+
d.note(
|
|
486
|
+
{
|
|
487
|
+
app: APP_TAG, id: "p", machine: "p", host: "10.0.0.11", port: 45917, ts: now,
|
|
488
|
+
capabilities: { cpuCores: 8, memMb: 16384, runtimes: { python: "3.12" }, capabilitiesAt: now },
|
|
489
|
+
},
|
|
490
|
+
"10.0.0.11",
|
|
491
|
+
);
|
|
492
|
+
// 更旧的一份从另一条通道姗姗来迟
|
|
493
|
+
d.note(
|
|
494
|
+
{
|
|
495
|
+
app: APP_TAG, id: "p", machine: "p", host: "10.0.0.11", port: 45917, ts: now - 60_000,
|
|
496
|
+
capabilities: { cpuCores: 2, memMb: 2048, runtimes: { python: "3.6" }, capabilitiesAt: now - 60_000 },
|
|
497
|
+
},
|
|
498
|
+
"10.0.0.11",
|
|
499
|
+
{ transport: "tsnet" },
|
|
500
|
+
);
|
|
501
|
+
const p = d.get("p");
|
|
502
|
+
assert.equal(p.capabilities.cpuCores, 8, "较新的能力不该被旧包顶掉");
|
|
503
|
+
assert.equal(p.capabilities.runtimes.python, "3.12");
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
test("对端名片里的 capabilities 是垃圾时降级成「未知」而不是崩溃", () => {
|
|
507
|
+
const d = makeDiscovery();
|
|
508
|
+
// 每一条用**不同的 id 和 host**:同一 host:port 会被去重合并(那是既有行为,
|
|
509
|
+
// 用来处理"对端重启后旧记录还在"的重名),这里要分别观察每一条的降级结果。
|
|
510
|
+
const junkValues = [null, "python", 42, [], { runtimes: "nope" }, { runtimes: { python: 3.11 } }];
|
|
511
|
+
junkValues.forEach((junk, i) => {
|
|
512
|
+
d.note(
|
|
513
|
+
{
|
|
514
|
+
app: APP_TAG,
|
|
515
|
+
id: `junk-${i}`,
|
|
516
|
+
machine: `j${i}`,
|
|
517
|
+
host: `10.0.1.${i + 1}`,
|
|
518
|
+
port: 45917,
|
|
519
|
+
ts: Date.now(),
|
|
520
|
+
capabilities: junk,
|
|
521
|
+
},
|
|
522
|
+
`10.0.1.${i + 1}`,
|
|
523
|
+
);
|
|
524
|
+
const p = d.get(`junk-${i}`);
|
|
525
|
+
assert.ok(p, `junk-${i} 应被登记`);
|
|
526
|
+
if (junk === null || typeof junk === "string" || typeof junk === "number" || Array.isArray(junk)) {
|
|
527
|
+
assert.equal(p.capabilities, null, `${JSON.stringify(junk)} 应降级成 null(未知)`);
|
|
528
|
+
} else {
|
|
529
|
+
// 对象形状不对时也不该抛;能救回的字段就救
|
|
530
|
+
assert.ok(p.capabilities === null || typeof p.capabilities === "object");
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
test("数字型版本号不会被当成版本(版本必须是字符串才收)", () => {
|
|
536
|
+
// 存进来的是字符串化的版本;`{python: 3.11}` 这种形状对端不会这么发,
|
|
537
|
+
// 但收到了也不能崩、更不能把 3.11 当成真版本报出去
|
|
538
|
+
const c = sanitizeCapabilities({ runtimes: { python: 3.11 } });
|
|
539
|
+
assert.ok(c !== null, "整体仍应是有效对象");
|
|
540
|
+
assert.equal(c.runtimes.python, "3.11", "数字也会被安全地字符串化");
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
test("自己发出去的名片不含本机能力时也不崩(第一次心跳早于采集完成)", () => {
|
|
544
|
+
setCapabilitiesForTest(null);
|
|
545
|
+
const d = makeDiscovery();
|
|
546
|
+
const rec = d.selfRecord({ forMulticast: true });
|
|
547
|
+
assert.equal(rec.capabilities, null);
|
|
548
|
+
assert.ok(!("mac" in rec), "组播名片仍不该带 mac");
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
console.log("\n── describePeerCapabilities:三种「不知道」必须说清楚 ──");
|
|
552
|
+
|
|
553
|
+
test("对端没报能力 → 明说「未知」,不能渲染成「什么都没装」", () => {
|
|
554
|
+
const s = describePeerCapabilities({ capabilities: null, capabilitiesStale: false });
|
|
555
|
+
assert.ok(s.includes("未知"), s);
|
|
556
|
+
assert.ok(!s.includes("未探到任何运行时"), "不能把未知说成没有");
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
test("对端报了能力 → 列出规格与运行时", () => {
|
|
560
|
+
const s = describePeerCapabilities({
|
|
561
|
+
capabilities: { cpuCores: 8, memMb: 16384, arch: "arm64", runtimes: { python: "3.11" }, capabilitiesAt: 1792000000000 },
|
|
562
|
+
capabilitiesStale: false,
|
|
563
|
+
});
|
|
564
|
+
assert.ok(s.includes("8 核"), s);
|
|
565
|
+
assert.ok(s.includes("16 GB 内存"), s);
|
|
566
|
+
assert.ok(s.includes("python3.11"), s);
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
test("过期 → 标出来", () => {
|
|
570
|
+
const s = describePeerCapabilities({
|
|
571
|
+
capabilities: { runtimes: { python: "3.11" }, capabilitiesAt: 1 },
|
|
572
|
+
capabilitiesStale: true,
|
|
573
|
+
});
|
|
574
|
+
assert.ok(s.includes("已过期"), s);
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
test("探测没探准 → 标出来,并说明不能据此断定「没有」", () => {
|
|
578
|
+
const s = describePeerCapabilities({
|
|
579
|
+
capabilities: { runtimes: {}, runtimesIncomplete: true, capabilitiesAt: 1792000000000 },
|
|
580
|
+
capabilitiesStale: false,
|
|
581
|
+
});
|
|
582
|
+
assert.ok(s.includes("没探准"), s);
|
|
583
|
+
assert.ok(s.includes("不能据此断定"), s);
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
console.log("\n── 指纹认领的边界:同机多实例不该互相顶掉 ──");
|
|
587
|
+
|
|
588
|
+
test("同指纹 + 同名(重装场景)→ 认领,旧记录被顶掉", () => {
|
|
589
|
+
const d = makeDiscovery();
|
|
590
|
+
const now = Date.now();
|
|
591
|
+
// 旧记录:同指纹、同名,且已经离线(重启残留)
|
|
592
|
+
d.note({ app: APP_TAG, id: "old-id", machine: "box", host: "10.0.0.5", port: 45917, ts: now - 60_000, fingerprint: "FP" }, "10.0.0.5");
|
|
593
|
+
assert.equal(d.peers().length, 1);
|
|
594
|
+
// 新记录:同指纹、同名、不同 id
|
|
595
|
+
d.note({ app: APP_TAG, id: "new-id", machine: "box", host: "10.0.0.5", port: 45918, ts: now, fingerprint: "FP" }, "10.0.0.5");
|
|
596
|
+
const ids = d.peers().map((p) => p.id);
|
|
597
|
+
assert.deepEqual(ids, ["new-id"], `旧记录应被认领掉,实际 ${JSON.stringify(ids)}`);
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
test("同指纹 + **不同名** + 两台都在线 → 各自保留(同机两个 profile)", () => {
|
|
601
|
+
const d = makeDiscovery();
|
|
602
|
+
const now = Date.now();
|
|
603
|
+
d.note({ app: APP_TAG, id: "prod", machine: "lipeng-mac", host: "10.0.0.5", port: 45917, ts: now, fingerprint: "FP" }, "10.0.0.5");
|
|
604
|
+
d.note({ app: APP_TAG, id: "dev", machine: "meshdev", host: "10.0.0.5", port: 45918, ts: now, fingerprint: "FP" }, "10.0.0.5");
|
|
605
|
+
const ids = d.peers().map((p) => p.id).sort();
|
|
606
|
+
assert.deepEqual(ids, ["dev", "prod"], "两台都活着且名字不同 → 不该互相顶掉");
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
await testAsync("同指纹 + 不同名 + 旧记录已离线 → 仍认领(丢了自定义机器名的重装)", async () => {
|
|
610
|
+
// 用极短 TTL 让"旧记录已离线"真实发生(endpoint 的 lastSeen 是 note() 那一刻
|
|
611
|
+
// 写的,没法用假时间戳伪造)。sweep 有 2s 下限,所以这 150ms 内记录不会被清掉。
|
|
612
|
+
const d = makeDiscovery({ ttlMs: 50 });
|
|
613
|
+
const now = Date.now();
|
|
614
|
+
d.note({ app: APP_TAG, id: "old", machine: "oldname", host: "10.0.0.5", port: 45917, ts: now, fingerprint: "FP" }, "10.0.0.5");
|
|
615
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
616
|
+
assert.equal(d.get("old").online, false, "旧记录应已离线");
|
|
617
|
+
d.note({ app: APP_TAG, id: "new", machine: "newname", host: "10.0.0.5", port: 45918, ts: Date.now(), fingerprint: "FP" }, "10.0.0.5");
|
|
618
|
+
const ids = d.peers().map((p) => p.id);
|
|
619
|
+
assert.deepEqual(ids, ["new"], `离线的旧记录应被认领,实际 ${JSON.stringify(ids)}`);
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
test("指纹不同 → 绝不认领(不同物理机)", () => {
|
|
623
|
+
const d = makeDiscovery();
|
|
624
|
+
const now = Date.now();
|
|
625
|
+
d.note({ app: APP_TAG, id: "m1", machine: "box", host: "10.0.0.5", port: 45917, ts: now, fingerprint: "FP1" }, "10.0.0.5");
|
|
626
|
+
d.note({ app: APP_TAG, id: "m2", machine: "box", host: "10.0.0.6", port: 45917, ts: now, fingerprint: "FP2" }, "10.0.0.6");
|
|
627
|
+
assert.equal(d.peers().length, 2, "不同物理机必须都保留(重名交给 duplicateNames 提示)");
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
console.log(`\n${failed === 0 ? "全部通过" : "有失败"}:${passed} 通过 / ${failed} 失败\n`);
|
|
631
|
+
process.exit(failed === 0 ? 0 : 1);
|