diff options
author | Jaap Aarts <JAicewizard@users.noreply.github.com> | 2020-06-11 16:58:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-11 10:58:09 -0400 |
commit | 5ee2ce1b1c37f08b11a25e6c0d190f3c397c7ec2 (patch) | |
tree | b2e78c05e61c7407363157316dd90970ed8d68f4 /cli/tests/integration_tests.rs | |
parent | ca5b5ba530eccd1a4ed34bc475250daae489190a (diff) |
feat: allow reading the entry file from stdin (#6130)
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r-- | cli/tests/integration_tests.rs | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 9c59e2a74..5ecd6d35b 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -8,7 +8,7 @@ extern crate pty; extern crate tempfile; use futures::prelude::*; -use std::io::BufRead; +use std::io::{BufRead, Write}; use std::process::Command; use tempfile::TempDir; @@ -71,6 +71,50 @@ fn eval_p() { } #[test] + +fn run_from_stdin() { + let mut deno = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg("-") + .stdout(std::process::Stdio::piped()) + .stdin(std::process::Stdio::piped()) + .spawn() + .unwrap(); + deno + .stdin + .as_mut() + .unwrap() + .write_all(b"console.log(\"Hello World\");") + .unwrap(); + let output = deno.wait_with_output().unwrap(); + assert!(output.status.success()); + + let deno_out = std::str::from_utf8(&output.stdout).unwrap().trim(); + assert_eq!("Hello World", deno_out); + + let mut deno = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg("-") + .stdout(std::process::Stdio::piped()) + .stdin(std::process::Stdio::piped()) + .spawn() + .unwrap(); + deno + .stdin + .as_mut() + .unwrap() + .write_all(b"console.log(\"Bye cached code\");") + .unwrap(); + let output = deno.wait_with_output().unwrap(); + assert!(output.status.success()); + + let deno_out = std::str::from_utf8(&output.stdout).unwrap().trim(); + assert_eq!("Bye cached code", deno_out); +} + +#[test] fn no_color() { let output = util::deno_cmd() .current_dir(util::root_path()) |