Files
reverse-engineering-anything/src/windows/WindowsHandleClose.test.ts
T
morlutoandCursor Agent be14c9d475 test: own temporary directories through createTestTempDirectory in src/ tests (#12725)
Give per-test temporary directories to the shared helper so Vitest removes
them after the case. Keep directories whose lifetime is the assertion, or
that are shared from beforeAll, on their existing cleanup.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-20 04:10:06 +00:00

49 lines
1.6 KiB
TypeScript

import { execFile, spawnSync } from "node:child_process";
import { join } from "node:path";
import { promisify } from "node:util";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";
const run = promisify(execFile);
const compilerProbe = spawnSync("g++", ["--version"], { stdio: "ignore" });
const compilerMissing =
compilerProbe.error instanceof Error &&
"code" in compilerProbe.error &&
compilerProbe.error.code === "ENOENT";
describe.skipIf(process.platform === "win32" && compilerMissing)(
"Windows native handle close gate",
() => {
it("retains a value unless close succeeds or the table no longer contains it", async () => {
// Injected close and liveness results. This does not call CloseHandle.
const include = fileURLToPath(
new URL("../../native/windows/src/", import.meta.url),
);
const source = join(include, "handle_close_test.cc");
const directory = await createTestTempDirectory("rea-handle-close-");
const binary = join(directory, "handle-close-test");
await run(
"g++",
[
"-std=c++17",
"-Wall",
"-Wextra",
"-Werror",
`-I${include}`,
source,
"-o",
binary,
],
{ encoding: "utf8", timeout: 60_000 },
);
const result = await run(binary, [], {
encoding: "utf8",
timeout: 30_000,
});
expect(result.stdout).toBe("");
expect(result.stderr).toBe("");
});
},
);