summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/test/captured_output.ts
blob: 3710c27b0228af9ace3574fafa23c09a6c5f81d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Deno.test("output", async () => {
  const p = Deno.run({
    cmd: [Deno.execPath(), "eval", "console.log(1); console.error(2);"],
  });
  await p.status();
  await p.close();
  Deno.spawnSync(Deno.execPath(), {
    args: ["eval", "console.log(3); console.error(4);"],
    stdout: "inherit",
    stderr: "inherit",
  });
  await Deno.spawn(Deno.execPath(), {
    args: ["eval", "console.log(5); console.error(6);"],
    stdout: "inherit",
    stderr: "inherit",
  });
  const c = await Deno.spawnChild(Deno.execPath(), {
    args: ["eval", "console.log(7); console.error(8);"],
    stdout: "inherit",
    stderr: "inherit",
  });
  await c.status;
  const worker = new Worker(
    new URL("./captured_output.worker.js", import.meta.url).href,
    { type: "module" },
  );

  // ensure worker output is captured
  const response = new Promise<void>((resolve) =>
    worker.onmessage = () => resolve()
  );
  worker.postMessage({});
  await response;
  worker.terminate();
});