From 04994f1046e69a3c3dd296ea8bd63b045d77b17d Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 22 Jun 2026 14:18:08 +0800 Subject: [PATCH] test(scripts): normalize RPC RTT path assertions --- test/scripts/measure-rpc-rtt.test.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/scripts/measure-rpc-rtt.test.ts b/test/scripts/measure-rpc-rtt.test.ts index 4b785a59954..abbe52d3b68 100644 --- a/test/scripts/measure-rpc-rtt.test.ts +++ b/test/scripts/measure-rpc-rtt.test.ts @@ -1,6 +1,7 @@ // Measure Rpc Rtt tests cover measure rpc rtt script behavior. import { spawnSync } from "node:child_process"; import { EventEmitter } from "node:events"; +import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs"; import { @@ -280,6 +281,8 @@ describe("scripts/measure-rpc-rtt.mjs", () => { }); it("closes parent gateway log handles after spawning", async () => { + const repoRoot = "/repo"; + const tempRoot = "/tmp/rpc-rtt"; const child = Object.assign(new EventEmitter(), { exitCode: null, kill: vi.fn(), @@ -296,12 +299,12 @@ describe("scripts/measure-rpc-rtt.mjs", () => { env: { PATH: "/bin" }, openImpl, port: 23456, - repoRoot: "/repo", + repoRoot, sourceEntryExists: () => true, spawnImpl, stderrPath: "/tmp/stderr.log", stdoutPath: "/tmp/stdout.log", - tempRoot: "/tmp/rpc-rtt", + tempRoot, token: "secret-token", }), ).resolves.toBe(child); @@ -313,7 +316,7 @@ describe("scripts/measure-rpc-rtt.mjs", () => { [ "--import", "tsx", - "/repo/src/entry.ts", + path.join(repoRoot, "src", "entry.ts"), "gateway", "run", "--port", @@ -323,13 +326,13 @@ describe("scripts/measure-rpc-rtt.mjs", () => { "--allow-unconfigured", ], expect.objectContaining({ - cwd: "/repo", + cwd: repoRoot, detached: process.platform !== "win32", env: expect.objectContaining({ - HOME: "/tmp/rpc-rtt/home", + HOME: path.join(tempRoot, "home"), OPENCLAW_CONFIG_PATH: "/tmp/openclaw.json", OPENCLAW_GATEWAY_TOKEN: "secret-token", - OPENCLAW_STATE_DIR: "/tmp/rpc-rtt/state", + OPENCLAW_STATE_DIR: path.join(tempRoot, "state"), PATH: "/bin", }), stdio: ["ignore", 41, 42],