diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2022-04-24 16:21:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-24 17:21:22 +0200 |
commit | e9041b9edc371f2cbd41a354591b5663f2bb4c84 (patch) | |
tree | 243140b739556cfcbf85baa2c0ec1cb058f65975 /cli/tests/unit/command_test.ts | |
parent | 4b7d306a198d020ce2b6fa1c758c71714bfd036c (diff) |
fix(runtime/js/spawn): Pass stdio options for spawn() and spawnSync() (#14358)
Diffstat (limited to 'cli/tests/unit/command_test.ts')
-rw-r--r-- | cli/tests/unit/command_test.ts | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/cli/tests/unit/command_test.ts b/cli/tests/unit/command_test.ts index f7213f034..4b3d5bd11 100644 --- a/cli/tests/unit/command_test.ts +++ b/cli/tests/unit/command_test.ts @@ -470,46 +470,6 @@ Deno.test( Deno.test( { permissions: { run: true, read: true } }, - async function spawnOverrideStdio() { - const { stdout, stderr } = await Deno.spawn(Deno.execPath(), { - args: [ - "eval", - "console.log('hello'); console.error('world')", - ], - stdin: "piped", - stdout: "null", - stderr: "null", - }); - - // @ts-ignore: for testing - assertEquals(new TextDecoder().decode(stdout), "hello\n"); - // @ts-ignore: for testing - assertEquals(new TextDecoder().decode(stderr), "world\n"); - }, -); - -Deno.test( - { permissions: { run: true, read: true } }, - function spawnSyncOverrideStdio() { - const { stdout, stderr } = Deno.spawnSync(Deno.execPath(), { - args: [ - "eval", - "console.log('hello'); console.error('world')", - ], - stdin: "piped", - stdout: "null", - stderr: "null", - }); - - // @ts-ignore: for testing - assertEquals(new TextDecoder().decode(stdout), "hello\n"); - // @ts-ignore: for testing - assertEquals(new TextDecoder().decode(stderr), "world\n"); - }, -); - -Deno.test( - { permissions: { run: true, read: true } }, async function spawnEnv() { const { stdout } = await Deno.spawn(Deno.execPath(), { args: [ @@ -685,3 +645,25 @@ Deno.test( } }, ); + +Deno.test(async function spawnStdinPipedFails() { + await assertRejects( + () => + Deno.spawn("id", { + stdin: "piped", + }), + TypeError, + "Piped stdin is not supported for this function, use 'Deno.spawnChild()' instead", + ); +}); + +Deno.test(function spawnSyncStdinPipedFails() { + assertThrows( + () => + Deno.spawnSync("id", { + stdin: "piped", + }), + TypeError, + "Piped stdin is not supported for this function, use 'Deno.spawnChild()' instead", + ); +}); |