diff options
author | 2022-11-06 16:14:46 -0800 | |
---|---|---|
committer | 2022-11-06 16:14:46 -0800 | |
commit | 1f174b9d9580ed1101c043963b17e2bd27aedf81 (patch) | |
tree | 5cb6355b92ee2cca924dcb252e1b4aaba4387bf4 /test/bun.js | |
parent | c154402c45e81c23ee53921008ff65f6e95506df (diff) | |
download | bun-1f174b9d9580ed1101c043963b17e2bd27aedf81.tar.gz bun-1f174b9d9580ed1101c043963b17e2bd27aedf81.tar.zst bun-1f174b9d9580ed1101c043963b17e2bd27aedf81.zip |
Fixes https://github.com/oven-sh/bun/issues/1462
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/spawn.test.ts | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/test/bun.js/spawn.test.ts b/test/bun.js/spawn.test.ts index 1b62542cf..24cf08e35 100644 --- a/test/bun.js/spawn.test.ts +++ b/test/bun.js/spawn.test.ts @@ -31,10 +31,10 @@ for (let [gcTick, label] of [ it("check exit code", async () => { const { exitCode: exitCode1 } = spawnSync({ - cmd: ["ls"] + cmd: ["ls"], }); const { exitCode: exitCode2 } = spawnSync({ - cmd: ["false"] + cmd: ["false"], }); expect(exitCode1).toBe(0); expect(exitCode2).toBe(1); @@ -86,7 +86,7 @@ for (let [gcTick, label] of [ cmd: ["ls"], }).exited; const exitCode2 = await spawn({ - cmd: ["false"] + cmd: ["false"], }).exited; expect(exitCode1).toBe(0); expect(exitCode2).toBe(1); @@ -162,6 +162,28 @@ for (let [gcTick, label] of [ expect(text).toBe(hugeString); }); + it("kill(1) works", async () => { + const process = spawn({ + cmd: ["bash", "-c", "sleep 1000"], + stdout: "pipe", + }); + gcTick(); + const prom = process.exited; + process.kill(1); + await prom; + }); + + it("kill() works", async () => { + const process = spawn({ + cmd: ["bash", "-c", "sleep 1000"], + stdout: "pipe", + }); + gcTick(); + const prom = process.exited; + process.kill(); + await prom; + }); + it("stdin can be read and stdout can be written", async () => { const proc = spawn({ cmd: ["bash", import.meta.dir + "/bash-echo.sh"], |