mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 21:04:07 +00:00
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildTestLiveEnv,
|
|
buildTestLivePnpmArgs,
|
|
parseTestLiveArgs,
|
|
} from "../../scripts/test-live.mjs";
|
|
|
|
describe("scripts/test-live", () => {
|
|
it("parses wrapper flags before live test spawn", () => {
|
|
const args = parseTestLiveArgs([
|
|
"--codex-harness",
|
|
"--no-quiet",
|
|
"--",
|
|
"src/gateway/gateway-codex-harness.live.test.ts",
|
|
"--reporter=verbose",
|
|
]);
|
|
|
|
expect(args).toEqual({
|
|
forceCodexHarness: true,
|
|
forwardedArgs: ["src/gateway/gateway-codex-harness.live.test.ts", "--reporter=verbose"],
|
|
help: false,
|
|
quietOverride: "0",
|
|
});
|
|
expect(buildTestLivePnpmArgs(args)).toEqual([
|
|
"exec",
|
|
"vitest",
|
|
"run",
|
|
"--config",
|
|
"test/vitest/vitest.live.config.ts",
|
|
"src/gateway/gateway-codex-harness.live.test.ts",
|
|
"--reporter=verbose",
|
|
]);
|
|
});
|
|
|
|
it("builds live env without mutating caller env", () => {
|
|
const env = buildTestLiveEnv(
|
|
{ forceCodexHarness: true, forwardedArgs: [], help: false, quietOverride: undefined },
|
|
{},
|
|
);
|
|
|
|
expect(env).toMatchObject({
|
|
CI: "1",
|
|
OPENCLAW_LIVE_CODEX_HARNESS: "1",
|
|
OPENCLAW_LIVE_TEST: "1",
|
|
OPENCLAW_LIVE_TEST_QUIET: "1",
|
|
PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN: "false",
|
|
pnpm_config_verify_deps_before_run: "false",
|
|
});
|
|
});
|
|
|
|
it("prints help without spawning live Vitest", () => {
|
|
const result = spawnSync(process.execPath, ["scripts/test-live.mjs", "--help"], {
|
|
cwd: process.cwd(),
|
|
encoding: "utf8",
|
|
});
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(result.stderr).toBe("");
|
|
expect(result.stdout).toContain("Usage: node scripts/test-live.mjs");
|
|
expect(result.stdout).not.toContain("Scope:");
|
|
expect(result.stdout).not.toContain("pnpm");
|
|
expect(result.stdout).not.toContain("[test:live]");
|
|
});
|
|
});
|