testTcmsEndedWaitsForThem
tcmts.cli.suites.testTcmsEndedWaitsForThem · #lksz4gum · term
import { tcmsEnded } from "#codebase/tcmts/cli/suites";
import { spawnSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
export const testTcmsEndedWaitsForThem = async () => {
const dir = fs.mkdtempSync(path.join(process.env.TMPDIR ?? "/tmp", "tcms-ended-"));
try {
if (!(await tcmsEnded(dir, 100))) throw new Error("none ran: all ended");
fs.writeFileSync(path.join(dir, `tcm-pid-${process.pid}`), "");
if (await tcmsEnded(dir, 100)) throw new Error("this process is still running");
fs.rmSync(path.join(dir, `tcm-pid-${process.pid}`));
// a process that has ended
const ended = spawnSync(process.execPath, ["-e", ""]).pid;
fs.writeFileSync(path.join(dir, `tcm-pid-${ended}`), "");
if (!(await tcmsEnded(dir, 100))) throw new Error("one that's gone has ended");
} finally {
fs.rmSync(dir, { recursive: true, force: true });
}
}
uses