Files
tech-log-frontend/scripts/check-realtime-boundary-fixtures.ts
T

48 lines
1.2 KiB
TypeScript

import { spawnSync } from "node:child_process";
const checker = "scripts/check-realtime-boundaries.ts";
const allowed = run(
"tests/fixtures/realtime-boundaries/allowed",
".tmp/realtime-boundaries-allowed.json",
);
const forbidden = run(
"tests/fixtures/realtime-boundaries/forbidden",
".tmp/realtime-boundaries-forbidden.json",
);
const forbiddenOutput = `${forbidden.stdout}${forbidden.stderr}`;
const expectedRules = [
"NATIVE_REALTIME_API_OUTSIDE_ADAPTER",
"PRESENTATION_INTERVAL_OWNER",
"UNSELECTED_REALTIME_RUNTIME_COMPOSED",
] as const;
if (
allowed.status !== 0 ||
forbidden.status === 0 ||
!expectedRules.every((rule) => forbiddenOutput.includes(rule))
) {
process.stderr.write(allowed.stdout);
process.stderr.write(allowed.stderr);
process.stderr.write(forbidden.stdout);
process.stderr.write(forbidden.stderr);
process.exit(1);
}
process.stdout.write(
`Realtime boundary fixtures: PASS (${expectedRules.length} forbidden rules rejected)\n`,
);
function run(sourceRoot: string, artifact: string) {
return spawnSync(
process.execPath,
[
checker,
"--source-root",
sourceRoot,
"--artifact",
artifact,
],
{ encoding: "utf8" },
);
}