summaryrefslogtreecommitdiff
path: root/cli/tests/integration_tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r--cli/tests/integration_tests.rs46
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())