1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

Fix cafile_install_remote_module test (#4429)

This commit is contained in:
Ryan Dahl 2020-03-19 12:46:56 -04:00 committed by GitHub
parent 3ef34673c9
commit 392d2c1118
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1518,13 +1518,9 @@ fn cafile_fetch() {
drop(g); drop(g);
} }
// TODO(ry) Re-enable this broken test.
#[test] #[test]
#[ignore]
fn cafile_install_remote_module() { fn cafile_install_remote_module() {
pub use deno::test_util::*; pub use deno::test_util::*;
use std::env;
use std::path::PathBuf;
use std::process::Command; use std::process::Command;
use tempfile::TempDir; use tempfile::TempDir;
@ -1545,33 +1541,22 @@ fn cafile_install_remote_module() {
.arg("https://localhost:5545/cli/tests/echo.ts") .arg("https://localhost:5545/cli/tests/echo.ts")
.output() .output()
.expect("Failed to spawn script"); .expect("Failed to spawn script");
assert!(install_output.status.success());
let code = install_output.status.code(); let mut echo_test_path = temp_dir.path().join("echo_test");
assert_eq!(Some(0), code);
let mut file_path = temp_dir.path().join("echo_test");
if cfg!(windows) { if cfg!(windows) {
file_path = file_path.with_extension(".cmd"); echo_test_path = echo_test_path.with_extension("cmd");
} }
assert!(file_path.exists()); assert!(echo_test_path.exists());
let path_var_name = if cfg!(windows) { "Path" } else { "PATH" }; let output = Command::new(echo_test_path)
let paths_var = env::var_os(path_var_name).expect("PATH not set");
let mut paths: Vec<PathBuf> = env::split_paths(&paths_var).collect();
paths.push(temp_dir.path().to_owned());
paths.push(util::target_dir());
let path_var_value = env::join_paths(paths).expect("Can't create PATH");
let output = Command::new(file_path)
.current_dir(temp_dir.path()) .current_dir(temp_dir.path())
.arg("foo") .arg("foo")
.env(path_var_name, path_var_value) .env("PATH", util::target_dir())
.output() .output()
.expect("failed to spawn script"); .expect("failed to spawn script");
assert!(std::str::from_utf8(&output.stdout) let stdout = std::str::from_utf8(&output.stdout).unwrap().trim();
.unwrap() assert!(stdout.ends_with("foo"));
.trim()
.ends_with("foo"));
drop(deno_dir); drop(deno_dir);
drop(temp_dir); drop(temp_dir);