6b7636b088
CI / check (pull_request) Failing after 3m6s
Breaking changes: - UWF_STORAGE_ROOT → UWF_HOME - WORKFLOW_STORAGE_ROOT removed (no fallback) - OCAS_DIR → OCAS_HOME (aligned with ocas CLI) Library functions no longer read process.env: - util-agent/storage.ts: resolveStorageRoot(override), getGlobalCasDir(override) - agent-hermes: isResumeDisabled(flag) pure function, CLI reads env - agent-claude-code: CLI reads CLAUDE_MODEL and passes to agent Fixes #37
73 lines
2.8 KiB
TypeScript
73 lines
2.8 KiB
TypeScript
import { execFileSync } from "node:child_process";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
const CLI_PATH = join(dirname(fileURLToPath(import.meta.url)), "..", "cli.js");
|
|
|
|
function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } {
|
|
try {
|
|
const stdout = execFileSync("npx", ["tsx", CLI_PATH, ...args], {
|
|
encoding: "utf8",
|
|
env: { ...process.env, UWF_HOME: "/tmp/uwf-test-nonexistent" },
|
|
stdio: ["ignore", "pipe", "pipe"],
|
|
});
|
|
return { stdout, stderr: "", exitCode: 0 };
|
|
} catch (e: unknown) {
|
|
const err = e as NodeJS.ErrnoException & { stdout?: string; stderr?: string; status?: number };
|
|
return {
|
|
stdout: err.stdout ?? "",
|
|
stderr: err.stderr ?? "",
|
|
exitCode: err.status ?? 1,
|
|
};
|
|
}
|
|
}
|
|
|
|
describe("thread exec --count CLI parsing", () => {
|
|
test("--help shows -c/--count option", () => {
|
|
const result = runCli(["thread", "exec", "--help"]);
|
|
expect(result.stdout).toContain("--count");
|
|
expect(result.stdout).toContain("-c");
|
|
});
|
|
|
|
test("description says 'one or more steps'", () => {
|
|
const result = runCli(["thread", "exec", "--help"]);
|
|
expect(result.stdout).toContain("one or more steps");
|
|
});
|
|
});
|
|
|
|
describe("cmdThreadExec count logic", () => {
|
|
test("count=0 fails with validation error", () => {
|
|
const result = runCli(["thread", "exec", "FAKE_THREAD_ID", "-c", "0"]);
|
|
expect(result.exitCode).not.toBe(0);
|
|
expect(result.stderr).toContain("positive integer");
|
|
});
|
|
|
|
test("negative count fails with validation error", () => {
|
|
const result = runCli(["thread", "exec", "FAKE_THREAD_ID", "-c", "-1"]);
|
|
expect(result.exitCode).not.toBe(0);
|
|
expect(result.stderr).toContain("positive integer");
|
|
});
|
|
|
|
test("non-integer count fails with validation error", () => {
|
|
const result = runCli(["thread", "exec", "FAKE_THREAD_ID", "-c", "1.5"]);
|
|
expect(result.exitCode).not.toBe(0);
|
|
expect(result.stderr).toContain("positive integer");
|
|
});
|
|
|
|
test("count=1 is the default (no -c flag)", () => {
|
|
// Without -c, it should attempt to run 1 step (failing on missing thread, not on count validation)
|
|
const result = runCli(["thread", "exec", "FAKE_THREAD_ID"]);
|
|
expect(result.exitCode).not.toBe(0);
|
|
// Should NOT contain "positive integer" error — should fail on thread lookup instead
|
|
expect(result.stderr).not.toContain("positive integer");
|
|
});
|
|
|
|
test("count=3 passes validation (fails on thread lookup)", () => {
|
|
const result = runCli(["thread", "exec", "FAKE_THREAD_ID", "-c", "3"]);
|
|
expect(result.exitCode).not.toBe(0);
|
|
// Should NOT contain "positive integer" error — should fail on thread/storage lookup
|
|
expect(result.stderr).not.toContain("positive integer");
|
|
});
|
|
});
|