summaryrefslogtreecommitdiff
path: root/cli/tests/integration/install_tests.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-06-27 13:27:36 -0400
committerGitHub <noreply@github.com>2021-06-27 13:27:36 -0400
commit098a7c8886a5be80f2acb4ed81365498a228ca0a (patch)
tree05d4ed8b1c7985228d109326eac1a6add8fe0af1 /cli/tests/integration/install_tests.rs
parent5bf7da91f178067c62d07f0220c99ba27791d206 (diff)
chore: split up integration_tests.rs into separate files (#11131)
Diffstat (limited to 'cli/tests/integration/install_tests.rs')
-rw-r--r--cli/tests/integration/install_tests.rs78
1 files changed, 78 insertions, 0 deletions
diff --git a/cli/tests/integration/install_tests.rs b/cli/tests/integration/install_tests.rs
new file mode 100644
index 000000000..e5229df8f
--- /dev/null
+++ b/cli/tests/integration/install_tests.rs
@@ -0,0 +1,78 @@
+// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+
+use std::process::Command;
+use tempfile::TempDir;
+use test_util as util;
+
+#[test]
+fn installer_test_local_module_run() {
+ let temp_dir = TempDir::new().expect("tempdir fail");
+ let bin_dir = temp_dir.path().join("bin");
+ std::fs::create_dir(&bin_dir).unwrap();
+ let status = util::deno_cmd()
+ .current_dir(util::root_path())
+ .arg("install")
+ .arg("--name")
+ .arg("echo_test")
+ .arg("--root")
+ .arg(temp_dir.path())
+ .arg(util::tests_path().join("echo.ts"))
+ .arg("hello")
+ .spawn()
+ .unwrap()
+ .wait()
+ .unwrap();
+ assert!(status.success());
+ let mut file_path = bin_dir.join("echo_test");
+ if cfg!(windows) {
+ file_path = file_path.with_extension("cmd");
+ }
+ assert!(file_path.exists());
+ // NOTE: using file_path here instead of exec_name, because tests
+ // shouldn't mess with user's PATH env variable
+ let output = Command::new(file_path)
+ .current_dir(temp_dir.path())
+ .arg("foo")
+ .env("PATH", util::target_dir())
+ .output()
+ .expect("failed to spawn script");
+ let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
+ assert!(stdout_str.ends_with("hello, foo"));
+}
+
+#[test]
+fn installer_test_remote_module_run() {
+ let _g = util::http_server();
+ let temp_dir = TempDir::new().expect("tempdir fail");
+ let bin_dir = temp_dir.path().join("bin");
+ std::fs::create_dir(&bin_dir).unwrap();
+ let status = util::deno_cmd()
+ .current_dir(util::root_path())
+ .arg("install")
+ .arg("--name")
+ .arg("echo_test")
+ .arg("--root")
+ .arg(temp_dir.path())
+ .arg("http://localhost:4545/cli/tests/echo.ts")
+ .arg("hello")
+ .spawn()
+ .unwrap()
+ .wait()
+ .unwrap();
+ assert!(status.success());
+ let mut file_path = bin_dir.join("echo_test");
+ if cfg!(windows) {
+ file_path = file_path.with_extension("cmd");
+ }
+ assert!(file_path.exists());
+ let output = Command::new(file_path)
+ .current_dir(temp_dir.path())
+ .arg("foo")
+ .env("PATH", util::target_dir())
+ .output()
+ .expect("failed to spawn script");
+ assert!(std::str::from_utf8(&output.stdout)
+ .unwrap()
+ .trim()
+ .ends_with("hello, foo"));
+}