@@ -7,6 +7,7 @@ import { redactSensitiveUrlLikeString } from "@openclaw/net-policy/redact-sensit
77import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
88import { useAutoCleanupTempDirTracker } from "../../test/helpers/temp-dir.js" ;
99import type { DiagnosticSecurityEvent } from "../infra/diagnostic-events.js" ;
10+ import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js" ;
1011
1112const runCommandWithTimeoutMock = vi . fn ( ) ;
1213const installPluginFromInstalledPackageDirMock = vi . fn ( ) ;
@@ -531,7 +532,7 @@ describe("installPluginFromGitSpec", () => {
531532 }
532533 } ) ;
533534
534- it ( "falls back to OS temp when target workspace creation fails" , async ( ) => {
535+ it ( "falls back to the OpenClaw temp root when target workspace creation fails" , async ( ) => {
535536 const gitDir = trackedTempDirs . make ( "openclaw-git-install-stage-fallback-" ) ;
536537 runCommandWithTimeoutMock
537538 . mockResolvedValueOnce ( { code : 0 , stdout : "" , stderr : "" } )
@@ -568,7 +569,12 @@ describe("installPluginFromGitSpec", () => {
568569 normalizedSpec : "git:https://github.com/acme/demo.git" ,
569570 } ) ;
570571 expect ( path . dirname ( targetPrefix ) ) . toBe ( await fs . realpath ( path . dirname ( persistentRepoDir ) ) ) ;
571- expect ( path . dirname ( fallbackPrefix ) ) . toBe ( await fs . realpath ( os . tmpdir ( ) ) ) ;
572+ // withTempDir roots fallback staging at resolvePreferredOpenClawTmpDir(), which
573+ // prefers /tmp/openclaw and only degrades to a uid-scoped os.tmpdir path when
574+ // that is unsafe. Recompute it here so the assertion holds on every host.
575+ expect ( path . dirname ( fallbackPrefix ) ) . toBe (
576+ await fs . realpath ( resolvePreferredOpenClawTmpDir ( ) ) ,
577+ ) ;
572578 expect ( runCommandWithTimeoutMock ) . toHaveBeenCalledTimes ( 3 ) ;
573579 } finally {
574580 mkdtempSpy . mockRestore ( ) ;
0 commit comments