diff options
author | Luca Casonato <luca.casonato@antipy.com> | 2020-06-25 18:38:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 12:38:19 -0400 |
commit | 4102a195851033a21c4a23daac4c78ed2329f61f (patch) | |
tree | 2d33701fdec4cf065bdfd7f9324dc9316929c1e9 /cli/tests/unit/process_test.ts | |
parent | 1fcb71b3556ed6d3a9c6bfa8fbf1ad8b700f8578 (diff) |
fix: panic when process stdio rid is 0 or invalid (#6405)
Diffstat (limited to 'cli/tests/unit/process_test.ts')
-rw-r--r-- | cli/tests/unit/process_test.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cli/tests/unit/process_test.ts b/cli/tests/unit/process_test.ts index f2e6e01e7..b82f048ee 100644 --- a/cli/tests/unit/process_test.ts +++ b/cli/tests/unit/process_test.ts @@ -1,6 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { assert, + assertThrows, assertEquals, assertStringContains, assertThrows, @@ -26,6 +27,46 @@ unitTest({ perms: { run: true } }, async function runSuccess(): Promise<void> { p.stdout.close(); p.close(); }); +unitTest({ perms: { run: true } }, async function runStdinRid0(): Promise< + void +> { + const p = Deno.run({ + cmd: ["python", "-c", "print('hello world')"], + stdin: 0, + stdout: "piped", + stderr: "null", + }); + const status = await p.status(); + assertEquals(status.success, true); + assertEquals(status.code, 0); + assertEquals(status.signal, undefined); + p.stdout.close(); + p.close(); +}); + +unitTest({ perms: { run: true } }, function runInvalidStdio(): void { + assertThrows(() => + Deno.run({ + cmd: ["python", "-c", "print('hello world')"], + // @ts-expect-error because Deno.run should throw on invalid stdin. + stdin: "a", + }) + ); + assertThrows(() => + Deno.run({ + cmd: ["python", "-c", "print('hello world')"], + // @ts-expect-error because Deno.run should throw on invalid stdout. + stdout: "b", + }) + ); + assertThrows(() => + Deno.run({ + cmd: ["python", "-c", "print('hello world')"], + // @ts-expect-error because Deno.run should throw on invalid stderr. + stderr: "c", + }) + ); +}); unitTest( { perms: { run: true } }, |