

























@@ -112,14 +112,89 @@ function assertOutput(logPath) {
112112}
113113}
114114115-const [command, arg] = process.argv.slice(2);
115+function assertCorruptUpdate(updateJsonPath, pluginId) {
116+const payload = readJson(updateJsonPath);
117+if (payload.status !== "ok") {
118+throw new Error(`expected core update status ok, got ${JSON.stringify(payload.status)}`);
119+}
120+const plugins = payload.postUpdate?.plugins;
121+if (!plugins) {
122+throw new Error(`missing postUpdate.plugins in update output: ${JSON.stringify(payload)}`);
123+}
124+if (plugins.status !== "warning") {
125+throw new Error(
126+`expected post-update plugin status warning, got ${JSON.stringify(plugins.status)}`,
127+);
128+}
129+assertCorruptPluginDetails(plugins, pluginId);
130+}
131+132+function assertCorruptPluginResult(pluginJsonPath, pluginId) {
133+const plugins = readJson(pluginJsonPath);
134+if (plugins.status !== "warning") {
135+throw new Error(
136+`expected post-update plugin status warning, got ${JSON.stringify(plugins.status)}`,
137+);
138+}
139+assertCorruptPluginDetails(plugins, pluginId);
140+}
141+142+function assertCorruptPluginDetails(plugins, pluginId) {
143+const outcomes = plugins.npm?.outcomes ?? [];
144+const outcome = outcomes.find((entry) => entry?.pluginId === pluginId);
145+if (!outcome || outcome.status !== "error") {
146+throw new Error(
147+`expected error outcome for ${pluginId}, got ${JSON.stringify({
148+ outcomes,
149+ warnings: plugins.warnings ?? [],
150+ sync: plugins.sync,
151+ integrityDrifts: plugins.integrityDrifts ?? [],
152+ })}`,
153+);
154+}
155+const warnings = plugins.warnings ?? [];
156+const warning = warnings.find((entry) => entry?.pluginId === pluginId);
157+if (!warning) {
158+throw new Error(`expected warning for ${pluginId}, got ${JSON.stringify(warnings)}`);
159+}
160+const text = JSON.stringify({ outcome, warning });
161+for (const expected of [
162+"package.json is missing",
163+"Run openclaw doctor --fix to attempt automatic repair.",
164+`Run openclaw plugins inspect ${pluginId} --runtime --json for details.`,
165+]) {
166+if (!text.includes(expected)) {
167+throw new Error(`expected update output to include ${expected}: ${text}`);
168+}
169+}
170+}
171+172+function assertLegacyPostUpdatePluginFailure(updateJsonPath) {
173+const payload = readJson(updateJsonPath);
174+if (payload.status !== "error" || payload.reason !== "post-update-plugins") {
175+throw new Error(
176+`expected legacy post-update plugin failure, got ${JSON.stringify({
177+ status: payload.status,
178+ reason: payload.reason,
179+ })}`,
180+);
181+}
182+if (!payload.after?.version) {
183+throw new Error(`expected core update to install a new version: ${JSON.stringify(payload)}`);
184+}
185+}
186+187+const [command, arg, arg2] = process.argv.slice(2);
116188const commands = {
117189"legacy-compat": () => console.log(legacyPackageAcceptanceCompat(arg || "") ? "1" : "0"),
118190seed: seedInstallState,
119191"wait-registry": waitRegistry,
120192snapshot: () => process.stdout.write(JSON.stringify(pluginRecordSnapshot(), null, 2)),
121193"assert-snapshot": () => assertSnapshot(arg),
122194"assert-output": () => assertOutput(arg),
195+"assert-corrupt-update": () => assertCorruptUpdate(arg, arg2),
196+"assert-corrupt-plugin-result": () => assertCorruptPluginResult(arg, arg2),
197+"assert-legacy-post-update-plugin-failure": () => assertLegacyPostUpdatePluginFailure(arg),
123198};
124199const run = commands[command];
125200await (
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。