mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-22 03:29:18 +01:00
Use a separate production TypeScript configuration that excludes colocated tests while retaining every runtime source input and keeping tests in source typechecking. Verify the real compiler input sets and bound compiler-list capture for the larger source graph. Validation: focused compiler-input regression passes; fresh CI has 61 passing checks and three optional skips on 181ad8d; Greptile Apex is 5/5 with no unresolved comments. Co-Authored-By: Scott Goodson <scottgoodson@gmail.com> Co-Authored-By: Devin Foley <devin@paperclip.ing> Co-Authored-By: Paperclip <noreply@paperclip.ing>
37 lines
1.6 KiB
JavaScript
37 lines
1.6 KiB
JavaScript
import { spawnSync } from "node:child_process";
|
|
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { expect, it } from "vitest";
|
|
|
|
const serverRoot = fileURLToPath(new URL("../", import.meta.url));
|
|
|
|
function compilerInputs(args) {
|
|
const result = spawnSync(process.execPath, ["../scripts/run-tsc.mjs", ...args, "--listFilesOnly"], {
|
|
cwd: serverRoot,
|
|
encoding: "utf8",
|
|
maxBuffer: 8 * 1024 * 1024,
|
|
timeout: 30_000,
|
|
});
|
|
if (result.error) throw result.error;
|
|
expect(result.status, result.stderr || result.stdout).toBe(0);
|
|
return result.stdout.split(/\r?\n/).filter((file) => file.startsWith(path.join(serverRoot, "src", path.sep)));
|
|
}
|
|
|
|
it("omits co-located tests from the build while retaining source typecheck coverage", () => {
|
|
const { scripts } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
const command = scripts.build.split("&&").map((part) => part.trim())
|
|
.find((part) => part.startsWith("node ../scripts/run-tsc.mjs"));
|
|
expect(command).toBeDefined();
|
|
const production = compilerInputs(command.split(/\s+/).slice(2));
|
|
const source = compilerInputs(["-p", "tsconfig.json"]);
|
|
const isTest = (file) => /\.test\.tsx?$/.test(file);
|
|
|
|
expect(source.filter(isTest).length).toBeGreaterThan(0);
|
|
expect(production.filter(isTest)).toEqual([]);
|
|
const productionFiles = new Set(production);
|
|
const testTree = path.join(serverRoot, "src", "__tests__", path.sep);
|
|
expect(source.filter((file) => !isTest(file) && !file.startsWith(testTree) && !productionFiles.has(file))).toEqual([]);
|
|
}, 60_000);
|