mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
42 lines
1.3 KiB
TypeScript
42 lines
1.3 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 proc = Bun.spawn({
|
|
cmd: [exe, filepath],
|
|
stdout: "inherit",
|
|
stderr: "inherit",
|
|
env: bunEnv,
|
|
});
|
|
|
|
await proc.exited;
|
|
if (proc.exitCode || proc.signalCode) {
|
|
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);
|
|
}
|
|
});
|