diff --git a/scripts/test-parallel.mjs b/scripts/test-parallel.mjs index 65cad7ee6..67129a24a 100644 --- a/scripts/test-parallel.mjs +++ b/scripts/test-parallel.mjs @@ -123,7 +123,9 @@ const testProfile = rawTestProfile === "serial" ? rawTestProfile : "normal"; -const shouldSplitUnitRuns = testProfile !== "low" && testProfile !== "serial"; +// Even on low-memory hosts, keep the isolated lane split so files like +// git-commit.test.ts still get the worker/process isolation they require. +const shouldSplitUnitRuns = testProfile !== "serial"; const runs = [ ...(shouldSplitUnitRuns ? [ diff --git a/src/agents/pi-embedded-runner-extraparams.test.ts b/src/agents/pi-embedded-runner-extraparams.test.ts index fb3569369..f0762e02f 100644 --- a/src/agents/pi-embedded-runner-extraparams.test.ts +++ b/src/agents/pi-embedded-runner-extraparams.test.ts @@ -914,7 +914,7 @@ describe("applyExtraParamsToAgent", () => { compat: { requiresOpenAiAnthropicToolPayload: true, }, - } as Model<"anthropic-messages">; + } as unknown as Model<"anthropic-messages">; const context: Context = { messages: [] }; void agent.streamFn?.(model, context, {}); diff --git a/src/agents/provider-capabilities.ts b/src/agents/provider-capabilities.ts index 807c72e22..d12a3f0b9 100644 --- a/src/agents/provider-capabilities.ts +++ b/src/agents/provider-capabilities.ts @@ -157,5 +157,5 @@ export function resolveTranscriptToolCallIdMode( if (modelIncludesAnyHint(modelId, capabilities.transcriptToolCallIdModelHints)) { return "strict9"; } - return mode === "strict9" ? mode : undefined; + return undefined; } diff --git a/src/infra/git-commit.test.ts b/src/infra/git-commit.test.ts index 61804e6f9..be89c5444 100644 --- a/src/infra/git-commit.test.ts +++ b/src/infra/git-commit.test.ts @@ -3,8 +3,8 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import process from "node:process"; -import { pathToFileURL } from "node:url"; -import { afterEach, describe, expect, it, vi } from "vitest"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; async function makeTempDir(label: string): Promise { return fs.mkdtemp(path.join(os.tmpdir(), `openclaw-${label}-`)); @@ -39,10 +39,20 @@ async function makeFakeGitRepo( } describe("git commit resolution", () => { - const originalCwd = process.cwd(); + const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.."); + + beforeEach(async () => { + process.chdir(repoRoot); + vi.restoreAllMocks(); + vi.doUnmock("node:fs"); + vi.doUnmock("node:module"); + vi.resetModules(); + const { __testing } = await import("./git-commit.js"); + __testing.clearCachedGitCommits(); + }); afterEach(async () => { - process.chdir(originalCwd); + process.chdir(repoRoot); vi.restoreAllMocks(); vi.doUnmock("node:fs"); vi.doUnmock("node:module"); @@ -53,7 +63,7 @@ describe("git commit resolution", () => { it("resolves commit metadata from the caller module root instead of the caller cwd", async () => { const repoHead = execFileSync("git", ["rev-parse", "--short=7", "HEAD"], { - cwd: originalCwd, + cwd: repoRoot, encoding: "utf-8", }).trim(); @@ -75,7 +85,7 @@ describe("git commit resolution", () => { process.chdir(otherRepo); const { resolveCommitHash } = await import("./git-commit.js"); - const entryModuleUrl = pathToFileURL(path.join(originalCwd, "src", "entry.ts")).href; + const entryModuleUrl = pathToFileURL(path.join(repoRoot, "src", "entry.ts")).href; expect(resolveCommitHash({ moduleUrl: entryModuleUrl })).toBe(repoHead); expect(resolveCommitHash({ moduleUrl: entryModuleUrl })).not.toBe(otherHead); @@ -83,12 +93,12 @@ describe("git commit resolution", () => { it("prefers live git metadata over stale build info in a real checkout", async () => { const repoHead = execFileSync("git", ["rev-parse", "--short=7", "HEAD"], { - cwd: originalCwd, + cwd: repoRoot, encoding: "utf-8", }).trim(); const { resolveCommitHash } = await import("./git-commit.js"); - const entryModuleUrl = pathToFileURL(path.join(originalCwd, "src", "entry.ts")).href; + const entryModuleUrl = pathToFileURL(path.join(repoRoot, "src", "entry.ts")).href; expect( resolveCommitHash({ @@ -149,16 +159,16 @@ describe("git commit resolution", () => { it("treats invalid moduleUrl inputs as a fallback hint instead of throwing", async () => { const repoHead = execFileSync("git", ["rev-parse", "--short=7", "HEAD"], { - cwd: originalCwd, + cwd: repoRoot, encoding: "utf-8", }).trim(); const { resolveCommitHash } = await import("./git-commit.js"); expect(() => - resolveCommitHash({ moduleUrl: "not-a-file-url", cwd: originalCwd, env: {} }), + resolveCommitHash({ moduleUrl: "not-a-file-url", cwd: repoRoot, env: {} }), ).not.toThrow(); - expect(resolveCommitHash({ moduleUrl: "not-a-file-url", cwd: originalCwd, env: {} })).toBe( + expect(resolveCommitHash({ moduleUrl: "not-a-file-url", cwd: repoRoot, env: {} })).toBe( repoHead, ); });