Files
bun.sh/test/js/node/async_hooks/AsyncLocalStorage-tracking.test.ts
2025-07-02 17:45:00 -07:00

41 lines
1.2 KiB
TypeScript

import { Glob } from "bun";
import { describe, test } from "bun:test";
import { bunEnv, bunExe, isASAN, isBroken, isLinux, nodeExe } from "harness";
import { basename, join } from "path";
describe("AsyncLocalStorage passes context to callbacks", () => {
let files = [...new Glob(join(import.meta.dir, "async-context", "async-context-*.js")).scanSync()];
let todos = ["async-context-worker_threads-message.js"];
if (isASAN && isBroken && isLinux) {
todos.push("async-context-dns-resolveTxt.js");
}
files = files.filter(file => !todos.includes(basename(file)));
for (const filepath of files) {
const file = basename(filepath).replaceAll("async-context-", "").replaceAll(".js", "");
test(file, async () => {
async function run(exe) {
const { exited } = Bun.spawn({
cmd: [exe, filepath],
stdout: "inherit",
stderr: "inherit",
env: bunEnv,
});
if (await exited) {
throw new Error(`${basename(exe)} failed in ${filepath}`);
}
}
await Promise.all([run(bunExe()), run(nodeExe())]);
});
}
for (const filepath of todos) {
const file = basename(filepath).replaceAll("async-context-", "").replaceAll(".js", "");
test.todo(file);
}
});