




















11// Measure Rpc Rtt tests cover measure rpc rtt script behavior.
22import { spawnSync } from "node:child_process";
33import { EventEmitter } from "node:events";
4+import path from "node:path";
45import { describe, expect, it, vi } from "vitest";
56import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs";
67import {
@@ -280,6 +281,8 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
280281});
281282282283it("closes parent gateway log handles after spawning", async () => {
284+const repoRoot = "/repo";
285+const tempRoot = "/tmp/rpc-rtt";
283286const child = Object.assign(new EventEmitter(), {
284287exitCode: null,
285288kill: vi.fn(),
@@ -296,12 +299,12 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
296299env: { PATH: "/bin" },
297300 openImpl,
298301port: 23456,
299-repoRoot: "/repo",
302+ repoRoot,
300303sourceEntryExists: () => true,
301304 spawnImpl,
302305stderrPath: "/tmp/stderr.log",
303306stdoutPath: "/tmp/stdout.log",
304-tempRoot: "/tmp/rpc-rtt",
307+ tempRoot,
305308token: "secret-token",
306309}),
307310).resolves.toBe(child);
@@ -313,7 +316,7 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
313316[
314317"--import",
315318"tsx",
316-"/repo/src/entry.ts",
319+path.join(repoRoot, "src", "entry.ts"),
317320"gateway",
318321"run",
319322"--port",
@@ -323,13 +326,13 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
323326"--allow-unconfigured",
324327],
325328expect.objectContaining({
326-cwd: "/repo",
329+cwd: repoRoot,
327330detached: process.platform !== "win32",
328331env: expect.objectContaining({
329-HOME: "/tmp/rpc-rtt/home",
332+HOME: path.join(tempRoot, "home"),
330333OPENCLAW_CONFIG_PATH: "/tmp/openclaw.json",
331334OPENCLAW_GATEWAY_TOKEN: "secret-token",
332-OPENCLAW_STATE_DIR: "/tmp/rpc-rtt/state",
335+OPENCLAW_STATE_DIR: path.join(tempRoot, "state"),
333336PATH: "/bin",
334337}),
335338stdio: ["ignore", 41, 42],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。