openclaw/test/scripts/prune-mac-node-worker.test.ts
Peter Steinberger f85b541ed4
fix(runtime): preserve Node worker dependencies and cleanup diagnostics (#155292)
* fix(bun): preserve Node worker dependencies and spawn diagnostics

* fix(models): preserve nested catalog cleanup diagnostics

* test(gateway): own pending embeddings provider cleanup

* test(bench): retain subprocess failure diagnostics

Include status, signal, stdout, and stderr when the history benchmark subprocess fails. Keep both profiles, every assertion, and the existing 30-second child and 35-second test deadlines unchanged. This exposes the failing phase without claiming to fix the timeout.

* chore: reconcile Bun compatibility with current main

Preserve the independently reviewed c134c8d7 tree while adopting the canonical embeddings cleanup and history benchmark repairs from main. Retain the existing PR ancestry for GitHub head synchronization.

* fix(runtime): preserve Bun diagnostics after owner extraction

Resolve the mainline diagnostics extraction by keeping spawn-diagnostics.ts as the sole owner and retaining the Bun family classification and existing regression assertions. The other compatibility changes are unchanged. Independent P0-P2 review and targeted formatting passed; refreshed hosted CI is required before landing.

* chore: adopt canonical PR wrapper inventory repair

Merge main including 3a4bbc6882, which restores the SQLite reader context and spawn diagnostics to the extracted PR wrapper source inventory. The eight-file Bun compatibility patch retains identical stable patch ID 43645b39aa8a317656d1047afccfa79137314e66 and its existing reviews. Refresh hosted CI before landing.

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-09-22 16:14:05 -07:00

59 lines
2.7 KiB
TypeScript

import { mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { planMacNodeWorkerClosure } from "../../scripts/prune-mac-node-worker.js";
import { runtimeProcessEntrypoints } from "../../src/infra/runtime-process-entrypoints.js";
import { resolveTestNodeExecPath } from "../../src/test-utils/node-process.js";
import { cleanupTempDirs, makeTempDir } from "../helpers/temp-dir.js";
const tempDirs: string[] = [];
afterEach(() => cleanupTempDirs(tempDirs));
describe("Mac node worker package closure", () => {
it.each([
'resolveRuntimeProcessEntrypointUrl("serviceChildRelay")',
"resolveRuntimeProcessEntrypointUrl('serviceChildRelay')",
'resolve(process.platform === "win32" ? "serviceChildWindowsJobAnchor" : "serviceChildRelay")',
"resolveRuntimeWorkerUrl(runtimeProcessEntrypoints.serviceChildRelay)",
'resolveRuntimeWorkerUrl(runtimeProcessEntrypoints["serviceChildRelay"])',
])("retains transitive worker dependencies for %s", (launch) => {
const root = makeTempDir(tempDirs, "openclaw-mac-worker-closure-");
const write = (relative: string, source: string) => {
mkdirSync(path.dirname(path.join(root, relative)), { recursive: true });
writeFileSync(path.join(root, relative), source);
};
write("package.json", JSON.stringify({ name: "openclaw", version: "1.0.0" }));
mkdirSync(path.join(root, "dist/extensions"), { recursive: true });
write("dist/build-info.json", "{}");
for (const entrypoint of Object.values(runtimeProcessEntrypoints)) {
write(`dist/${entrypoint.distWorkerPath}`, "export {};\n");
}
write("dist/mac-node-worker.js", `${launch};\n`);
write(
"dist/process/supervisor/service-child-relay.js",
'resolveRuntimeProcessEntrypointUrl("serviceChildGroupAnchor");\n',
);
write(
"dist/process/supervisor/service-child-group-anchor.js",
'import "./anchor-helper.js";\n',
);
write("dist/process/supervisor/anchor-helper.js", 'import "worker-runtime-dependency";\n');
const closure = planMacNodeWorkerClosure(root, resolveTestNodeExecPath());
expect(closure.files).toEqual(
expect.arrayContaining([
"dist/process/supervisor/service-child-relay.js",
"dist/process/supervisor/service-child-group-anchor.js",
"dist/process/supervisor/anchor-helper.js",
]),
);
expect(closure.dependencies).toContain("worker-runtime-dependency");
expect(closure.files).not.toContain("dist/commands/doctor-lint.worker.js");
if (launch.includes("win32")) {
expect(closure.files).toContain(
"dist/process/supervisor/service-child-windows-job-anchor.js",
);
}
});
});