From 7c35cbc4f46488524a9b5d8bf509922e514c13a9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 3 Aug 2026 00:25:48 -0700 Subject: [PATCH] test(node-host): isolate linux plugin discovery (#118556) Co-authored-by: Peter Steinberger --- .../linux-node-plugin.integration.test.ts | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/node-host/linux-node-plugin.integration.test.ts b/src/node-host/linux-node-plugin.integration.test.ts index 48828849c6b5..3ee2b5429892 100644 --- a/src/node-host/linux-node-plugin.integration.test.ts +++ b/src/node-host/linux-node-plugin.integration.test.ts @@ -1,4 +1,5 @@ import fs from "node:fs"; +import os from "node:os"; import path from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/types.openclaw.js"; @@ -25,10 +26,31 @@ function resetPluginState(): void { resetNodeHostPluginRegistry(); } +const tempBundledRoots: string[] = []; + +function createLinuxNodeBundledRoot(): string { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-linux-node-plugin-")); + try { + fs.symlinkSync( + path.resolve("extensions/linux-node"), + path.join(root, "linux-node"), + process.platform === "win32" ? "junction" : "dir", + ); + } catch (error) { + fs.rmSync(root, { force: true, recursive: true }); + throw error; + } + tempBundledRoots.push(root); + return root; +} + afterEach(() => { vi.restoreAllMocks(); vi.unstubAllEnvs(); resetPluginState(); + for (const root of tempBundledRoots.splice(0)) { + fs.rmSync(root, { force: true, recursive: true }); + } }); describe("linux-node node-host integration", () => { @@ -38,6 +60,7 @@ describe("linux-node node-host integration", () => { if (!platformDescriptor) { throw new Error("process.platform descriptor unavailable"); } + const bundledRoot = createLinuxNodeBundledRoot(); Object.defineProperty(process, "platform", { ...platformDescriptor, value: "linux" }); const fakeBinDir = path.resolve(".artifacts", "linux-node-test-bin"); @@ -49,7 +72,7 @@ describe("linux-node node-host integration", () => { return originalAccessSync(candidate, mode); }); vi.stubEnv("PATH", `${fakeBinDir}${path.delimiter}${process.env.PATH ?? ""}`); - vi.stubEnv("OPENCLAW_BUNDLED_PLUGINS_DIR", path.resolve("extensions")); + vi.stubEnv("OPENCLAW_BUNDLED_PLUGINS_DIR", bundledRoot); vi.stubEnv("OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR", "1"); vi.stubEnv("OPENCLAW_DISABLE_BUNDLED_PLUGINS", undefined);