2022-04-26 14:46:49 -04:00
|
|
|
Deno.test("output", async () => {
|
|
|
|
const p = Deno.run({
|
2022-05-01 14:44:55 -04:00
|
|
|
cmd: [Deno.execPath(), "eval", "console.log(0); console.error(1);"],
|
2022-04-26 14:46:49 -04:00
|
|
|
});
|
|
|
|
await p.status();
|
|
|
|
await p.close();
|
|
|
|
Deno.spawnSync(Deno.execPath(), {
|
2022-05-01 14:44:55 -04:00
|
|
|
args: ["eval", "console.log(2); console.error(3);"],
|
2022-04-26 14:46:49 -04:00
|
|
|
stdout: "inherit",
|
|
|
|
stderr: "inherit",
|
|
|
|
});
|
|
|
|
await Deno.spawn(Deno.execPath(), {
|
2022-05-01 14:44:55 -04:00
|
|
|
args: ["eval", "console.log(4); console.error(5);"],
|
2022-04-26 14:46:49 -04:00
|
|
|
stdout: "inherit",
|
|
|
|
stderr: "inherit",
|
|
|
|
});
|
|
|
|
const c = await Deno.spawnChild(Deno.execPath(), {
|
2022-05-01 14:44:55 -04:00
|
|
|
args: ["eval", "console.log(6); console.error(7);"],
|
2022-04-26 14:46:49 -04:00
|
|
|
stdout: "inherit",
|
|
|
|
stderr: "inherit",
|
|
|
|
});
|
|
|
|
await c.status;
|
2022-04-26 19:00:04 -04:00
|
|
|
const worker = new Worker(
|
2022-07-20 10:56:53 -04:00
|
|
|
import.meta.resolve("./captured_output.worker.js"),
|
2022-04-26 19:00:04 -04:00
|
|
|
{ type: "module" },
|
|
|
|
);
|
|
|
|
|
|
|
|
// ensure worker output is captured
|
|
|
|
const response = new Promise<void>((resolve) =>
|
|
|
|
worker.onmessage = () => resolve()
|
|
|
|
);
|
|
|
|
worker.postMessage({});
|
|
|
|
await response;
|
|
|
|
worker.terminate();
|
2022-04-26 14:46:49 -04:00
|
|
|
});
|