mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
- Enforce oxlint and oxfmt for owned JavaScript and TypeScript with independent CI checks. - Preserve compiler import boundaries and protected fixtures while cleaning up lint findings. - Standardize source formatting and validate import, fixture, and embedded-source protections.
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { execFile } from "node:child_process";
|
|
import { mkdirSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { promisify } from "node:util";
|
|
import { expect, test } from "vitest";
|
|
import { compile } from "@scriptc/compiler";
|
|
|
|
const execFileAsync = promisify(execFile);
|
|
const repoRoot = join(import.meta.dirname, "../..");
|
|
const entry = join(repoRoot, "tests/fixtures/workspace-source/main.ts");
|
|
const cacheDir = join(repoRoot, "node_modules/.cache/scriptc-tests/workspace-source");
|
|
const sanitize = process.env["SCRIPTC_SAN"] === "1";
|
|
|
|
test.for(["llvm"] as const)(
|
|
"a TypeScript-source workspace package compiles as program modules with the %s backend",
|
|
async (backend) => {
|
|
const outDir = join(cacheDir, `${backend}-${sanitize ? "san" : "plain"}`);
|
|
mkdirSync(outDir, { recursive: true });
|
|
const result = await compile(entry, {
|
|
outPath: join(outDir, "program"),
|
|
outDir,
|
|
backend,
|
|
sanitize,
|
|
});
|
|
if (!result.ok) {
|
|
throw new Error(
|
|
result.diagnostics
|
|
.map((diagnostic) => `${diagnostic.code}: ${diagnostic.message}`)
|
|
.join("\n"),
|
|
);
|
|
}
|
|
|
|
const { stdout } = await execFileAsync(result.binaryPath, [], { encoding: "utf8" });
|
|
expect(stdout).toBe("wssource:linked:6\n");
|
|
},
|
|
120_000,
|
|
);
|