fix: stabilize gateway tests on windows
This commit is contained in:
@@ -9,6 +9,9 @@ Docs: https://docs.clawd.bot
|
|||||||
- Android: bump okhttp + dnsjava to satisfy lint dependency checks.
|
- Android: bump okhttp + dnsjava to satisfy lint dependency checks.
|
||||||
- Docs: refresh Android node discovery docs for the Gateway WS service type.
|
- Docs: refresh Android node discovery docs for the Gateway WS service type.
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Tests: stabilize Windows gateway/CLI tests by skipping sidecars and normalizing argv.
|
||||||
|
|
||||||
## 2026.1.19-1
|
## 2026.1.19-1
|
||||||
|
|
||||||
### Breaking
|
### Breaking
|
||||||
|
|||||||
32
src/entry.ts
32
src/entry.ts
@@ -60,17 +60,39 @@ function ensureExperimentalWarningSuppressed(): boolean {
|
|||||||
function normalizeWindowsArgv(argv: string[]): string[] {
|
function normalizeWindowsArgv(argv: string[]): string[] {
|
||||||
if (process.platform !== "win32") return argv;
|
if (process.platform !== "win32") return argv;
|
||||||
if (argv.length < 3) return argv;
|
if (argv.length < 3) return argv;
|
||||||
const execBase = path.basename(process.execPath).toLowerCase();
|
const execPath = process.execPath;
|
||||||
|
const execPathLower = execPath.toLowerCase();
|
||||||
|
const execBase = path.basename(execPath).toLowerCase();
|
||||||
|
const isExecPath = (value: string | undefined): boolean => {
|
||||||
|
if (!value) return false;
|
||||||
|
const lower = value.toLowerCase();
|
||||||
|
return lower === execPathLower || path.basename(lower) === execBase;
|
||||||
|
};
|
||||||
const arg1 = path.basename(argv[1] ?? "").toLowerCase();
|
const arg1 = path.basename(argv[1] ?? "").toLowerCase();
|
||||||
const arg2 = path.basename(argv[2] ?? "").toLowerCase();
|
const arg2 = path.basename(argv[2] ?? "").toLowerCase();
|
||||||
const looksLikeEntry = arg1 === "entry.ts" || arg1 === "entry.js";
|
const looksLikeEntry = arg1 === "entry.ts" || arg1 === "entry.js";
|
||||||
|
let next = argv;
|
||||||
if (arg1 === execBase) {
|
if (arg1 === execBase) {
|
||||||
return [argv[0], ...argv.slice(2)];
|
next = [argv[0], ...argv.slice(2)];
|
||||||
|
} else if (looksLikeEntry && arg2 === execBase) {
|
||||||
|
next = [argv[0], argv[1], ...argv.slice(3)];
|
||||||
}
|
}
|
||||||
if (looksLikeEntry && arg2 === execBase) {
|
|
||||||
return [argv[0], argv[1], ...argv.slice(3)];
|
if (next.length < 3) return next;
|
||||||
|
const cleaned = [...next];
|
||||||
|
for (let i = 2; i < cleaned.length; ) {
|
||||||
|
const arg = cleaned[i];
|
||||||
|
if (!arg || arg.startsWith("-")) {
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isExecPath(arg)) {
|
||||||
|
cleaned.splice(i, 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return argv;
|
return cleaned;
|
||||||
}
|
}
|
||||||
|
|
||||||
process.argv = normalizeWindowsArgv(process.argv);
|
process.argv = normalizeWindowsArgv(process.argv);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ async function startServerWithDefaultConfig(port: number) {
|
|||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
auth: { mode: "token", token: "secret" },
|
auth: { mode: "token", token: "secret" },
|
||||||
controlUiEnabled: false,
|
controlUiEnabled: false,
|
||||||
|
openAiChatCompletionsEnabled: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,12 +81,12 @@ describe("gateway server sessions", () => {
|
|||||||
},
|
},
|
||||||
"discord:group:dev": {
|
"discord:group:dev": {
|
||||||
sessionId: "sess-group",
|
sessionId: "sess-group",
|
||||||
updatedAt: now - 120_000,
|
updatedAt: now - 10 * 60_000,
|
||||||
totalTokens: 50,
|
totalTokens: 50,
|
||||||
},
|
},
|
||||||
"agent:main:subagent:one": {
|
"agent:main:subagent:one": {
|
||||||
sessionId: "sess-subagent",
|
sessionId: "sess-subagent",
|
||||||
updatedAt: now - 120_000,
|
updatedAt: now - 10 * 60_000,
|
||||||
spawnedBy: "agent:main:main",
|
spawnedBy: "agent:main:main",
|
||||||
},
|
},
|
||||||
global: {
|
global: {
|
||||||
@@ -147,7 +147,7 @@ describe("gateway server sessions", () => {
|
|||||||
}>(ws, "sessions.list", {
|
}>(ws, "sessions.list", {
|
||||||
includeGlobal: false,
|
includeGlobal: false,
|
||||||
includeUnknown: false,
|
includeUnknown: false,
|
||||||
activeMinutes: 1,
|
activeMinutes: 5,
|
||||||
});
|
});
|
||||||
expect(active.ok).toBe(true);
|
expect(active.ok).toBe(true);
|
||||||
expect(active.payload?.sessions.map((s) => s.key)).toEqual(["agent:main:main"]);
|
expect(active.payload?.sessions.map((s) => s.key)).toEqual(["agent:main:main"]);
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ let previousHome: string | undefined;
|
|||||||
let previousUserProfile: string | undefined;
|
let previousUserProfile: string | undefined;
|
||||||
let previousStateDir: string | undefined;
|
let previousStateDir: string | undefined;
|
||||||
let previousConfigPath: string | undefined;
|
let previousConfigPath: string | undefined;
|
||||||
|
let previousSkipBrowserControl: string | undefined;
|
||||||
|
let previousSkipGmailWatcher: string | undefined;
|
||||||
|
let previousSkipCanvasHost: string | undefined;
|
||||||
let tempHome: string | undefined;
|
let tempHome: string | undefined;
|
||||||
let tempConfigRoot: string | undefined;
|
let tempConfigRoot: string | undefined;
|
||||||
|
|
||||||
@@ -75,11 +78,17 @@ export function installGatewayTestHooks() {
|
|||||||
previousUserProfile = process.env.USERPROFILE;
|
previousUserProfile = process.env.USERPROFILE;
|
||||||
previousStateDir = process.env.CLAWDBOT_STATE_DIR;
|
previousStateDir = process.env.CLAWDBOT_STATE_DIR;
|
||||||
previousConfigPath = process.env.CLAWDBOT_CONFIG_PATH;
|
previousConfigPath = process.env.CLAWDBOT_CONFIG_PATH;
|
||||||
|
previousSkipBrowserControl = process.env.CLAWDBOT_SKIP_BROWSER_CONTROL_SERVER;
|
||||||
|
previousSkipGmailWatcher = process.env.CLAWDBOT_SKIP_GMAIL_WATCHER;
|
||||||
|
previousSkipCanvasHost = process.env.CLAWDBOT_SKIP_CANVAS_HOST;
|
||||||
tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-gateway-home-"));
|
tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-gateway-home-"));
|
||||||
process.env.HOME = tempHome;
|
process.env.HOME = tempHome;
|
||||||
process.env.USERPROFILE = tempHome;
|
process.env.USERPROFILE = tempHome;
|
||||||
process.env.CLAWDBOT_STATE_DIR = path.join(tempHome, ".clawdbot");
|
process.env.CLAWDBOT_STATE_DIR = path.join(tempHome, ".clawdbot");
|
||||||
delete process.env.CLAWDBOT_CONFIG_PATH;
|
delete process.env.CLAWDBOT_CONFIG_PATH;
|
||||||
|
process.env.CLAWDBOT_SKIP_BROWSER_CONTROL_SERVER = "1";
|
||||||
|
process.env.CLAWDBOT_SKIP_GMAIL_WATCHER = "1";
|
||||||
|
process.env.CLAWDBOT_SKIP_CANVAS_HOST = "1";
|
||||||
tempConfigRoot = path.join(tempHome, ".clawdbot-test");
|
tempConfigRoot = path.join(tempHome, ".clawdbot-test");
|
||||||
setTestConfigRoot(tempConfigRoot);
|
setTestConfigRoot(tempConfigRoot);
|
||||||
sessionStoreSaveDelayMs.value = 0;
|
sessionStoreSaveDelayMs.value = 0;
|
||||||
@@ -128,6 +137,13 @@ export function installGatewayTestHooks() {
|
|||||||
else process.env.CLAWDBOT_STATE_DIR = previousStateDir;
|
else process.env.CLAWDBOT_STATE_DIR = previousStateDir;
|
||||||
if (previousConfigPath === undefined) delete process.env.CLAWDBOT_CONFIG_PATH;
|
if (previousConfigPath === undefined) delete process.env.CLAWDBOT_CONFIG_PATH;
|
||||||
else process.env.CLAWDBOT_CONFIG_PATH = previousConfigPath;
|
else process.env.CLAWDBOT_CONFIG_PATH = previousConfigPath;
|
||||||
|
if (previousSkipBrowserControl === undefined)
|
||||||
|
delete process.env.CLAWDBOT_SKIP_BROWSER_CONTROL_SERVER;
|
||||||
|
else process.env.CLAWDBOT_SKIP_BROWSER_CONTROL_SERVER = previousSkipBrowserControl;
|
||||||
|
if (previousSkipGmailWatcher === undefined) delete process.env.CLAWDBOT_SKIP_GMAIL_WATCHER;
|
||||||
|
else process.env.CLAWDBOT_SKIP_GMAIL_WATCHER = previousSkipGmailWatcher;
|
||||||
|
if (previousSkipCanvasHost === undefined) delete process.env.CLAWDBOT_SKIP_CANVAS_HOST;
|
||||||
|
else process.env.CLAWDBOT_SKIP_CANVAS_HOST = previousSkipCanvasHost;
|
||||||
if (tempHome) {
|
if (tempHome) {
|
||||||
await fs.rm(tempHome, {
|
await fs.rm(tempHome, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user