11import fs from "node:fs" ;
2+ import os from "node:os" ;
23import path from "node:path" ;
34import { afterEach , describe , expect , it , vi } from "vitest" ;
45import type { OpenClawConfig } from "../config/types.openclaw.js" ;
@@ -25,10 +26,31 @@ function resetPluginState(): void {
2526 resetNodeHostPluginRegistry ( ) ;
2627}
2728
29+ const tempBundledRoots : string [ ] = [ ] ;
30+
31+ function createLinuxNodeBundledRoot ( ) : string {
32+ const root = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-linux-node-plugin-" ) ) ;
33+ try {
34+ fs . symlinkSync (
35+ path . resolve ( "extensions/linux-node" ) ,
36+ path . join ( root , "linux-node" ) ,
37+ process . platform === "win32" ? "junction" : "dir" ,
38+ ) ;
39+ } catch ( error ) {
40+ fs . rmSync ( root , { force : true , recursive : true } ) ;
41+ throw error ;
42+ }
43+ tempBundledRoots . push ( root ) ;
44+ return root ;
45+ }
46+
2847afterEach ( ( ) => {
2948 vi . restoreAllMocks ( ) ;
3049 vi . unstubAllEnvs ( ) ;
3150 resetPluginState ( ) ;
51+ for ( const root of tempBundledRoots . splice ( 0 ) ) {
52+ fs . rmSync ( root , { force : true , recursive : true } ) ;
53+ }
3254} ) ;
3355
3456describe ( "linux-node node-host integration" , ( ) => {
@@ -38,6 +60,7 @@ describe("linux-node node-host integration", () => {
3860 if ( ! platformDescriptor ) {
3961 throw new Error ( "process.platform descriptor unavailable" ) ;
4062 }
63+ const bundledRoot = createLinuxNodeBundledRoot ( ) ;
4164 Object . defineProperty ( process , "platform" , { ...platformDescriptor , value : "linux" } ) ;
4265
4366 const fakeBinDir = path . resolve ( ".artifacts" , "linux-node-test-bin" ) ;
@@ -49,7 +72,7 @@ describe("linux-node node-host integration", () => {
4972 return originalAccessSync ( candidate , mode ) ;
5073 } ) ;
5174 vi . stubEnv ( "PATH" , `${ fakeBinDir } ${ path . delimiter } ${ process . env . PATH ?? "" } ` ) ;
52- vi . stubEnv ( "OPENCLAW_BUNDLED_PLUGINS_DIR" , path . resolve ( "extensions" ) ) ;
75+ vi . stubEnv ( "OPENCLAW_BUNDLED_PLUGINS_DIR" , bundledRoot ) ;
5376 vi . stubEnv ( "OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR" , "1" ) ;
5477 vi . stubEnv ( "OPENCLAW_DISABLE_BUNDLED_PLUGINS" , undefined ) ;
5578
0 commit comments