From e12e23fc55af5b6ae5f347bdefe7aa2dfde8b4c6 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 30 Jul 2025 22:34:16 -0700 Subject: [PATCH] Add exceptions --- scripts/runner.node.mjs | 20 +++++++++++++++----- src/bun.js/bindings/JSGlobalObject.zig | 2 +- src/bun.zig | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/runner.node.mjs b/scripts/runner.node.mjs index 604f7dd8c2..73b80eeffc 100755 --- a/scripts/runner.node.mjs +++ b/scripts/runner.node.mjs @@ -263,15 +263,18 @@ function getTestExpectations() { return expectations; } -const skipArray = (() => { - const path = join(cwd, "test/no-validate-exceptions.txt"); +function normalizeFilePathTextFile(path) { if (!existsSync(path)) { return []; } return readFileSync(path, "utf-8") .split("\n") - .filter(line => !line.startsWith("#") && line.length > 0); -})(); + .filter(line => !line.startsWith("#") && line.length > 0) + .map(line => line.replace(/\\/g, "/").trim()); +} + +const skipArray = normalizeFilePathTextFile(join(cwd, "test/no-validate-exceptions.txt")); +const noStackOverflowArray = normalizeFilePathTextFile(join(cwd, "test/stackoverflow-tests.txt")); /** * Returns whether we should validate exception checks running the given test @@ -1026,7 +1029,7 @@ function getCombinedPath(execPath) { * @param {SpawnOptions} options * @returns {Promise} */ -async function spawnBun(execPath, { args, cwd, timeout, env, stdout, stderr }) { +async function spawnBun(execPath, { args, cwd, timeout, env, stdout, stderr, testPath }) { const path = getCombinedPath(execPath); const tmpdirPath = mkdtempSync(join(tmpdir(), "buntmp-")); const { username, homedir } = userInfo(); @@ -1053,6 +1056,12 @@ async function spawnBun(execPath, { args, cwd, timeout, env, stdout, stderr }) { : { BUN_ENABLE_CRASH_REPORTING: "0" }), }; + if (testPath) { + if (noStackOverflowArray.includes(testPath)) { + delete bunEnv.BUN_FEATURE_FLAG_CRASH_ON_STACK_OVERFLOW; + } + } + if (basename(execPath).includes("asan")) { bunEnv.ASAN_OPTIONS = "allow_user_segv_handler=1:disable_coredump=0"; } @@ -1251,6 +1260,7 @@ async function spawnBunTest(execPath, testPath, options = { cwd }) { } const { ok, error, stdout, crashes } = await spawnBun(execPath, { + testPath, args: isReallyTest ? testArgs : [...args, absPath], cwd: options["cwd"], timeout: isReallyTest ? timeout : 30_000, diff --git a/src/bun.js/bindings/JSGlobalObject.zig b/src/bun.js/bindings/JSGlobalObject.zig index e35a4169e8..1c6fe8bb35 100644 --- a/src/bun.js/bindings/JSGlobalObject.zig +++ b/src/bun.js/bindings/JSGlobalObject.zig @@ -6,7 +6,7 @@ pub const JSGlobalObject = opaque { pub fn throwStackOverflow(this: *JSGlobalObject) void { if (comptime bun.Environment.is_canary) { if (bun.getRuntimeFeatureFlag(.BUN_FEATURE_FLAG_CRASH_ON_STACK_OVERFLOW)) { - @panic("Stack overflow"); + @panic("Stack overflow. If this was intentional, update test/stackoverflow-tests.txt"); } } diff --git a/src/bun.zig b/src/bun.zig index c88d30ecdb..cedec2439c 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -3732,7 +3732,7 @@ pub noinline fn throwStackOverflow() StackOverflow!void { @branchHint(.cold); if (comptime bun.Environment.is_canary) { if (bun.getRuntimeFeatureFlag(.BUN_FEATURE_FLAG_CRASH_ON_STACK_OVERFLOW)) { - @panic("Stack overflow"); + @panic("Stack overflow. If this was intentional, update test/stackoverflow-tests.txt"); } }