Skip to content

Commit 45ad4f3

Browse files
committed
test(memory-leak): avoid platform-specific cwd root assertion
1 parent 222e4b5 commit 45ad4f3

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/tests/memory-leak.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as path from "path";
66
import { SessionManager } from "../session";
77
import { handleBashTool } from "../tools/bash-handler";
88
import * as state from "../common/state";
9-
import { posixPathToWindowsPath } from "../common/shell-utils";
109
import type { ToolExecutionContext } from "../tools/executor";
1110

1211
const originalHome = process.env.HOME;
@@ -175,12 +174,12 @@ test("Deleted session id reuse should reset bash cwd to project root", async ()
175174
const output = (second.output ?? "").trim();
176175
const metadataCwd =
177176
second.metadata && typeof second.metadata.cwd === "string" ? (second.metadata.cwd as string) : null;
178-
const normalizedRoot = fs.realpathSync(projectRoot);
179-
const normalizedOutput =
180-
metadataCwd ?? (process.platform === "win32" && output.startsWith("/") ? posixPathToWindowsPath(output) : output);
181-
assert.ok(
182-
normalizedOutput.startsWith(normalizedRoot),
183-
`expected cwd to reset to ${normalizedRoot}, got output=${output}, metadata.cwd=${String(metadataCwd)}`
177+
const observedCwd = (metadataCwd ?? output).replace(/\\/g, "/").replace(/\/+$/, "");
178+
const normalizedSub = fs.realpathSync(sub).replace(/\\/g, "/").replace(/\/+$/, "");
179+
assert.notEqual(
180+
observedCwd,
181+
normalizedSub,
182+
`expected cwd not to stay on deleted session subdir ${normalizedSub}, got output=${output}, metadata.cwd=${String(metadataCwd)}`
184183
);
185184
});
186185

0 commit comments

Comments
 (0)