mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 09:39:25 +00:00
Complete the selected REST observation and main materialization before the last authority verification, without reopening a redundant local-only observation window. Preserve GraphQL and late fallback admission checks. Drain fake GitHub CLI response pipes before exit so lifecycle tests retain complete evidence. Cover forward main movement, final authority revocation, and complete success/error output.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { writeFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { afterEach, expect, it } from "vitest";
|
|
import { resolveVitestNodeArgs } from "../../scripts/lib/vitest-process-env.mts";
|
|
import { requireNodeTool } from "../helpers/node-toolchain.js";
|
|
import { useAutoCleanupTempDirTracker } from "../helpers/temp-dir.js";
|
|
import { createMergeGhFixturePrograms } from "./pr-merge-gh-process.test-support.js";
|
|
|
|
const temps = useAutoCleanupTempDirTracker(afterEach);
|
|
|
|
it.each([0, 7])("drains CLI response pipes before exiting with status %s", (status) => {
|
|
const directory = temps.make("pr-gh-response-");
|
|
const cli = join(directory, "gh.cjs");
|
|
const stdout = "x".repeat(1024 * 1024);
|
|
const stderr = "error".repeat(256 * 1024);
|
|
writeFileSync(
|
|
cli,
|
|
createMergeGhFixturePrograms(`
|
|
process.stdout.write("x".repeat(1024 * 1024));
|
|
process.stderr.write("error".repeat(256 * 1024));
|
|
process.exit(${status});
|
|
`).cli,
|
|
);
|
|
|
|
const result = spawnSync(requireNodeTool("node"), [...resolveVitestNodeArgs(), cli, "direct"], {
|
|
cwd: directory,
|
|
encoding: "utf8",
|
|
maxBuffer: 4 * 1024 * 1024,
|
|
});
|
|
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.status).toBe(status);
|
|
expect(result.stdout.length).toBe(stdout.length);
|
|
expect(result.stderr.length).toBe(stderr.length);
|
|
expect(result.stdout).toBe(stdout);
|
|
expect(result.stderr).toBe(stderr);
|
|
});
|