Files
bun.sh/test/cli/run/garbage-env.test.ts
Zack Radisic 2cbb196f29 Fix crash with garbage environment variables (#20527)
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Zack Radisic <zackradisic@users.noreply.github.com>
2025-06-21 23:44:59 -07:00

26 lines
832 B
TypeScript

import { describe, expect, test } from "bun:test";
import { bunExe, isPosix } from "harness";
import path from "path";
describe.if(isPosix)("garbage env", () => {
test("garbage env", async () => {
const cfile = path.join(import.meta.dirname, "garbage-env.c");
{
const cc = Bun.which("clang") || Bun.which("gcc") || Bun.which("cc");
const { exitCode, stderr } = await Bun.$`${cc} -o garbage-env ${cfile}`;
const stderrText = stderr.toString();
if (stderrText.length > 0) {
console.error(stderrText);
}
expect(exitCode).toBe(0);
}
const { exitCode, stderr } = await Bun.$`./garbage-env`.env({ BUN_PATH: bunExe() });
const stderrText = stderr.toString();
if (stderrText.length > 0) {
console.error(stderrText);
}
expect(exitCode).toBe(0);
});
});