fix bugs found by exception scope verification (#20285)

Co-authored-by: 190n <7763597+190n@users.noreply.github.com>
This commit is contained in:
190n
2025-06-18 23:08:19 -07:00
committed by GitHub
parent aa37ecb7a5
commit 346e97dde2
98 changed files with 4263 additions and 933 deletions

View File

@@ -230,6 +230,27 @@ function getTestExpectations() {
return expectations;
}
/**
* Returns whether we should validate exception checks running the given test
* @param {string} test
* @returns {boolean}
*/
const shouldValidateExceptions = (() => {
let skipArray;
return test => {
if (!skipArray) {
const path = join(cwd, "test/no-validate-exceptions.txt");
if (!existsSync(path)) {
skipArray = [];
}
skipArray = readFileSync(path, "utf-8")
.split("\n")
.filter(line => !line.startsWith("#"));
}
return !(skipArray.includes(test) || skipArray.includes("test/" + test));
};
})();
/**
* @param {string} testPath
* @returns {string[]}
@@ -416,16 +437,20 @@ async function runTests() {
const runWithBunTest =
title.includes("needs-test") || testContent.includes("bun:test") || testContent.includes("node:test");
const subcommand = runWithBunTest ? "test" : "run";
const env = {
FORCE_COLOR: "0",
NO_COLOR: "1",
BUN_DEBUG_QUIET_LOGS: "1",
};
if (basename(execPath).includes("asan") && shouldValidateExceptions(testPath)) {
env.BUN_JSC_validateExceptionChecks = "1";
}
await runTest(title, async () => {
const { ok, error, stdout } = await spawnBun(execPath, {
cwd: cwd,
args: [subcommand, "--config=" + join(import.meta.dirname, "../bunfig.node-test.toml"), absoluteTestPath],
timeout: getNodeParallelTestTimeout(title),
env: {
FORCE_COLOR: "0",
NO_COLOR: "1",
BUN_DEBUG_QUIET_LOGS: "1",
},
env,
stdout: chunk => pipeTestStdout(process.stdout, chunk),
stderr: chunk => pipeTestStdout(process.stderr, chunk),
});
@@ -953,13 +978,18 @@ async function spawnBunTest(execPath, testPath, options = { cwd }) {
testArgs.push(absPath);
const env = {
GITHUB_ACTIONS: "true", // always true so annotations are parsed
};
if (basename(execPath).includes("asan") && shouldValidateExceptions(relative(cwd, absPath))) {
env.BUN_JSC_validateExceptionChecks = "1";
}
const { ok, error, stdout } = await spawnBun(execPath, {
args: isReallyTest ? testArgs : [...args, absPath],
cwd: options["cwd"],
timeout: isReallyTest ? timeout : 30_000,
env: {
GITHUB_ACTIONS: "true", // always true so annotations are parsed
},
env,
stdout: chunk => pipeTestStdout(process.stdout, chunk),
stderr: chunk => pipeTestStdout(process.stderr, chunk),
});