mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 10:51:10 +00:00
test(memory): stabilize windows qmd spawn expectation
This commit is contained in:
@@ -886,7 +886,7 @@ describe("QmdMemoryManager", () => {
|
|||||||
await manager.close();
|
await manager.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses qmd.cmd on Windows when qmd command is bare", async () => {
|
it("resolves bare qmd command to a Windows-compatible spawn invocation", async () => {
|
||||||
const platformSpy = vi.spyOn(process, "platform", "get").mockReturnValue("win32");
|
const platformSpy = vi.spyOn(process, "platform", "get").mockReturnValue("win32");
|
||||||
try {
|
try {
|
||||||
const { manager } = await createManager({ mode: "status" });
|
const { manager } = await createManager({ mode: "status" });
|
||||||
@@ -894,13 +894,23 @@ describe("QmdMemoryManager", () => {
|
|||||||
|
|
||||||
const qmdCalls = spawnMock.mock.calls.filter((call: unknown[]) => {
|
const qmdCalls = spawnMock.mock.calls.filter((call: unknown[]) => {
|
||||||
const args = call[1] as string[] | undefined;
|
const args = call[1] as string[] | undefined;
|
||||||
return Array.isArray(args) && args.length > 0;
|
return (
|
||||||
|
Array.isArray(args) &&
|
||||||
|
args.some((token) => token === "update" || token === "search" || token === "query")
|
||||||
|
);
|
||||||
});
|
});
|
||||||
expect(qmdCalls.length).toBeGreaterThan(0);
|
expect(qmdCalls.length).toBeGreaterThan(0);
|
||||||
for (const call of qmdCalls) {
|
for (const call of qmdCalls) {
|
||||||
expect(call[0]).toBe("qmd.cmd");
|
const command = String(call[0]);
|
||||||
const options = call[2] as { shell?: boolean } | undefined;
|
const options = call[2] as { shell?: boolean } | undefined;
|
||||||
|
if (/(^|[\\/])qmd(?:\.cmd)?$/i.test(command)) {
|
||||||
|
// Wrapper unresolved: keep `.cmd` and use shell for PATHEXT lookup.
|
||||||
|
expect(command.toLowerCase().endsWith("qmd.cmd")).toBe(true);
|
||||||
expect(options?.shell).toBe(true);
|
expect(options?.shell).toBe(true);
|
||||||
|
} else {
|
||||||
|
// Wrapper resolved to node/exe entrypoint: shell fallback should not be used.
|
||||||
|
expect(options?.shell).not.toBe(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await manager.close();
|
await manager.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user