diff --git a/packages/memory-host-sdk/src/host/internal.test.ts b/packages/memory-host-sdk/src/host/internal.test.ts index a969aaf0cf8..45adf405867 100644 --- a/packages/memory-host-sdk/src/host/internal.test.ts +++ b/packages/memory-host-sdk/src/host/internal.test.ts @@ -1,7 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { buildMultimodalChunkForIndexing, buildFileEntry, @@ -16,13 +16,24 @@ import { type MemoryMultimodalSettings, } from "./multimodal.js"; +let sharedTempRoot = ""; +let sharedTempId = 0; + +beforeAll(async () => { + sharedTempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "memory-host-sdk-tests-")); +}); + +afterAll(async () => { + if (sharedTempRoot) { + await fs.rm(sharedTempRoot, { recursive: true, force: true }); + } +}); + function setupTempDirLifecycle(prefix: string): () => string { let tmpDir = ""; beforeEach(async () => { - tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), prefix)); - }); - afterEach(async () => { - await fs.rm(tmpDir, { recursive: true, force: true }); + tmpDir = path.join(sharedTempRoot, `${prefix}${sharedTempId++}`); + await fs.mkdir(tmpDir, { recursive: true }); }); return () => tmpDir; } diff --git a/src/context-engine/context-engine.test.ts b/src/context-engine/context-engine.test.ts index 8232b6260e5..a62b1c15cdf 100644 --- a/src/context-engine/context-engine.test.ts +++ b/src/context-engine/context-engine.test.ts @@ -1011,7 +1011,7 @@ describe("Bundle chunk isolation (#40096)", () => { const registryUrl = new URL("./registry.ts", import.meta.url).href; const chunks = await Promise.all( Array.from( - { length: 5 }, + { length: 3 }, (_, i) => import(/* @vite-ignore */ `${registryUrl}?chunk=${ts}-${i}`), ), ); diff --git a/src/entry.version-fast-path.test.ts b/src/entry.version-fast-path.test.ts index 42f92c76dd0..673a0aef751 100644 --- a/src/entry.version-fast-path.test.ts +++ b/src/entry.version-fast-path.test.ts @@ -52,6 +52,10 @@ vi.mock("./infra/git-commit.js", () => ({ resolveCommitHash: resolveCommitHashMock, })); +vi.mock("./infra/gaxios-fetch-compat.js", () => ({ + installGaxiosFetchCompat: vi.fn(async () => {}), +})); + vi.mock("./infra/is-main.js", () => ({ isMainModule: isMainModuleMock, })); diff --git a/src/install-sh-version.test.ts b/src/install-sh-version.test.ts index 8e4469f154e..9eb60242bcd 100644 --- a/src/install-sh-version.test.ts +++ b/src/install-sh-version.test.ts @@ -21,19 +21,34 @@ printf '%s\n' '${escapedOutput}' return { root, cliPath }; } -function resolveVersionsFromInstaller(cliPaths: string[]): string[] { +function resolveInstallerVersionCases(params: { + cliPaths: string[]; + stdinCliPath: string; + stdinCwd: string; +}): string[] { const installerPath = path.join(process.cwd(), "scripts", "install.sh"); + const installerSource = fs.readFileSync(installerPath, "utf-8"); const output = execFileSync( "bash", [ "-lc", `source "${installerPath}" >/dev/null 2>&1 -for openclaw_bin in "$@"; do +for openclaw_bin in "\${@:3}"; do OPENCLAW_BIN="$openclaw_bin" resolve_openclaw_version -done`, +done +( + cd "$2" + FAKE_OPENCLAW_BIN="\${@:1:1}" bash -s <<'OPENCLAW_STDIN_INSTALLER' +${installerSource} +OPENCLAW_BIN="$FAKE_OPENCLAW_BIN" +resolve_openclaw_version +OPENCLAW_STDIN_INSTALLER +)`, "openclaw-version-test", - ...cliPaths, + params.stdinCliPath, + params.stdinCwd, + ...params.cliPaths, ], { cwd: process.cwd(), @@ -47,44 +62,17 @@ done`, return output.trimEnd().split("\n"); } -function resolveVersionFromInstallerViaStdin(cliPath: string, cwd: string): string { - const installerPath = path.join(process.cwd(), "scripts", "install.sh"); - const installerSource = fs.readFileSync(installerPath, "utf-8"); - const output = execFileSync("bash", [], { - cwd, - encoding: "utf-8", - input: `${installerSource} -OPENCLAW_BIN="$FAKE_OPENCLAW_BIN" -resolve_openclaw_version -`, - env: { - ...process.env, - FAKE_OPENCLAW_BIN: cliPath, - OPENCLAW_INSTALL_SH_NO_RUN: "1", - }, - }); - return output.trim(); -} - describe("install.sh version resolution", () => { afterEach(() => { cleanupTempDirs(tempRoots); }); - it.runIf(process.platform !== "win32")("parses decorated and raw CLI versions", () => { - const decorated = withFakeCli("OpenClaw 2026.3.10 (abcdef0)"); - const raw = withFakeCli("OpenClaw dev's build"); - - expect(resolveVersionsFromInstaller([decorated.cliPath, raw.cliPath])).toEqual([ - "2026.3.10", - "OpenClaw dev's build", - ]); - }); - it.runIf(process.platform !== "win32")( - "does not source version helpers from cwd when installer runs via stdin", + "parses CLI versions and keeps stdin helpers isolated from cwd", () => { - const fixture = withFakeCli("OpenClaw 2026.3.10 (abcdef0)"); + const decorated = withFakeCli("OpenClaw 2026.3.10 (abcdef0)"); + const raw = withFakeCli("OpenClaw dev's build"); + const stdinFixture = withFakeCli("OpenClaw 2026.3.10 (abcdef0)"); const hostileCwd = makeTempDir(tempRoots, "openclaw-install-stdin-"); const hostileHelper = path.join( @@ -104,7 +92,13 @@ extract_openclaw_semver() { "utf-8", ); - expect(resolveVersionFromInstallerViaStdin(fixture.cliPath, hostileCwd)).toBe("2026.3.10"); + expect( + resolveInstallerVersionCases({ + cliPaths: [decorated.cliPath, raw.cliPath], + stdinCliPath: stdinFixture.cliPath, + stdinCwd: hostileCwd, + }), + ).toEqual(["2026.3.10", "OpenClaw dev's build", "2026.3.10"]); }, ); }); diff --git a/src/memory-host-sdk/host/internal.test.ts b/src/memory-host-sdk/host/internal.test.ts index 4a76d28864b..a68d1a98137 100644 --- a/src/memory-host-sdk/host/internal.test.ts +++ b/src/memory-host-sdk/host/internal.test.ts @@ -1,7 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { buildMultimodalChunkForIndexing, buildFileEntry, @@ -16,13 +16,24 @@ import { type MemoryMultimodalSettings, } from "./multimodal.js"; +let sharedTempRoot = ""; +let sharedTempId = 0; + +beforeAll(async () => { + sharedTempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "memory-host-sdk-tests-")); +}); + +afterAll(async () => { + if (sharedTempRoot) { + await fs.rm(sharedTempRoot, { recursive: true, force: true }); + } +}); + function setupTempDirLifecycle(prefix: string): () => string { let tmpDir = ""; beforeEach(async () => { - tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), prefix)); - }); - afterEach(async () => { - await fs.rm(tmpDir, { recursive: true, force: true }); + tmpDir = path.join(sharedTempRoot, `${prefix}${sharedTempId++}`); + await fs.mkdir(tmpDir, { recursive: true }); }); return () => tmpDir; } diff --git a/src/routing/resolve-route.test.ts b/src/routing/resolve-route.test.ts index a3c45b86ec0..d04f11f2449 100644 --- a/src/routing/resolve-route.test.ts +++ b/src/routing/resolve-route.test.ts @@ -1063,7 +1063,7 @@ describe("wildcard peer bindings (peer.id=*)", () => { describe("binding evaluation cache scalability", () => { test("does not rescan full bindings after channel/account cache rollover (#36915)", () => { - const bindingCount = 2_205; + const bindingCount = 2_001; const cfg: OpenClawConfig = { bindings: Array.from({ length: bindingCount }, (_, idx) => ({ agentId: `agent-${idx}`,