summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests.rs62
-rw-r--r--cli/tests/std_tests.rs30
2 files changed, 29 insertions, 63 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index 61e1fca7d..7437b1744 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -13,6 +13,27 @@ use std::process::Command;
use tempfile::TempDir;
#[test]
+fn std_tests() {
+ let dir = TempDir::new().expect("tempdir fail");
+ let mut deno_cmd = Command::new(util::deno_exe_path());
+ deno_cmd.env("DENO_DIR", dir.path());
+
+ let mut cwd = util::root_path();
+ cwd.push("std");
+ let mut deno = deno_cmd
+ .current_dir(cwd) // note: std tests expect to run from "std" dir
+ .arg("test")
+ .arg("--unstable")
+ .arg("--seed=86") // Some tests rely on specific random numbers.
+ .arg("-A")
+ // .arg("-Ldebug")
+ .spawn()
+ .expect("failed to spawn script");
+ let status = deno.wait().expect("failed to wait for the child process");
+ assert!(status.success());
+}
+
+#[test]
fn x_deno_warning() {
let g = util::http_server();
let output = util::deno_cmd()
@@ -134,35 +155,24 @@ fn deno_dir_test() {
}
#[test]
-fn fetch_test() {
- use deno::http_cache::url_to_filename;
- pub use deno::test_util::*;
- use url::Url;
-
+fn cache_test() {
let g = util::http_server();
-
let deno_dir = TempDir::new().expect("tempdir fail");
let module_url =
- Url::parse("http://localhost:4545/cli/tests/006_url_imports.ts").unwrap();
-
- let output = Command::new(deno_exe_path())
+ url::Url::parse("http://localhost:4545/cli/tests/006_url_imports.ts")
+ .unwrap();
+ let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
.current_dir(util::root_path())
.arg("cache")
.arg(module_url.to_string())
.output()
.expect("Failed to spawn script");
-
assert!(output.status.success());
let out = std::str::from_utf8(&output.stdout).unwrap();
assert_eq!(out, "");
-
- let expected_path = deno_dir
- .path()
- .join("deps")
- .join(url_to_filename(&module_url));
- assert_eq!(expected_path.exists(), true);
-
+ // TODO(ry) Is there some way to check that the file was actually cached in
+ // DENO_DIR?
drop(g);
}
@@ -1696,18 +1706,14 @@ itest!(proto_exploit {
#[test]
fn cafile_fetch() {
- use deno::http_cache::url_to_filename;
- pub use deno::test_util::*;
use url::Url;
-
let g = util::http_server();
-
let deno_dir = TempDir::new().expect("tempdir fail");
let module_url =
Url::parse("http://localhost:4545/cli/tests/cafile_url_imports.ts")
.unwrap();
let cafile = util::root_path().join("cli/tests/tls/RootCA.pem");
- let output = Command::new(deno_exe_path())
+ let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
.current_dir(util::root_path())
.arg("cache")
@@ -1716,19 +1722,9 @@ fn cafile_fetch() {
.arg(module_url.to_string())
.output()
.expect("Failed to spawn script");
-
- let code = output.status.code();
+ assert!(output.status.success());
let out = std::str::from_utf8(&output.stdout).unwrap();
-
- assert_eq!(Some(0), code);
assert_eq!(out, "");
-
- let expected_path = deno_dir
- .path()
- .join("deps")
- .join(url_to_filename(&module_url));
- assert_eq!(expected_path.exists(), true);
-
drop(g);
}
diff --git a/cli/tests/std_tests.rs b/cli/tests/std_tests.rs
deleted file mode 100644
index f5b1f1998..000000000
--- a/cli/tests/std_tests.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-mod tests {
- extern crate lazy_static;
- extern crate tempfile;
- use deno::test_util::*;
- use std::process::Command;
- use tempfile::TempDir;
-
- #[test]
- fn std_tests() {
- let dir = TempDir::new().expect("tempdir fail");
- let mut deno_cmd = Command::new(deno_exe_path());
- deno_cmd.env("DENO_DIR", dir.path());
-
- let mut cwd = root_path();
- cwd.push("std");
- let mut deno = deno_cmd
- .current_dir(cwd) // note: std tests expect to run from "std" dir
- .arg("test")
- .arg("--unstable")
- .arg("--seed=86") // Some tests rely on specific random numbers.
- .arg("-A")
- // .arg("-Ldebug")
- .spawn()
- .expect("failed to spawn script");
- let status = deno.wait().expect("failed to wait for the child process");
- assert!(status.success());
- }
-}