mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
- Remove C emission, debugging options, and automatic backend fallback. - Complete LLVM lowering and native bootstrap coverage across supported targets. - Link executables and libraries with precompiled C runtime packs, including iOS and Android.
35 lines
1.7 KiB
TypeScript
35 lines
1.7 KiB
TypeScript
import { execFile } from "node:child_process";
|
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { promisify } from "node:util";
|
|
import { expect, test } from "vitest";
|
|
import { compile } from "@scriptc/compiler";
|
|
|
|
const run = promisify(execFile);
|
|
const fixture = join(import.meta.dirname, "../fixtures/terminal-geometry");
|
|
|
|
test.skipIf(process.platform === "win32")("stdio geometry matches Node on independent resized PTYs", async () => {
|
|
const dir = await mkdtemp(join(tmpdir(), "scriptc-geometry-"));
|
|
try {
|
|
const entry = join(fixture, "main.ts");
|
|
const script = join(fixture, "observe.py");
|
|
const oracle = await run("python3", [script, process.execPath, "--experimental-strip-types", entry]);
|
|
expect(JSON.parse(oracle.stdout)).toEqual([[88, 48, 72, 30], [100, 52, 80, 24]]);
|
|
expect(oracle.stderr).toBe("");
|
|
// Apple ASan can make malloc abandon its nano zone and write a startup warning to the PTY.
|
|
const nativeEnv = process.platform === "darwin" && process.env["SCRIPTC_SAN"] === "1"
|
|
? { ...process.env, MallocNanoZone: "0" }
|
|
: process.env;
|
|
for (const backend of ["llvm"] as const) {
|
|
const result = await compile(entry, { outDir: dir, outPath: join(dir, backend), backend, sanitize: process.env["SCRIPTC_SAN"] === "1" });
|
|
if (!result.ok) throw new Error(result.diagnostics.map((d) => `${d.code}: ${d.message}`).join("\n"));
|
|
const native = await run("python3", [script, result.binaryPath], { env: nativeEnv });
|
|
expect(native.stdout).toBe(oracle.stdout);
|
|
expect(native.stderr).toBe("");
|
|
}
|
|
} finally {
|
|
await rm(dir, { recursive: true, force: true });
|
|
}
|
|
}, 60_000);
|