summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/run_tests.rs5
-rw-r--r--cli/tests/testdata/spawn_stdout_inherit.ts8
-rw-r--r--cli/tests/testdata/spawn_stdout_inherit.ts.out2
-rw-r--r--cli/tests/unit/command_test.ts62
4 files changed, 37 insertions, 40 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 85363a27f..e6004ba49 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -2764,3 +2764,8 @@ itest!(report_error_handled {
args: "run --quiet report_error_handled.ts",
output: "report_error_handled.ts.out",
});
+
+itest!(spawn_stdout_inherit {
+ args: "run --quiet --unstable -A spawn_stdout_inherit.ts",
+ output: "spawn_stdout_inherit.ts.out",
+});
diff --git a/cli/tests/testdata/spawn_stdout_inherit.ts b/cli/tests/testdata/spawn_stdout_inherit.ts
new file mode 100644
index 000000000..be5f9b7ef
--- /dev/null
+++ b/cli/tests/testdata/spawn_stdout_inherit.ts
@@ -0,0 +1,8 @@
+await Deno.spawn(Deno.execPath(), {
+ args: ["eval", "--quiet", "console.log('Hello, world! 1')"],
+ stdout: "inherit",
+});
+Deno.spawnSync(Deno.execPath(), {
+ args: ["eval", "--quiet", "console.log('Hello, world! 2')"],
+ stdout: "inherit",
+});
diff --git a/cli/tests/testdata/spawn_stdout_inherit.ts.out b/cli/tests/testdata/spawn_stdout_inherit.ts.out
new file mode 100644
index 000000000..474891cf2
--- /dev/null
+++ b/cli/tests/testdata/spawn_stdout_inherit.ts.out
@@ -0,0 +1,2 @@
+Hello, world! 1
+Hello, world! 2
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",
+ );
+});