mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Pham Minh Triet <92496972+Nanome203@users.noreply.github.com> Co-authored-by: snwy <snwy@snwy.me> Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com> Co-authored-by: cirospaciari <cirospaciari@users.noreply.github.com> Co-authored-by: Ben Grant <ben@bun.sh>
42 lines
1.0 KiB
JavaScript
Generated
42 lines
1.0 KiB
JavaScript
Generated
const { spawn } = await import("child_process");
|
|
const assert = await import("assert");
|
|
const http = await import("http");
|
|
|
|
async function runTest() {
|
|
return new Promise((resolve, reject) => {
|
|
const server = spawn("node", ["04298.fixture.js"], {
|
|
cwd: import.meta.dirname,
|
|
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
|
});
|
|
|
|
server.on("message", url => {
|
|
http
|
|
.get(url, res => {
|
|
assert.strictEqual(res.statusCode, 500);
|
|
server.kill();
|
|
resolve();
|
|
})
|
|
.on("error", reject);
|
|
});
|
|
|
|
server.on("error", reject);
|
|
server.on("exit", (code, signal) => {
|
|
if (code !== null && code !== 0) {
|
|
reject(new Error(`Server exited with code ${code}`));
|
|
} else if (signal) {
|
|
reject(new Error(`Server was killed with signal ${signal}`));
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
runTest()
|
|
.then(() => {
|
|
console.log("Test passed");
|
|
process.exit(0);
|
|
})
|
|
.catch(error => {
|
|
console.error("Test failed:", error);
|
|
process.exit(1);
|
|
});
|