fix: reject empty removal fixture scans

This commit is contained in:
DongHyeonka
2026-08-02 15:02:57 +09:00
parent f49d147b01
commit 42ffb79997
3 changed files with 62 additions and 1 deletions
+6
View File
@@ -78,6 +78,9 @@ export async function runtimeImportGraph(
const files = (await filesBelow(root))
.filter((file) => /\.(?:[cm]?ts|tsx)$/u.test(file))
.map((file) => path.resolve(file));
if (files.length === 0) {
throw new Error("removal fixture scanned module universe is empty");
}
const sourceSet = new Set(files);
const runtimeRoots = runtimeSourceRoots.map((entry) => path.resolve(root, entry));
const imports = new Map<string, readonly string[]>();
@@ -124,6 +127,9 @@ export async function removeRuntimeDependentTests(
runtimeSourceRoots: readonly string[],
): Promise<number> {
const graph = await runtimeImportGraph(root, runtimeSourceRoots);
if (graph.dependentTests.length === 0) {
throw new Error("removal fixture: no runtime-dependent tests discovered");
}
await Promise.all(graph.dependentTests.map((file) => rm(file, { force: true })));
return graph.dependentTests.length;
}