mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
chore(tests): use custom temp dir creation for the tests (#14153)
This commit is contained in:
parent
8ca4c1819f
commit
1c37ac3352
33 changed files with 385 additions and 247 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4455,6 +4455,7 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"hyper",
|
"hyper",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"once_cell",
|
||||||
"os_pipe",
|
"os_pipe",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
|
@ -4463,7 +4464,6 @@ dependencies = [
|
||||||
"rustls-pemfile 0.2.1",
|
"rustls-pemfile 0.2.1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tempfile",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
|
|
|
@ -86,11 +86,11 @@ regex = "=1.5.5"
|
||||||
ring = "=0.16.20"
|
ring = "=0.16.20"
|
||||||
rustyline = { version = "=9.1.2", default-features = false }
|
rustyline = { version = "=9.1.2", default-features = false }
|
||||||
rustyline-derive = "=0.6.0"
|
rustyline-derive = "=0.6.0"
|
||||||
|
secure_tempfile = { version = "=3.2.0", package = "tempfile" } # different name to discourage use in tests
|
||||||
semver-parser = "=0.10.2"
|
semver-parser = "=0.10.2"
|
||||||
serde = { version = "=1.0.136", features = ["derive"] }
|
serde = { version = "=1.0.136", features = ["derive"] }
|
||||||
shell-escape = "=0.1.5"
|
shell-escape = "=0.1.5"
|
||||||
sourcemap = "=6.0.1"
|
sourcemap = "=6.0.1"
|
||||||
tempfile = "=3.2.0"
|
|
||||||
text-size = "=1.1.0"
|
text-size = "=1.1.0"
|
||||||
text_lines = "=0.4.1"
|
text_lines = "=0.4.1"
|
||||||
tokio = { version = "=1.14", features = ["full"] }
|
tokio = { version = "=1.14", features = ["full"] }
|
||||||
|
|
|
@ -351,7 +351,7 @@ fn run_strace_benchmarks(
|
||||||
let mut syscall_count = HashMap::<String, u64>::new();
|
let mut syscall_count = HashMap::<String, u64>::new();
|
||||||
|
|
||||||
for (name, args, expected_exit_code) in EXEC_TIME_BENCHMARKS {
|
for (name, args, expected_exit_code) in EXEC_TIME_BENCHMARKS {
|
||||||
let mut file = tempfile::NamedTempFile::new()?;
|
let mut file = secure_tempfile::NamedTempFile::new()?;
|
||||||
|
|
||||||
let exit_status = Command::new("strace")
|
let exit_status = Command::new("strace")
|
||||||
.args(&[
|
.args(&[
|
||||||
|
|
|
@ -150,11 +150,11 @@ impl DiskCache {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_create_cache_if_dir_exits() {
|
fn test_create_cache_if_dir_exits() {
|
||||||
let cache_location = TempDir::new().unwrap();
|
let cache_location = TempDir::new();
|
||||||
let mut cache_path = cache_location.path().to_owned();
|
let mut cache_path = cache_location.path().to_owned();
|
||||||
cache_path.push("foo");
|
cache_path.push("foo");
|
||||||
let cache = DiskCache::new(&cache_path);
|
let cache = DiskCache::new(&cache_path);
|
||||||
|
@ -166,7 +166,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_create_cache_if_dir_not_exits() {
|
fn test_create_cache_if_dir_not_exits() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut cache_location = temp_dir.path().to_owned();
|
let mut cache_location = temp_dir.path().to_owned();
|
||||||
assert!(fs::remove_dir(&cache_location).is_ok());
|
assert!(fs::remove_dir(&cache_location).is_ok());
|
||||||
cache_location.push("foo");
|
cache_location.push("foo");
|
||||||
|
|
|
@ -745,13 +745,12 @@ mod tests {
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
use deno_runtime::deno_web::Blob;
|
use deno_runtime::deno_web::Blob;
|
||||||
use deno_runtime::deno_web::InMemoryBlobPart;
|
use deno_runtime::deno_web::InMemoryBlobPart;
|
||||||
use std::rc::Rc;
|
use test_util::TempDir;
|
||||||
use tempfile::TempDir;
|
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
cache_setting: CacheSetting,
|
cache_setting: CacheSetting,
|
||||||
maybe_temp_dir: Option<Rc<TempDir>>,
|
maybe_temp_dir: Option<TempDir>,
|
||||||
) -> (FileFetcher, Rc<TempDir>) {
|
) -> (FileFetcher, TempDir) {
|
||||||
let (file_fetcher, temp_dir, _) =
|
let (file_fetcher, temp_dir, _) =
|
||||||
setup_with_blob_store(cache_setting, maybe_temp_dir);
|
setup_with_blob_store(cache_setting, maybe_temp_dir);
|
||||||
(file_fetcher, temp_dir)
|
(file_fetcher, temp_dir)
|
||||||
|
@ -759,10 +758,9 @@ mod tests {
|
||||||
|
|
||||||
fn setup_with_blob_store(
|
fn setup_with_blob_store(
|
||||||
cache_setting: CacheSetting,
|
cache_setting: CacheSetting,
|
||||||
maybe_temp_dir: Option<Rc<TempDir>>,
|
maybe_temp_dir: Option<TempDir>,
|
||||||
) -> (FileFetcher, Rc<TempDir>, BlobStore) {
|
) -> (FileFetcher, TempDir, BlobStore) {
|
||||||
let temp_dir =
|
let temp_dir = maybe_temp_dir.unwrap_or_default();
|
||||||
maybe_temp_dir.unwrap_or_else(|| Rc::new(TempDir::new().unwrap()));
|
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
let blob_store = BlobStore::default();
|
let blob_store = BlobStore::default();
|
||||||
let file_fetcher = FileFetcher::new(
|
let file_fetcher = FileFetcher::new(
|
||||||
|
@ -1227,7 +1225,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_fetch_uses_cache() {
|
async fn test_fetch_uses_cache() {
|
||||||
let _http_server_guard = test_util::http_server();
|
let _http_server_guard = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
let file_fetcher_01 = FileFetcher::new(
|
let file_fetcher_01 = FileFetcher::new(
|
||||||
HttpCache::new(&location),
|
HttpCache::new(&location),
|
||||||
|
@ -1397,7 +1395,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_fetch_uses_cache_with_redirects() {
|
async fn test_fetch_uses_cache_with_redirects() {
|
||||||
let _http_server_guard = test_util::http_server();
|
let _http_server_guard = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
let file_fetcher_01 = FileFetcher::new(
|
let file_fetcher_01 = FileFetcher::new(
|
||||||
HttpCache::new(&location),
|
HttpCache::new(&location),
|
||||||
|
@ -1526,7 +1524,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_fetch_no_remote() {
|
async fn test_fetch_no_remote() {
|
||||||
let _http_server_guard = test_util::http_server();
|
let _http_server_guard = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
let file_fetcher = FileFetcher::new(
|
let file_fetcher = FileFetcher::new(
|
||||||
HttpCache::new(&location),
|
HttpCache::new(&location),
|
||||||
|
@ -1551,7 +1549,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_fetch_cache_only() {
|
async fn test_fetch_cache_only() {
|
||||||
let _http_server_guard = test_util::http_server();
|
let _http_server_guard = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
let file_fetcher_01 = FileFetcher::new(
|
let file_fetcher_01 = FileFetcher::new(
|
||||||
HttpCache::new(&location),
|
HttpCache::new(&location),
|
||||||
|
@ -1618,7 +1616,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_respect_cache_revalidates() {
|
async fn test_respect_cache_revalidates() {
|
||||||
let _g = test_util::http_server();
|
let _g = test_util::http_server();
|
||||||
let temp_dir = Rc::new(TempDir::new().unwrap());
|
let temp_dir = TempDir::new();
|
||||||
let (file_fetcher, _) =
|
let (file_fetcher, _) =
|
||||||
setup(CacheSetting::RespectHeaders, Some(temp_dir.clone()));
|
setup(CacheSetting::RespectHeaders, Some(temp_dir.clone()));
|
||||||
let specifier =
|
let specifier =
|
||||||
|
@ -1645,7 +1643,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_respect_cache_still_fresh() {
|
async fn test_respect_cache_still_fresh() {
|
||||||
let _g = test_util::http_server();
|
let _g = test_util::http_server();
|
||||||
let temp_dir = Rc::new(TempDir::new().unwrap());
|
let temp_dir = TempDir::new();
|
||||||
let (file_fetcher, _) =
|
let (file_fetcher, _) =
|
||||||
setup(CacheSetting::RespectHeaders, Some(temp_dir.clone()));
|
setup(CacheSetting::RespectHeaders, Some(temp_dir.clone()));
|
||||||
let specifier =
|
let specifier =
|
||||||
|
|
10
cli/flags.rs
10
cli/flags.rs
|
@ -3796,8 +3796,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn allow_read_allowlist() {
|
fn allow_read_allowlist() {
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
let temp_dir = TempDir::new().expect("tempdir fail").path().to_path_buf();
|
let temp_dir_guard = TempDir::new();
|
||||||
|
let temp_dir = temp_dir_guard.path().to_path_buf();
|
||||||
|
|
||||||
let r = flags_from_vec(svec![
|
let r = flags_from_vec(svec![
|
||||||
"deno",
|
"deno",
|
||||||
|
@ -3819,8 +3820,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn allow_write_allowlist() {
|
fn allow_write_allowlist() {
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
let temp_dir = TempDir::new().expect("tempdir fail").path().to_path_buf();
|
let temp_dir_guard = TempDir::new();
|
||||||
|
let temp_dir = temp_dir_guard.path().to_path_buf();
|
||||||
|
|
||||||
let r = flags_from_vec(svec![
|
let r = flags_from_vec(svec![
|
||||||
"deno",
|
"deno",
|
||||||
|
|
|
@ -406,7 +406,7 @@ pub fn path_with_stem_suffix(path: &Path, suffix: &str) -> PathBuf {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn resolve_from_cwd_child() {
|
fn resolve_from_cwd_child() {
|
||||||
|
@ -548,7 +548,7 @@ mod tests {
|
||||||
// ├── g.d.ts
|
// ├── g.d.ts
|
||||||
// └── .gitignore
|
// └── .gitignore
|
||||||
|
|
||||||
let t = TempDir::new().expect("tempdir fail");
|
let t = TempDir::new();
|
||||||
|
|
||||||
let root_dir_path = t.path().join("dir.ts");
|
let root_dir_path = t.path().join("dir.ts");
|
||||||
let root_dir_files = ["a.ts", "b.js", "c.tsx", "d.jsx"];
|
let root_dir_files = ["a.ts", "b.js", "c.tsx", "d.jsx"];
|
||||||
|
@ -609,7 +609,7 @@ mod tests {
|
||||||
// ├── g.d.ts
|
// ├── g.d.ts
|
||||||
// └── .gitignore
|
// └── .gitignore
|
||||||
|
|
||||||
let t = TempDir::new().expect("tempdir fail");
|
let t = TempDir::new();
|
||||||
|
|
||||||
let root_dir_path = t.path().join("dir.ts");
|
let root_dir_path = t.path().join("dir.ts");
|
||||||
let root_dir_files = ["a.ts", "b.js", "c.tsx", "d.jsx"];
|
let root_dir_files = ["a.ts", "b.js", "c.tsx", "d.jsx"];
|
||||||
|
|
|
@ -188,11 +188,11 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_create_cache() {
|
fn test_create_cache() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let mut cache_path = dir.path().to_owned();
|
let mut cache_path = dir.path().to_owned();
|
||||||
cache_path.push("foobar");
|
cache_path.push("foobar");
|
||||||
// HttpCache should be created lazily on first use:
|
// HttpCache should be created lazily on first use:
|
||||||
|
@ -219,7 +219,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_set() {
|
fn test_get_set() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let cache = HttpCache::new(dir.path());
|
let cache = HttpCache::new(dir.path());
|
||||||
let url = Url::parse("https://deno.land/x/welcome.ts").unwrap();
|
let url = Url::parse("https://deno.land/x/welcome.ts").unwrap();
|
||||||
let mut headers = HashMap::new();
|
let mut headers = HashMap::new();
|
||||||
|
|
|
@ -138,11 +138,9 @@ mod tests {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
fn setup() -> (TempDir, PathBuf) {
|
|
||||||
let temp_dir = TempDir::new().expect("could not create temp dir");
|
|
||||||
|
|
||||||
|
fn setup(temp_dir: &TempDir) -> PathBuf {
|
||||||
let file_path = temp_dir.path().join("valid_lockfile.json");
|
let file_path = temp_dir.path().join("valid_lockfile.json");
|
||||||
let mut file = File::create(file_path).expect("write file fail");
|
let mut file = File::create(file_path).expect("write file fail");
|
||||||
|
|
||||||
|
@ -153,13 +151,7 @@ mod tests {
|
||||||
|
|
||||||
file.write_all(value.to_string().as_bytes()).unwrap();
|
file.write_all(value.to_string().as_bytes()).unwrap();
|
||||||
|
|
||||||
let file_path = temp_dir.path().join("valid_lockfile.json");
|
temp_dir.path().join("valid_lockfile.json")
|
||||||
|
|
||||||
(temp_dir, file_path)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn teardown(temp_dir: TempDir) {
|
|
||||||
temp_dir.close().expect("file close error");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -170,7 +162,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new_valid_lockfile() {
|
fn new_valid_lockfile() {
|
||||||
let (temp_dir, file_path) = setup();
|
let temp_dir = TempDir::new();
|
||||||
|
let file_path = setup(&temp_dir);
|
||||||
|
|
||||||
let result = Lockfile::new(file_path, false).unwrap();
|
let result = Lockfile::new(file_path, false).unwrap();
|
||||||
|
|
||||||
|
@ -182,13 +175,12 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(keys.len(), 2);
|
assert_eq!(keys.len(), 2);
|
||||||
assert_eq!(keys, expected_keys);
|
assert_eq!(keys, expected_keys);
|
||||||
|
|
||||||
teardown(temp_dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new_lockfile_from_file_and_insert() {
|
fn new_lockfile_from_file_and_insert() {
|
||||||
let (temp_dir, file_path) = setup();
|
let temp_dir = TempDir::new();
|
||||||
|
let file_path = setup(&temp_dir);
|
||||||
|
|
||||||
let mut lockfile = Lockfile::new(file_path, false).unwrap();
|
let mut lockfile = Lockfile::new(file_path, false).unwrap();
|
||||||
|
|
||||||
|
@ -205,13 +197,12 @@ mod tests {
|
||||||
];
|
];
|
||||||
assert_eq!(keys.len(), 3);
|
assert_eq!(keys.len(), 3);
|
||||||
assert_eq!(keys, expected_keys);
|
assert_eq!(keys, expected_keys);
|
||||||
|
|
||||||
teardown(temp_dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new_lockfile_and_write() {
|
fn new_lockfile_and_write() {
|
||||||
let (temp_dir, file_path) = setup();
|
let temp_dir = TempDir::new();
|
||||||
|
let file_path = setup(&temp_dir);
|
||||||
|
|
||||||
let mut lockfile = Lockfile::new(file_path, true).unwrap();
|
let mut lockfile = Lockfile::new(file_path, true).unwrap();
|
||||||
|
|
||||||
|
@ -264,13 +255,12 @@ mod tests {
|
||||||
Some("https://deno.land/std@0.71.0/textproto/mod.ts")
|
Some("https://deno.land/std@0.71.0/textproto/mod.ts")
|
||||||
);
|
);
|
||||||
assert!(keys.next().is_none());
|
assert!(keys.next().is_none());
|
||||||
|
|
||||||
teardown(temp_dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_or_insert_lockfile_false() {
|
fn check_or_insert_lockfile_false() {
|
||||||
let (temp_dir, file_path) = setup();
|
let temp_dir = TempDir::new();
|
||||||
|
let file_path = setup(&temp_dir);
|
||||||
|
|
||||||
let mut lockfile = Lockfile::new(file_path, false).unwrap();
|
let mut lockfile = Lockfile::new(file_path, false).unwrap();
|
||||||
|
|
||||||
|
@ -290,7 +280,5 @@ mod tests {
|
||||||
"This is new Source code",
|
"This is new Source code",
|
||||||
);
|
);
|
||||||
assert!(!check_false);
|
assert!(!check_false);
|
||||||
|
|
||||||
teardown(temp_dir);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -578,7 +578,7 @@ mod tests {
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
fn mock_documents(
|
fn mock_documents(
|
||||||
fixtures: &[(&str, &str, i32, LanguageId)],
|
fixtures: &[(&str, &str, i32, LanguageId)],
|
||||||
|
@ -612,10 +612,10 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
|
temp_dir: &TempDir,
|
||||||
documents: &[(&str, &str, i32, LanguageId)],
|
documents: &[(&str, &str, i32, LanguageId)],
|
||||||
sources: &[(&str, &str)],
|
sources: &[(&str, &str)],
|
||||||
) -> Documents {
|
) -> Documents {
|
||||||
let temp_dir = TempDir::new().expect("could not create temp dir");
|
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
mock_documents(documents, sources, &location)
|
mock_documents(documents, sources, &location)
|
||||||
}
|
}
|
||||||
|
@ -717,7 +717,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_local_completions() {
|
fn test_get_local_completions() {
|
||||||
let temp_dir = TempDir::new().expect("could not create temp dir");
|
let temp_dir = TempDir::new();
|
||||||
let fixtures = temp_dir.path().join("fixtures");
|
let fixtures = temp_dir.path().join("fixtures");
|
||||||
std::fs::create_dir(&fixtures).expect("could not create");
|
std::fs::create_dir(&fixtures).expect("could not create");
|
||||||
let dir_a = fixtures.join("a");
|
let dir_a = fixtures.join("a");
|
||||||
|
@ -776,7 +776,9 @@ mod tests {
|
||||||
character: 21,
|
character: 21,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let documents = setup(
|
let documents = setup(
|
||||||
|
&temp_dir,
|
||||||
&[
|
&[
|
||||||
(
|
(
|
||||||
"file:///a/b/c.ts",
|
"file:///a/b/c.ts",
|
||||||
|
|
|
@ -884,7 +884,7 @@ mod tests {
|
||||||
use crate::lsp::language_server::StateSnapshot;
|
use crate::lsp::language_server::StateSnapshot;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
fn mock_state_snapshot(
|
fn mock_state_snapshot(
|
||||||
fixtures: &[(&str, &str, i32, LanguageId)],
|
fixtures: &[(&str, &str, i32, LanguageId)],
|
||||||
|
@ -922,9 +922,9 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
|
temp_dir: &TempDir,
|
||||||
sources: &[(&str, &str, i32, LanguageId)],
|
sources: &[(&str, &str, i32, LanguageId)],
|
||||||
) -> (StateSnapshot, PathBuf) {
|
) -> (StateSnapshot, PathBuf) {
|
||||||
let temp_dir = TempDir::new().expect("could not create temp dir");
|
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
let state_snapshot = mock_state_snapshot(sources, &location);
|
let state_snapshot = mock_state_snapshot(sources, &location);
|
||||||
(state_snapshot, location)
|
(state_snapshot, location)
|
||||||
|
@ -932,16 +932,20 @@ mod tests {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_enabled_then_disabled_specifier() {
|
async fn test_enabled_then_disabled_specifier() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let specifier = ModuleSpecifier::parse("file:///a.ts").unwrap();
|
let specifier = ModuleSpecifier::parse("file:///a.ts").unwrap();
|
||||||
let (snapshot, _) = setup(&[(
|
let (snapshot, _) = setup(
|
||||||
"file:///a.ts",
|
&temp_dir,
|
||||||
r#"import * as b from "./b.ts";
|
&[(
|
||||||
|
"file:///a.ts",
|
||||||
|
r#"import * as b from "./b.ts";
|
||||||
let a: any = "a";
|
let a: any = "a";
|
||||||
let c: number = "a";
|
let c: number = "a";
|
||||||
"#,
|
"#,
|
||||||
1,
|
1,
|
||||||
LanguageId::TypeScript,
|
LanguageId::TypeScript,
|
||||||
)]);
|
)],
|
||||||
|
);
|
||||||
let snapshot = Arc::new(snapshot);
|
let snapshot = Arc::new(snapshot);
|
||||||
let ts_server = TsServer::new(Default::default());
|
let ts_server = TsServer::new(Default::default());
|
||||||
|
|
||||||
|
@ -1026,12 +1030,16 @@ let c: number = "a";
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_cancelled_ts_diagnostics_request() {
|
async fn test_cancelled_ts_diagnostics_request() {
|
||||||
let (snapshot, _) = setup(&[(
|
let temp_dir = TempDir::new();
|
||||||
"file:///a.ts",
|
let (snapshot, _) = setup(
|
||||||
r#"export let a: string = 5;"#,
|
&temp_dir,
|
||||||
1,
|
&[(
|
||||||
LanguageId::TypeScript,
|
"file:///a.ts",
|
||||||
)]);
|
r#"export let a: string = 5;"#,
|
||||||
|
1,
|
||||||
|
LanguageId::TypeScript,
|
||||||
|
)],
|
||||||
|
);
|
||||||
let snapshot = Arc::new(snapshot);
|
let snapshot = Arc::new(snapshot);
|
||||||
let ts_server = TsServer::new(Default::default());
|
let ts_server = TsServer::new(Default::default());
|
||||||
|
|
||||||
|
|
|
@ -1134,10 +1134,9 @@ impl Documents {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
fn setup() -> (Documents, PathBuf) {
|
fn setup(temp_dir: &TempDir) -> (Documents, PathBuf) {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
let documents = Documents::new(&location);
|
let documents = Documents::new(&location);
|
||||||
(documents, location)
|
(documents, location)
|
||||||
|
@ -1145,7 +1144,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_documents_open() {
|
fn test_documents_open() {
|
||||||
let (mut documents, _) = setup();
|
let temp_dir = TempDir::new();
|
||||||
|
let (mut documents, _) = setup(&temp_dir);
|
||||||
let specifier = ModuleSpecifier::parse("file:///a.ts").unwrap();
|
let specifier = ModuleSpecifier::parse("file:///a.ts").unwrap();
|
||||||
let content = Arc::new(
|
let content = Arc::new(
|
||||||
r#"import * as b from "./b.ts";
|
r#"import * as b from "./b.ts";
|
||||||
|
@ -1161,7 +1161,8 @@ console.log(b);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_documents_change() {
|
fn test_documents_change() {
|
||||||
let (mut documents, _) = setup();
|
let temp_dir = TempDir::new();
|
||||||
|
let (mut documents, _) = setup(&temp_dir);
|
||||||
let specifier = ModuleSpecifier::parse("file:///a.ts").unwrap();
|
let specifier = ModuleSpecifier::parse("file:///a.ts").unwrap();
|
||||||
let content = Arc::new(
|
let content = Arc::new(
|
||||||
r#"import * as b from "./b.ts";
|
r#"import * as b from "./b.ts";
|
||||||
|
@ -1207,7 +1208,8 @@ console.log(b, "hello deno");
|
||||||
fn test_documents_ensure_no_duplicates() {
|
fn test_documents_ensure_no_duplicates() {
|
||||||
// it should never happen that a user of this API causes this to happen,
|
// it should never happen that a user of this API causes this to happen,
|
||||||
// but we'll guard against it anyway
|
// but we'll guard against it anyway
|
||||||
let (mut documents, documents_path) = setup();
|
let temp_dir = TempDir::new();
|
||||||
|
let (mut documents, documents_path) = setup(&temp_dir);
|
||||||
let file_path = documents_path.join("file.ts");
|
let file_path = documents_path.join("file.ts");
|
||||||
let file_specifier = ModuleSpecifier::from_file_path(&file_path).unwrap();
|
let file_specifier = ModuleSpecifier::from_file_path(&file_path).unwrap();
|
||||||
fs::create_dir_all(&documents_path).unwrap();
|
fs::create_dir_all(&documents_path).unwrap();
|
||||||
|
|
|
@ -1050,7 +1050,7 @@ impl ModuleRegistry {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_validate_registry_configuration() {
|
fn test_validate_registry_configuration() {
|
||||||
|
@ -1205,7 +1205,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_registry_completions_origin_match() {
|
async fn test_registry_completions_origin_match() {
|
||||||
let _g = test_util::http_server();
|
let _g = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().expect("could not create tmp");
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("registries");
|
let location = temp_dir.path().join("registries");
|
||||||
let mut module_registry =
|
let mut module_registry =
|
||||||
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
||||||
|
@ -1266,7 +1266,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_registry_completions() {
|
async fn test_registry_completions() {
|
||||||
let _g = test_util::http_server();
|
let _g = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().expect("could not create tmp");
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("registries");
|
let location = temp_dir.path().join("registries");
|
||||||
let mut module_registry =
|
let mut module_registry =
|
||||||
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
||||||
|
@ -1489,7 +1489,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_registry_completions_key_first() {
|
async fn test_registry_completions_key_first() {
|
||||||
let _g = test_util::http_server();
|
let _g = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().expect("could not create tmp");
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("registries");
|
let location = temp_dir.path().join("registries");
|
||||||
let mut module_registry =
|
let mut module_registry =
|
||||||
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
||||||
|
@ -1559,7 +1559,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_registry_completions_complex() {
|
async fn test_registry_completions_complex() {
|
||||||
let _g = test_util::http_server();
|
let _g = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().expect("could not create tmp");
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("registries");
|
let location = temp_dir.path().join("registries");
|
||||||
let mut module_registry =
|
let mut module_registry =
|
||||||
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
||||||
|
@ -1610,7 +1610,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_check_origin_supported() {
|
async fn test_check_origin_supported() {
|
||||||
let _g = test_util::http_server();
|
let _g = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().expect("could not create tmp");
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("registries");
|
let location = temp_dir.path().join("registries");
|
||||||
let module_registry =
|
let module_registry =
|
||||||
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
||||||
|
@ -1621,7 +1621,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_check_origin_not_supported() {
|
async fn test_check_origin_not_supported() {
|
||||||
let _g = test_util::http_server();
|
let _g = test_util::http_server();
|
||||||
let temp_dir = TempDir::new().expect("could not create tmp");
|
let temp_dir = TempDir::new();
|
||||||
let location = temp_dir.path().join("registries");
|
let location = temp_dir.path().join("registries");
|
||||||
let module_registry =
|
let module_registry =
|
||||||
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
ModuleRegistry::new(&location, ModuleRegistryOptions::default()).unwrap();
|
||||||
|
|
|
@ -3298,7 +3298,7 @@ mod tests {
|
||||||
use crate::lsp::text::LineIndex;
|
use crate::lsp::text::LineIndex;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tempfile::TempDir;
|
use test_util::TempDir;
|
||||||
|
|
||||||
fn mock_state_snapshot(
|
fn mock_state_snapshot(
|
||||||
fixtures: &[(&str, &str, i32, LanguageId)],
|
fixtures: &[(&str, &str, i32, LanguageId)],
|
||||||
|
@ -3322,11 +3322,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
|
temp_dir: &TempDir,
|
||||||
debug: bool,
|
debug: bool,
|
||||||
config: Value,
|
config: Value,
|
||||||
sources: &[(&str, &str, i32, LanguageId)],
|
sources: &[(&str, &str, i32, LanguageId)],
|
||||||
) -> (JsRuntime, Arc<StateSnapshot>, PathBuf) {
|
) -> (JsRuntime, Arc<StateSnapshot>, PathBuf) {
|
||||||
let temp_dir = TempDir::new().expect("could not create temp dir");
|
|
||||||
let location = temp_dir.path().join("deps");
|
let location = temp_dir.path().join("deps");
|
||||||
let state_snapshot = Arc::new(mock_state_snapshot(sources, &location));
|
let state_snapshot = Arc::new(mock_state_snapshot(sources, &location));
|
||||||
let mut runtime = js_runtime(Default::default());
|
let mut runtime = js_runtime(Default::default());
|
||||||
|
@ -3363,7 +3363,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_project_configure() {
|
fn test_project_configure() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
setup(
|
setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3376,7 +3378,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_project_reconfigure() {
|
fn test_project_reconfigure() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3404,7 +3408,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_diagnostics() {
|
fn test_get_diagnostics() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3453,7 +3459,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_diagnostics_lib() {
|
fn test_get_diagnostics_lib() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3483,7 +3491,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_module_resolution() {
|
fn test_module_resolution() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3518,7 +3528,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bad_module_specifiers() {
|
fn test_bad_module_specifiers() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3569,7 +3581,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_remote_modules() {
|
fn test_remote_modules() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3604,7 +3618,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_partial_modules() {
|
fn test_partial_modules() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3676,7 +3692,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_debug_failure() {
|
fn test_no_debug_failure() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3726,7 +3744,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_request_asset() {
|
fn test_request_asset() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3752,7 +3772,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_modify_sources() {
|
fn test_modify_sources() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, location) = setup(
|
let (mut runtime, state_snapshot, location) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3839,7 +3861,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_op_exists() {
|
fn test_op_exists() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut rt, state_snapshot, _) = setup(
|
let (mut rt, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
@ -3910,7 +3934,9 @@ mod tests {
|
||||||
character: 16,
|
character: 16,
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let (mut runtime, state_snapshot, _) = setup(
|
let (mut runtime, state_snapshot, _) = setup(
|
||||||
|
&temp_dir,
|
||||||
false,
|
false,
|
||||||
json!({
|
json!({
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::itest;
|
use crate::itest;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bundle_exports() {
|
fn bundle_exports() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let mod1 = util::testdata_path().join("subdir/mod1.ts");
|
let mod1 = util::testdata_path().join("subdir/mod1.ts");
|
||||||
assert!(mod1.is_file());
|
assert!(mod1.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("mod1.bundle.js");
|
let bundle = t.path().join("mod1.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -51,7 +51,7 @@ fn bundle_exports_no_check() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let mod1 = util::testdata_path().join("subdir/mod1.ts");
|
let mod1 = util::testdata_path().join("subdir/mod1.ts");
|
||||||
assert!(mod1.is_file());
|
assert!(mod1.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("mod1.bundle.js");
|
let bundle = t.path().join("mod1.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -94,7 +94,7 @@ fn bundle_circular() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let circular1 = util::testdata_path().join("subdir/circular1.ts");
|
let circular1 = util::testdata_path().join("subdir/circular1.ts");
|
||||||
assert!(circular1.is_file());
|
assert!(circular1.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("circular1.bundle.js");
|
let bundle = t.path().join("circular1.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -126,7 +126,7 @@ fn bundle_single_module() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let single_module = util::testdata_path().join("subdir/single_module.ts");
|
let single_module = util::testdata_path().join("subdir/single_module.ts");
|
||||||
assert!(single_module.is_file());
|
assert!(single_module.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("single_module.bundle.js");
|
let bundle = t.path().join("single_module.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -158,7 +158,7 @@ fn bundle_tla() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let tla_import = util::testdata_path().join("subdir/tla.ts");
|
let tla_import = util::testdata_path().join("subdir/tla.ts");
|
||||||
assert!(tla_import.is_file());
|
assert!(tla_import.is_file());
|
||||||
let t = tempfile::TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("tla.bundle.js");
|
let bundle = t.path().join("tla.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -200,7 +200,7 @@ fn bundle_js() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let mod6 = util::testdata_path().join("subdir/mod6.js");
|
let mod6 = util::testdata_path().join("subdir/mod6.js");
|
||||||
assert!(mod6.is_file());
|
assert!(mod6.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("mod6.bundle.js");
|
let bundle = t.path().join("mod6.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -228,7 +228,7 @@ fn bundle_dynamic_import() {
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let dynamic_import = util::testdata_path().join("bundle_dynamic_import.ts");
|
let dynamic_import = util::testdata_path().join("bundle_dynamic_import.ts");
|
||||||
assert!(dynamic_import.is_file());
|
assert!(dynamic_import.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("bundle_dynamic_import.bundle.js");
|
let bundle = t.path().join("bundle_dynamic_import.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -262,7 +262,7 @@ fn bundle_import_map() {
|
||||||
let import = util::testdata_path().join("bundle_im.ts");
|
let import = util::testdata_path().join("bundle_im.ts");
|
||||||
let import_map_path = util::testdata_path().join("bundle_im.json");
|
let import_map_path = util::testdata_path().join("bundle_im.json");
|
||||||
assert!(import.is_file());
|
assert!(import.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("import_map.bundle.js");
|
let bundle = t.path().join("import_map.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -306,7 +306,7 @@ fn bundle_import_map_no_check() {
|
||||||
let import = util::testdata_path().join("bundle_im.ts");
|
let import = util::testdata_path().join("bundle_im.ts");
|
||||||
let import_map_path = util::testdata_path().join("bundle_im.json");
|
let import_map_path = util::testdata_path().join("bundle_im.json");
|
||||||
assert!(import.is_file());
|
assert!(import.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("import_map.bundle.js");
|
let bundle = t.path().join("import_map.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -351,7 +351,7 @@ fn bundle_json_module() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let mod7 = util::testdata_path().join("subdir/mod7.js");
|
let mod7 = util::testdata_path().join("subdir/mod7.js");
|
||||||
assert!(mod7.is_file());
|
assert!(mod7.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("mod7.bundle.js");
|
let bundle = t.path().join("mod7.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -383,7 +383,7 @@ fn bundle_json_module_escape_sub() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let mod8 = util::testdata_path().join("subdir/mod8.js");
|
let mod8 = util::testdata_path().join("subdir/mod8.js");
|
||||||
assert!(mod8.is_file());
|
assert!(mod8.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("mod8.bundle.js");
|
let bundle = t.path().join("mod8.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
|
|
@ -54,10 +54,10 @@ itest!(ignore_require {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
#[test]
|
#[test]
|
||||||
fn relative_home_dir() {
|
fn relative_home_dir() {
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
let deno_dir = TempDir::new_in(util::testdata_path()).unwrap();
|
let deno_dir = TempDir::new_in(&util::testdata_path());
|
||||||
let path = deno_dir.path().strip_prefix(util::testdata_path()).unwrap();
|
let path = deno_dir.path().strip_prefix(util::testdata_path()).unwrap();
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd();
|
let mut deno_cmd = util::deno_cmd();
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compile() {
|
fn compile() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("welcome.exe")
|
dir.path().join("welcome.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,7 +38,7 @@ fn compile() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_args() {
|
fn standalone_args() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("args.exe")
|
dir.path().join("args.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,7 +74,7 @@ fn standalone_args() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_error() {
|
fn standalone_error() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("error.exe")
|
dir.path().join("error.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -116,7 +116,7 @@ fn standalone_error() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_error_module_with_imports() {
|
fn standalone_error_module_with_imports() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("error.exe")
|
dir.path().join("error.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -156,7 +156,7 @@ fn standalone_error_module_with_imports() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_load_datauri() {
|
fn standalone_load_datauri() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("load_datauri.exe")
|
dir.path().join("load_datauri.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -221,7 +221,7 @@ fn standalone_follow_redirects() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_compiler_ops() {
|
fn standalone_compiler_ops() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("standalone_compiler_ops.exe")
|
dir.path().join("standalone_compiler_ops.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -253,7 +253,7 @@ fn standalone_compiler_ops() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_with_directory_output_flag() {
|
fn compile_with_directory_output_flag() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let output_path = if cfg!(windows) {
|
let output_path = if cfg!(windows) {
|
||||||
dir.path().join(r"args\random\")
|
dir.path().join(r"args\random\")
|
||||||
} else {
|
} else {
|
||||||
|
@ -291,7 +291,7 @@ fn compile_with_directory_output_flag() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_with_file_exists_error() {
|
fn compile_with_file_exists_error() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let output_path = if cfg!(windows) {
|
let output_path = if cfg!(windows) {
|
||||||
dir.path().join(r"args\")
|
dir.path().join(r"args\")
|
||||||
} else {
|
} else {
|
||||||
|
@ -326,7 +326,7 @@ fn compile_with_file_exists_error() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_with_directory_exists_error() {
|
fn compile_with_directory_exists_error() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("args.exe")
|
dir.path().join("args.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -360,7 +360,7 @@ fn compile_with_directory_exists_error() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_with_conflict_file_exists_error() {
|
fn compile_with_conflict_file_exists_error() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("args.exe")
|
dir.path().join("args.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -398,7 +398,7 @@ fn compile_with_conflict_file_exists_error() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_and_overwrite_file() {
|
fn compile_and_overwrite_file() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("args.exe")
|
dir.path().join("args.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -436,7 +436,7 @@ fn compile_and_overwrite_file() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_runtime_flags() {
|
fn standalone_runtime_flags() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("flags.exe")
|
dir.path().join("flags.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -475,7 +475,7 @@ fn standalone_runtime_flags() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_import_map() {
|
fn standalone_import_map() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("import_map.exe")
|
dir.path().join("import_map.exe")
|
||||||
} else {
|
} else {
|
||||||
|
@ -510,7 +510,7 @@ fn standalone_import_map() {
|
||||||
#[test]
|
#[test]
|
||||||
// https://github.com/denoland/deno/issues/12670
|
// https://github.com/denoland/deno/issues/12670
|
||||||
fn skip_rebundle() {
|
fn skip_rebundle() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new();
|
||||||
let exe = if cfg!(windows) {
|
let exe = if cfg!(windows) {
|
||||||
dir.path().join("hello_world.exe")
|
dir.path().join("hello_world.exe")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn branch() {
|
fn branch() {
|
||||||
|
@ -20,11 +20,11 @@ fn final_blankline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_coverage_text(test_name: &str, extension: &str) {
|
fn run_coverage_text(test_name: &str, extension: &str) {
|
||||||
let deno_dir = TempDir::new().unwrap();
|
let deno_dir = TempDir::new();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new();
|
||||||
let tempdir = tempdir.path().join("cov");
|
let tempdir = tempdir.path().join("cov");
|
||||||
|
|
||||||
let status = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let status = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("test")
|
.arg("test")
|
||||||
.arg("--quiet")
|
.arg("--quiet")
|
||||||
|
@ -38,7 +38,7 @@ fn run_coverage_text(test_name: &str, extension: &str) {
|
||||||
|
|
||||||
assert!(status.success());
|
assert!(status.success());
|
||||||
|
|
||||||
let output = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let output = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("coverage")
|
.arg("coverage")
|
||||||
.arg("--unstable")
|
.arg("--unstable")
|
||||||
|
@ -68,7 +68,7 @@ fn run_coverage_text(test_name: &str, extension: &str) {
|
||||||
|
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
|
|
||||||
let output = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let output = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("coverage")
|
.arg("coverage")
|
||||||
.arg("--quiet")
|
.arg("--quiet")
|
||||||
|
@ -100,11 +100,11 @@ fn run_coverage_text(test_name: &str, extension: &str) {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multifile_coverage() {
|
fn multifile_coverage() {
|
||||||
let deno_dir = TempDir::new().unwrap();
|
let deno_dir = TempDir::new();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new();
|
||||||
let tempdir = tempdir.path().join("cov");
|
let tempdir = tempdir.path().join("cov");
|
||||||
|
|
||||||
let status = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let status = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("test")
|
.arg("test")
|
||||||
.arg("--quiet")
|
.arg("--quiet")
|
||||||
|
@ -118,7 +118,7 @@ fn multifile_coverage() {
|
||||||
|
|
||||||
assert!(status.success());
|
assert!(status.success());
|
||||||
|
|
||||||
let output = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let output = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("coverage")
|
.arg("coverage")
|
||||||
.arg("--unstable")
|
.arg("--unstable")
|
||||||
|
@ -148,7 +148,7 @@ fn multifile_coverage() {
|
||||||
|
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
|
|
||||||
let output = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let output = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("coverage")
|
.arg("coverage")
|
||||||
.arg("--quiet")
|
.arg("--quiet")
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::itest;
|
use crate::itest;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fmt_test() {
|
fn fmt_test() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let fixed_js = util::testdata_path().join("badly_formatted_fixed.js");
|
let fixed_js = util::testdata_path().join("badly_formatted_fixed.js");
|
||||||
let badly_formatted_original_js =
|
let badly_formatted_original_js =
|
||||||
util::testdata_path().join("badly_formatted.mjs");
|
util::testdata_path().join("badly_formatted.mjs");
|
||||||
|
@ -135,7 +135,8 @@ fn fmt_auto_ignore_git() {
|
||||||
let mut bad_json_file = File::create(bad_json_path).unwrap();
|
let mut bad_json_file = File::create(bad_json_path).unwrap();
|
||||||
writeln!(bad_json_file, "bad json").unwrap();
|
writeln!(bad_json_file, "bad json").unwrap();
|
||||||
}
|
}
|
||||||
let t = TempDir::new().unwrap().path().join("target");
|
let temp_dir = TempDir::new();
|
||||||
|
let t = temp_dir.path().join("target");
|
||||||
let nest_git = t.join("nest").join(".git");
|
let nest_git = t.join("nest").join(".git");
|
||||||
let git_dir = t.join(".git");
|
let git_dir = t.join(".git");
|
||||||
create_dir_all(&nest_git).unwrap();
|
create_dir_all(&nest_git).unwrap();
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::itest;
|
use crate::itest;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn info_with_compiled_source() {
|
fn info_with_compiled_source() {
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let module_path = "http://127.0.0.1:4545/048_media_types_jsx.ts";
|
let module_path = "http://127.0.0.1:4545/048_media_types_jsx.ts";
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
|
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.env("DENO_DIR", t.path())
|
.env("DENO_DIR", t.path())
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_basic() {
|
fn install_basic() {
|
||||||
let _guard = util::http_server();
|
let _guard = util::http_server();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let temp_dir_str = temp_dir.path().to_string_lossy().to_string();
|
let temp_dir_str = temp_dir.path().to_string_lossy().to_string();
|
||||||
|
|
||||||
let status = util::deno_cmd()
|
let status = util::deno_cmd()
|
||||||
|
@ -50,7 +50,7 @@ fn install_basic() {
|
||||||
#[test]
|
#[test]
|
||||||
fn install_custom_dir_env_var() {
|
fn install_custom_dir_env_var() {
|
||||||
let _guard = util::http_server();
|
let _guard = util::http_server();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let temp_dir_str = temp_dir.path().to_string_lossy().to_string();
|
let temp_dir_str = temp_dir.path().to_string_lossy().to_string();
|
||||||
|
|
||||||
let status = util::deno_cmd()
|
let status = util::deno_cmd()
|
||||||
|
@ -87,7 +87,7 @@ fn install_custom_dir_env_var() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn installer_test_local_module_run() {
|
fn installer_test_local_module_run() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
let status = util::deno_cmd()
|
let status = util::deno_cmd()
|
||||||
|
@ -124,7 +124,7 @@ fn installer_test_local_module_run() {
|
||||||
#[test]
|
#[test]
|
||||||
fn installer_test_remote_module_run() {
|
fn installer_test_remote_module_run() {
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
let status = util::deno_cmd()
|
let status = util::deno_cmd()
|
||||||
|
|
|
@ -12,11 +12,11 @@ use lspower::lsp;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util::deno_exe_path;
|
use test_util::deno_exe_path;
|
||||||
use test_util::http_server;
|
use test_util::http_server;
|
||||||
use test_util::lsp::LspClient;
|
use test_util::lsp::LspClient;
|
||||||
use test_util::testdata_path;
|
use test_util::testdata_path;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
fn load_fixture(path: &str) -> Value {
|
fn load_fixture(path: &str) -> Value {
|
||||||
load_fixture_as(path)
|
load_fixture_as(path)
|
||||||
|
@ -233,7 +233,7 @@ fn lsp_startup_shutdown() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_init_tsconfig() {
|
fn lsp_init_tsconfig() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let tsconfig =
|
let tsconfig =
|
||||||
|
@ -276,7 +276,7 @@ fn lsp_init_tsconfig() {
|
||||||
fn lsp_tsconfig_types() {
|
fn lsp_tsconfig_types() {
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let tsconfig =
|
let tsconfig =
|
||||||
serde_json::to_vec_pretty(&load_fixture("types.tsconfig.json")).unwrap();
|
serde_json::to_vec_pretty(&load_fixture("types.tsconfig.json")).unwrap();
|
||||||
fs::write(temp_dir.path().join("types.tsconfig.json"), tsconfig).unwrap();
|
fs::write(temp_dir.path().join("types.tsconfig.json"), tsconfig).unwrap();
|
||||||
|
@ -341,9 +341,9 @@ fn lsp_tsconfig_bad_config_path() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_triple_slash_types() {
|
fn lsp_triple_slash_types() {
|
||||||
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
|
||||||
let a_dts = load_fixture_str("a.d.ts");
|
let a_dts = load_fixture_str("a.d.ts");
|
||||||
fs::write(temp_dir.path().join("a.d.ts"), a_dts).unwrap();
|
fs::write(temp_dir.path().join("a.d.ts"), a_dts).unwrap();
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ fn lsp_triple_slash_types() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_import_map() {
|
fn lsp_import_map() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let import_map =
|
let import_map =
|
||||||
|
@ -488,7 +488,7 @@ fn lsp_import_map_data_url() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_import_map_config_file() {
|
fn lsp_import_map_config_file() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ fn lsp_import_map_config_file() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_deno_task() {
|
fn lsp_deno_task() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let workspace_root = temp_dir.path().canonicalize().unwrap();
|
let workspace_root = temp_dir.path().canonicalize().unwrap();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
|
@ -704,7 +704,7 @@ fn lsp_import_assertions() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_import_map_import_completions() {
|
fn lsp_import_map_import_completions() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let import_map =
|
let import_map =
|
||||||
|
@ -1073,7 +1073,7 @@ fn lsp_workspace_enable_paths() {
|
||||||
// we aren't actually writing anything to the tempdir in this test, but we
|
// we aren't actually writing anything to the tempdir in this test, but we
|
||||||
// just need a legitimate file path on the host system so that logic that
|
// just need a legitimate file path on the host system so that logic that
|
||||||
// tries to convert to and from the fs paths works on all env
|
// tries to convert to and from the fs paths works on all env
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
|
|
||||||
let root_specifier =
|
let root_specifier =
|
||||||
ensure_directory_specifier(Url::from_file_path(temp_dir.path()).unwrap());
|
ensure_directory_specifier(Url::from_file_path(temp_dir.path()).unwrap());
|
||||||
|
@ -1458,7 +1458,8 @@ fn lsp_hover_change_mbc() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_hover_closed_document() {
|
fn lsp_hover_closed_document() {
|
||||||
let temp_dir = TempDir::new().unwrap().into_path();
|
let temp_dir_guard = TempDir::new();
|
||||||
|
let temp_dir = temp_dir_guard.path();
|
||||||
let a_path = temp_dir.join("a.ts");
|
let a_path = temp_dir.join("a.ts");
|
||||||
fs::write(a_path, r#"export const a = "a";"#).unwrap();
|
fs::write(a_path, r#"export const a = "a";"#).unwrap();
|
||||||
let b_path = temp_dir.join("b.ts");
|
let b_path = temp_dir.join("b.ts");
|
||||||
|
@ -3669,7 +3670,7 @@ fn lsp_auto_discover_registry() {
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_cache_location() {
|
fn lsp_cache_location() {
|
||||||
let _g = http_server();
|
let _g = http_server();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params_registry.json"))
|
serde_json::from_value(load_fixture("initialize_params_registry.json"))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -4395,7 +4396,7 @@ fn lsp_format_mbc() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_format_exclude_with_config() {
|
fn lsp_format_exclude_with_config() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let deno_fmt_jsonc =
|
let deno_fmt_jsonc =
|
||||||
|
@ -4450,7 +4451,7 @@ fn lsp_format_exclude_with_config() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_format_exclude_default_config() {
|
fn lsp_format_exclude_default_config() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let workspace_root = temp_dir.path().canonicalize().unwrap();
|
let workspace_root = temp_dir.path().canonicalize().unwrap();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
|
@ -4675,7 +4676,7 @@ fn lsp_format_markdown() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_format_with_config() {
|
fn lsp_format_with_config() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let deno_fmt_jsonc =
|
let deno_fmt_jsonc =
|
||||||
|
@ -5154,7 +5155,7 @@ console.log(snake_case);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_lint_with_config() {
|
fn lsp_lint_with_config() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let deno_lint_jsonc =
|
let deno_lint_jsonc =
|
||||||
|
@ -5186,7 +5187,7 @@ fn lsp_lint_with_config() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_lint_exclude_with_config() {
|
fn lsp_lint_exclude_with_config() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let deno_lint_jsonc =
|
let deno_lint_jsonc =
|
||||||
|
@ -5346,7 +5347,7 @@ struct TestRunResponseParams {
|
||||||
fn lsp_testing_api() {
|
fn lsp_testing_api() {
|
||||||
let mut params: lsp::InitializeParams =
|
let mut params: lsp::InitializeParams =
|
||||||
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
|
|
||||||
let root_specifier =
|
let root_specifier =
|
||||||
ensure_directory_specifier(Url::from_file_path(temp_dir.path()).unwrap());
|
ensure_directory_specifier(Url::from_file_path(temp_dir.path()).unwrap());
|
||||||
|
|
|
@ -12,8 +12,8 @@ use std::io::Cursor;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
use tokio::task::LocalSet;
|
use tokio::task::LocalSet;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
@ -139,7 +139,7 @@ itest!(types {
|
||||||
#[test]
|
#[test]
|
||||||
fn cache_test() {
|
fn cache_test() {
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
let deno_dir = TempDir::new();
|
||||||
let module_url =
|
let module_url =
|
||||||
url::Url::parse("http://localhost:4545/006_url_imports.ts").unwrap();
|
url::Url::parse("http://localhost:4545/006_url_imports.ts").unwrap();
|
||||||
let output = Command::new(util::deno_exe_path())
|
let output = Command::new(util::deno_exe_path())
|
||||||
|
@ -184,7 +184,7 @@ fn cache_test() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cache_invalidation_test() {
|
fn cache_invalidation_test() {
|
||||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
let deno_dir = TempDir::new();
|
||||||
let fixture_path = deno_dir.path().join("fixture.ts");
|
let fixture_path = deno_dir.path().join("fixture.ts");
|
||||||
{
|
{
|
||||||
let mut file = std::fs::File::create(fixture_path.clone())
|
let mut file = std::fs::File::create(fixture_path.clone())
|
||||||
|
@ -224,7 +224,7 @@ fn cache_invalidation_test() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cache_invalidation_test_no_check() {
|
fn cache_invalidation_test_no_check() {
|
||||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
let deno_dir = TempDir::new();
|
||||||
let fixture_path = deno_dir.path().join("fixture.ts");
|
let fixture_path = deno_dir.path().join("fixture.ts");
|
||||||
{
|
{
|
||||||
let mut file = std::fs::File::create(fixture_path.clone())
|
let mut file = std::fs::File::create(fixture_path.clone())
|
||||||
|
@ -266,7 +266,7 @@ fn cache_invalidation_test_no_check() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ts_dependency_recompilation() {
|
fn ts_dependency_recompilation() {
|
||||||
let t = TempDir::new().expect("tempdir fail");
|
let t = TempDir::new();
|
||||||
let ats = t.path().join("a.ts");
|
let ats = t.path().join("a.ts");
|
||||||
|
|
||||||
std::fs::write(
|
std::fs::write(
|
||||||
|
@ -365,8 +365,8 @@ fn ts_reload() {
|
||||||
let hello_ts = util::testdata_path().join("002_hello.ts");
|
let hello_ts = util::testdata_path().join("002_hello.ts");
|
||||||
assert!(hello_ts.is_file());
|
assert!(hello_ts.is_file());
|
||||||
|
|
||||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
let deno_dir = TempDir::new();
|
||||||
let mut initial = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let mut initial = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("cache")
|
.arg("cache")
|
||||||
.arg(&hello_ts)
|
.arg(&hello_ts)
|
||||||
|
@ -376,7 +376,7 @@ fn ts_reload() {
|
||||||
initial.wait().expect("failed to wait for child process");
|
initial.wait().expect("failed to wait for child process");
|
||||||
assert!(status_initial.success());
|
assert!(status_initial.success());
|
||||||
|
|
||||||
let output = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let output = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("cache")
|
.arg("cache")
|
||||||
.arg("--reload")
|
.arg("--reload")
|
||||||
|
@ -539,7 +539,7 @@ itest!(localhost_unsafe_ssl {
|
||||||
fn cafile_env_fetch() {
|
fn cafile_env_fetch() {
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
let deno_dir = TempDir::new();
|
||||||
let module_url =
|
let module_url =
|
||||||
Url::parse("https://localhost:5545/cafile_url_imports.ts").unwrap();
|
Url::parse("https://localhost:5545/cafile_url_imports.ts").unwrap();
|
||||||
let cafile = util::testdata_path().join("tls/RootCA.pem");
|
let cafile = util::testdata_path().join("tls/RootCA.pem");
|
||||||
|
@ -558,7 +558,7 @@ fn cafile_env_fetch() {
|
||||||
fn cafile_fetch() {
|
fn cafile_fetch() {
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
let deno_dir = TempDir::new();
|
||||||
let module_url =
|
let module_url =
|
||||||
Url::parse("http://localhost:4545/cafile_url_imports.ts").unwrap();
|
Url::parse("http://localhost:4545/cafile_url_imports.ts").unwrap();
|
||||||
let cafile = util::testdata_path().join("tls/RootCA.pem");
|
let cafile = util::testdata_path().join("tls/RootCA.pem");
|
||||||
|
@ -579,10 +579,10 @@ fn cafile_fetch() {
|
||||||
#[flaky_test::flaky_test]
|
#[flaky_test::flaky_test]
|
||||||
fn cafile_install_remote_module() {
|
fn cafile_install_remote_module() {
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let temp_dir = TempDir::new().expect("tempdir fail");
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
let deno_dir = TempDir::new();
|
||||||
let cafile = util::testdata_path().join("tls/RootCA.pem");
|
let cafile = util::testdata_path().join("tls/RootCA.pem");
|
||||||
|
|
||||||
let install_output = Command::new(util::deno_exe_path())
|
let install_output = Command::new(util::deno_exe_path())
|
||||||
|
@ -625,7 +625,7 @@ fn cafile_bundle_remote_exports() {
|
||||||
// First we have to generate a bundle of some remote module that has exports.
|
// First we have to generate a bundle of some remote module that has exports.
|
||||||
let mod1 = "https://localhost:5545/subdir/mod1.ts";
|
let mod1 = "https://localhost:5545/subdir/mod1.ts";
|
||||||
let cafile = util::testdata_path().join("tls/RootCA.pem");
|
let cafile = util::testdata_path().join("tls/RootCA.pem");
|
||||||
let t = TempDir::new().expect("tempdir fail");
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("mod1.bundle.js");
|
let bundle = t.path().join("mod1.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -1095,7 +1095,7 @@ fn typecheck_declarations_unstable() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn typecheck_core() {
|
fn typecheck_core() {
|
||||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
let deno_dir = TempDir::new();
|
||||||
let test_file = deno_dir.path().join("test_deno_core_types.ts");
|
let test_file = deno_dir.path().join("test_deno_core_types.ts");
|
||||||
std::fs::write(
|
std::fs::write(
|
||||||
&test_file,
|
&test_file,
|
||||||
|
@ -1111,7 +1111,7 @@ fn typecheck_core() {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let output = util::deno_cmd_with_deno_dir(deno_dir.path())
|
let output = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||||
.arg("run")
|
.arg("run")
|
||||||
.arg(test_file.to_str().unwrap())
|
.arg(test_file.to_str().unwrap())
|
||||||
.output()
|
.output()
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
use deno_core::url;
|
use deno_core::url;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
itest!(stdout_write_all {
|
itest!(stdout_write_all {
|
||||||
args: "run --quiet stdout_write_all.ts",
|
args: "run --quiet stdout_write_all.ts",
|
||||||
|
@ -253,7 +253,7 @@ itest!(webstorage_serialization {
|
||||||
fn webstorage_location_shares_origin() {
|
fn webstorage_location_shares_origin() {
|
||||||
let deno_dir = util::new_deno_dir();
|
let deno_dir = util::new_deno_dir();
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -268,7 +268,7 @@ fn webstorage_location_shares_origin() {
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -290,7 +290,7 @@ fn webstorage_location_shares_origin() {
|
||||||
fn webstorage_config_file() {
|
fn webstorage_config_file() {
|
||||||
let deno_dir = util::new_deno_dir();
|
let deno_dir = util::new_deno_dir();
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -305,7 +305,7 @@ fn webstorage_config_file() {
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -320,7 +320,7 @@ fn webstorage_config_file() {
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -342,7 +342,7 @@ fn webstorage_config_file() {
|
||||||
fn webstorage_location_precedes_config() {
|
fn webstorage_location_precedes_config() {
|
||||||
let deno_dir = util::new_deno_dir();
|
let deno_dir = util::new_deno_dir();
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -359,7 +359,7 @@ fn webstorage_location_precedes_config() {
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -383,7 +383,7 @@ fn webstorage_location_precedes_config() {
|
||||||
fn webstorage_main_module() {
|
fn webstorage_main_module() {
|
||||||
let deno_dir = util::new_deno_dir();
|
let deno_dir = util::new_deno_dir();
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -396,7 +396,7 @@ fn webstorage_main_module() {
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -409,7 +409,7 @@ fn webstorage_main_module() {
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
assert_eq!(output.stdout, b"Storage { length: 0 }\n");
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -466,7 +466,7 @@ itest!(_082_prepare_stack_trace_throw {
|
||||||
#[test]
|
#[test]
|
||||||
fn _083_legacy_external_source_map() {
|
fn _083_legacy_external_source_map() {
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let deno_dir = TempDir::new().unwrap();
|
let deno_dir = TempDir::new();
|
||||||
let module_url =
|
let module_url =
|
||||||
url::Url::parse("http://localhost:4545/083_legacy_external_source_map.ts")
|
url::Url::parse("http://localhost:4545/083_legacy_external_source_map.ts")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -1804,7 +1804,7 @@ fn rust_log() {
|
||||||
fn dont_cache_on_check_fail() {
|
fn dont_cache_on_check_fail() {
|
||||||
let deno_dir = util::new_deno_dir();
|
let deno_dir = util::new_deno_dir();
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -1818,7 +1818,7 @@ fn dont_cache_on_check_fail() {
|
||||||
assert!(!output.status.success());
|
assert!(!output.status.success());
|
||||||
assert!(!output.stderr.is_empty());
|
assert!(!output.stderr.is_empty());
|
||||||
|
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let output = deno_cmd
|
let output = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -2368,7 +2368,7 @@ itest!(eval_context_throw_dom_exception {
|
||||||
fn issue12453() {
|
fn issue12453() {
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
let deno_dir = util::new_deno_dir();
|
let deno_dir = util::new_deno_dir();
|
||||||
let mut deno_cmd = util::deno_cmd_with_deno_dir(deno_dir.path());
|
let mut deno_cmd = util::deno_cmd_with_deno_dir(&deno_dir);
|
||||||
let status = deno_cmd
|
let status = deno_cmd
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
@ -2385,7 +2385,7 @@ fn issue12453() {
|
||||||
/// Regression test for https://github.com/denoland/deno/issues/12740.
|
/// Regression test for https://github.com/denoland/deno/issues/12740.
|
||||||
#[test]
|
#[test]
|
||||||
fn issue12740() {
|
fn issue12740() {
|
||||||
let mod_dir = TempDir::new().unwrap();
|
let mod_dir = TempDir::new();
|
||||||
let mod1_path = mod_dir.path().join("mod1.ts");
|
let mod1_path = mod_dir.path().join("mod1.ts");
|
||||||
let mod2_path = mod_dir.path().join("mod2.ts");
|
let mod2_path = mod_dir.path().join("mod2.ts");
|
||||||
let mut deno_cmd = util::deno_cmd();
|
let mut deno_cmd = util::deno_cmd();
|
||||||
|
@ -2419,7 +2419,7 @@ fn issue12740() {
|
||||||
/// Regression test for https://github.com/denoland/deno/issues/12807.
|
/// Regression test for https://github.com/denoland/deno/issues/12807.
|
||||||
#[test]
|
#[test]
|
||||||
fn issue12807() {
|
fn issue12807() {
|
||||||
let mod_dir = TempDir::new().unwrap();
|
let mod_dir = TempDir::new();
|
||||||
let mod1_path = mod_dir.path().join("mod1.ts");
|
let mod1_path = mod_dir.path().join("mod1.ts");
|
||||||
let mod2_path = mod_dir.path().join("mod2.ts");
|
let mod2_path = mod_dir.path().join("mod2.ts");
|
||||||
let mut deno_cmd = util::deno_cmd();
|
let mut deno_cmd = util::deno_cmd();
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
// Warning: this test requires internet access.
|
// Warning: this test requires internet access.
|
||||||
// TODO(#7412): reenable. test is flaky
|
// TODO(#7412): reenable. test is flaky
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn upgrade_in_tmpdir() {
|
fn upgrade_in_tmpdir() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let exe_path = temp_dir.path().join("deno");
|
let exe_path = temp_dir.path().join("deno");
|
||||||
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
||||||
assert!(exe_path.exists());
|
assert!(exe_path.exists());
|
||||||
|
@ -31,10 +31,7 @@ fn upgrade_in_tmpdir() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn upgrade_with_space_in_path() {
|
fn upgrade_with_space_in_path() {
|
||||||
let temp_dir = tempfile::Builder::new()
|
let temp_dir = TempDir::new_with_prefix("directory with spaces");
|
||||||
.prefix("directory with spaces")
|
|
||||||
.tempdir()
|
|
||||||
.unwrap();
|
|
||||||
let exe_path = temp_dir.path().join("deno");
|
let exe_path = temp_dir.path().join("deno");
|
||||||
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
||||||
assert!(exe_path.exists());
|
assert!(exe_path.exists());
|
||||||
|
@ -54,7 +51,7 @@ fn upgrade_with_space_in_path() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn upgrade_with_version_in_tmpdir() {
|
fn upgrade_with_version_in_tmpdir() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let exe_path = temp_dir.path().join("deno");
|
let exe_path = temp_dir.path().join("deno");
|
||||||
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
||||||
assert!(exe_path.exists());
|
assert!(exe_path.exists());
|
||||||
|
@ -83,7 +80,7 @@ fn upgrade_with_version_in_tmpdir() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn upgrade_with_canary_in_tmpdir() {
|
fn upgrade_with_canary_in_tmpdir() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let exe_path = temp_dir.path().join("deno");
|
let exe_path = temp_dir.path().join("deno");
|
||||||
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
||||||
assert!(exe_path.exists());
|
assert!(exe_path.exists());
|
||||||
|
@ -112,7 +109,7 @@ fn upgrade_with_canary_in_tmpdir() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn upgrade_with_out_in_tmpdir() {
|
fn upgrade_with_out_in_tmpdir() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let exe_path = temp_dir.path().join("deno");
|
let exe_path = temp_dir.path().join("deno");
|
||||||
let new_exe_path = temp_dir.path().join("foo");
|
let new_exe_path = temp_dir.path().join("foo");
|
||||||
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
||||||
|
@ -149,7 +146,7 @@ fn upgrade_with_out_in_tmpdir() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn upgrade_invalid_stable_version() {
|
fn upgrade_invalid_stable_version() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let exe_path = temp_dir.path().join("deno");
|
let exe_path = temp_dir.path().join("deno");
|
||||||
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
||||||
assert!(exe_path.exists());
|
assert!(exe_path.exists());
|
||||||
|
@ -174,7 +171,7 @@ fn upgrade_invalid_stable_version() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn upgrade_invalid_canary_version() {
|
fn upgrade_invalid_canary_version() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let exe_path = temp_dir.path().join("deno");
|
let exe_path = temp_dir.path().join("deno");
|
||||||
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap();
|
||||||
assert!(exe_path.exists());
|
assert!(exe_path.exists());
|
||||||
|
|
|
@ -6,13 +6,13 @@ use pretty_assertions::assert_eq;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
use util::http_server;
|
use util::http_server;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn output_dir_exists() {
|
fn output_dir_exists() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let vendor_dir = t.path().join("vendor");
|
let vendor_dir = t.path().join("vendor");
|
||||||
fs::write(t.path().join("mod.ts"), "").unwrap();
|
fs::write(t.path().join("mod.ts"), "").unwrap();
|
||||||
fs::create_dir_all(&vendor_dir).unwrap();
|
fs::create_dir_all(&vendor_dir).unwrap();
|
||||||
|
@ -75,7 +75,7 @@ fn output_dir_exists() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn import_map_output_dir() {
|
fn import_map_output_dir() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let vendor_dir = t.path().join("vendor");
|
let vendor_dir = t.path().join("vendor");
|
||||||
fs::write(t.path().join("mod.ts"), "").unwrap();
|
fs::write(t.path().join("mod.ts"), "").unwrap();
|
||||||
fs::create_dir_all(&vendor_dir).unwrap();
|
fs::create_dir_all(&vendor_dir).unwrap();
|
||||||
|
@ -109,7 +109,7 @@ fn import_map_output_dir() {
|
||||||
#[test]
|
#[test]
|
||||||
fn standard_test() {
|
fn standard_test() {
|
||||||
let _server = http_server();
|
let _server = http_server();
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let vendor_dir = t.path().join("vendor2");
|
let vendor_dir = t.path().join("vendor2");
|
||||||
fs::write(
|
fs::write(
|
||||||
t.path().join("my_app.ts"),
|
t.path().join("my_app.ts"),
|
||||||
|
@ -186,7 +186,7 @@ fn standard_test() {
|
||||||
#[test]
|
#[test]
|
||||||
fn remote_module_test() {
|
fn remote_module_test() {
|
||||||
let _server = http_server();
|
let _server = http_server();
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let vendor_dir = t.path().join("vendor");
|
let vendor_dir = t.path().join("vendor");
|
||||||
|
|
||||||
let deno = util::deno_cmd()
|
let deno = util::deno_cmd()
|
||||||
|
@ -239,7 +239,7 @@ fn remote_module_test() {
|
||||||
#[test]
|
#[test]
|
||||||
fn existing_import_map() {
|
fn existing_import_map() {
|
||||||
let _server = http_server();
|
let _server = http_server();
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let vendor_dir = t.path().join("vendor");
|
let vendor_dir = t.path().join("vendor");
|
||||||
fs::write(
|
fs::write(
|
||||||
t.path().join("mod.ts"),
|
t.path().join("mod.ts"),
|
||||||
|
@ -274,7 +274,7 @@ fn existing_import_map() {
|
||||||
#[test]
|
#[test]
|
||||||
fn dynamic_import() {
|
fn dynamic_import() {
|
||||||
let _server = http_server();
|
let _server = http_server();
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let vendor_dir = t.path().join("vendor");
|
let vendor_dir = t.path().join("vendor");
|
||||||
fs::write(
|
fs::write(
|
||||||
t.path().join("mod.ts"),
|
t.path().join("mod.ts"),
|
||||||
|
@ -327,7 +327,7 @@ fn dynamic_import() {
|
||||||
#[test]
|
#[test]
|
||||||
fn dynamic_non_analyzable_import() {
|
fn dynamic_non_analyzable_import() {
|
||||||
let _server = http_server();
|
let _server = http_server();
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
fs::write(
|
fs::write(
|
||||||
t.path().join("mod.ts"),
|
t.path().join("mod.ts"),
|
||||||
"import {Logger} from 'http://localhost:4545/vendor/dynamic_non_analyzable.ts'; new Logger().log('outputted');",
|
"import {Logger} from 'http://localhost:4545/vendor/dynamic_non_analyzable.ts'; new Logger().log('outputted');",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
use flaky_test::flaky_test;
|
use flaky_test::flaky_test;
|
||||||
use std::fs::write;
|
use std::fs::write;
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
const CLEAR_SCREEN: &str = r#"[2J"#;
|
const CLEAR_SCREEN: &str = r#"[2J"#;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ fn child_lines(
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lint_watch_test() {
|
fn lint_watch_test() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let badly_linted_original =
|
let badly_linted_original =
|
||||||
util::testdata_path().join("lint/watch/badly_linted.js");
|
util::testdata_path().join("lint/watch/badly_linted.js");
|
||||||
let badly_linted_output =
|
let badly_linted_output =
|
||||||
|
@ -147,7 +147,7 @@ fn lint_watch_test() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lint_watch_without_args_test() {
|
fn lint_watch_without_args_test() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let badly_linted_original =
|
let badly_linted_original =
|
||||||
util::testdata_path().join("lint/watch/badly_linted.js");
|
util::testdata_path().join("lint/watch/badly_linted.js");
|
||||||
let badly_linted_output =
|
let badly_linted_output =
|
||||||
|
@ -206,7 +206,7 @@ fn lint_watch_without_args_test() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lint_all_files_on_each_change_test() {
|
fn lint_all_files_on_each_change_test() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let badly_linted_fixed0 =
|
let badly_linted_fixed0 =
|
||||||
util::testdata_path().join("lint/watch/badly_linted.js");
|
util::testdata_path().join("lint/watch/badly_linted.js");
|
||||||
let badly_linted_fixed1 =
|
let badly_linted_fixed1 =
|
||||||
|
@ -245,7 +245,7 @@ fn lint_all_files_on_each_change_test() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fmt_watch_test() {
|
fn fmt_watch_test() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let fixed = util::testdata_path().join("badly_formatted_fixed.js");
|
let fixed = util::testdata_path().join("badly_formatted_fixed.js");
|
||||||
let badly_formatted_original =
|
let badly_formatted_original =
|
||||||
util::testdata_path().join("badly_formatted.mjs");
|
util::testdata_path().join("badly_formatted.mjs");
|
||||||
|
@ -295,7 +295,7 @@ fn fmt_watch_test() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fmt_watch_without_args_test() {
|
fn fmt_watch_without_args_test() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let fixed = util::testdata_path().join("badly_formatted_fixed.js");
|
let fixed = util::testdata_path().join("badly_formatted_fixed.js");
|
||||||
let badly_formatted_original =
|
let badly_formatted_original =
|
||||||
util::testdata_path().join("badly_formatted.mjs");
|
util::testdata_path().join("badly_formatted.mjs");
|
||||||
|
@ -343,7 +343,7 @@ fn fmt_watch_without_args_test() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fmt_check_all_files_on_each_change_test() {
|
fn fmt_check_all_files_on_each_change_test() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let badly_formatted_original =
|
let badly_formatted_original =
|
||||||
util::testdata_path().join("badly_formatted.mjs");
|
util::testdata_path().join("badly_formatted.mjs");
|
||||||
let badly_formatted_1 = t.path().join("badly_formatted_1.js");
|
let badly_formatted_1 = t.path().join("badly_formatted_1.js");
|
||||||
|
@ -384,11 +384,11 @@ fn fmt_check_all_files_on_each_change_test() {
|
||||||
fn bundle_js_watch() {
|
fn bundle_js_watch() {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
// Test strategy extends this of test bundle_js by adding watcher
|
// Test strategy extends this of test bundle_js by adding watcher
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let file_to_watch = t.path().join("file_to_watch.ts");
|
let file_to_watch = t.path().join("file_to_watch.ts");
|
||||||
write(&file_to_watch, "console.log('Hello world');").unwrap();
|
write(&file_to_watch, "console.log('Hello world');").unwrap();
|
||||||
assert!(file_to_watch.is_file());
|
assert!(file_to_watch.is_file());
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("mod6.bundle.js");
|
let bundle = t.path().join("mod6.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
let mut deno = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -439,7 +439,7 @@ fn bundle_js_watch() {
|
||||||
/// Confirm that the watcher continues to work even if module resolution fails at the *first* attempt
|
/// Confirm that the watcher continues to work even if module resolution fails at the *first* attempt
|
||||||
#[test]
|
#[test]
|
||||||
fn bundle_watch_not_exit() {
|
fn bundle_watch_not_exit() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let file_to_watch = t.path().join("file_to_watch.ts");
|
let file_to_watch = t.path().join("file_to_watch.ts");
|
||||||
write(&file_to_watch, "syntax error ^^").unwrap();
|
write(&file_to_watch, "syntax error ^^").unwrap();
|
||||||
let target_file = t.path().join("target.js");
|
let target_file = t.path().join("target.js");
|
||||||
|
@ -485,7 +485,7 @@ fn bundle_watch_not_exit() {
|
||||||
|
|
||||||
#[flaky_test::flaky_test]
|
#[flaky_test::flaky_test]
|
||||||
fn run_watch() {
|
fn run_watch() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let file_to_watch = t.path().join("file_to_watch.js");
|
let file_to_watch = t.path().join("file_to_watch.js");
|
||||||
write(&file_to_watch, "console.log('Hello world');").unwrap();
|
write(&file_to_watch, "console.log('Hello world');").unwrap();
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ fn run_watch() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn run_watch_external_watch_files() {
|
fn run_watch_external_watch_files() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let file_to_watch = t.path().join("file_to_watch.js");
|
let file_to_watch = t.path().join("file_to_watch.js");
|
||||||
write(&file_to_watch, "console.log('Hello world');").unwrap();
|
write(&file_to_watch, "console.log('Hello world');").unwrap();
|
||||||
|
|
||||||
|
@ -609,7 +609,7 @@ fn run_watch_external_watch_files() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn run_watch_load_unload_events() {
|
fn run_watch_load_unload_events() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let file_to_watch = t.path().join("file_to_watch.js");
|
let file_to_watch = t.path().join("file_to_watch.js");
|
||||||
write(
|
write(
|
||||||
&file_to_watch,
|
&file_to_watch,
|
||||||
|
@ -677,7 +677,7 @@ fn run_watch_load_unload_events() {
|
||||||
/// Confirm that the watcher continues to work even if module resolution fails at the *first* attempt
|
/// Confirm that the watcher continues to work even if module resolution fails at the *first* attempt
|
||||||
#[test]
|
#[test]
|
||||||
fn run_watch_not_exit() {
|
fn run_watch_not_exit() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let file_to_watch = t.path().join("file_to_watch.js");
|
let file_to_watch = t.path().join("file_to_watch.js");
|
||||||
write(&file_to_watch, "syntax error ^^").unwrap();
|
write(&file_to_watch, "syntax error ^^").unwrap();
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ fn run_watch_with_import_map_and_relative_paths() {
|
||||||
assert!(relative_path.is_relative());
|
assert!(relative_path.is_relative());
|
||||||
relative_path
|
relative_path
|
||||||
}
|
}
|
||||||
let temp_directory = TempDir::new_in(util::testdata_path()).unwrap();
|
let temp_directory = TempDir::new_in(&util::testdata_path());
|
||||||
let file_to_watch = create_relative_tmp_file(
|
let file_to_watch = create_relative_tmp_file(
|
||||||
&temp_directory,
|
&temp_directory,
|
||||||
"file_to_watch.js",
|
"file_to_watch.js",
|
||||||
|
@ -764,7 +764,7 @@ fn run_watch_with_import_map_and_relative_paths() {
|
||||||
|
|
||||||
#[flaky_test]
|
#[flaky_test]
|
||||||
fn test_watch() {
|
fn test_watch() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
|
|
||||||
let mut child = util::deno_cmd()
|
let mut child = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -908,7 +908,7 @@ fn test_watch() {
|
||||||
|
|
||||||
#[flaky_test]
|
#[flaky_test]
|
||||||
fn test_watch_doc() {
|
fn test_watch_doc() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
|
|
||||||
let mut child = util::deno_cmd()
|
let mut child = util::deno_cmd()
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
|
@ -961,7 +961,7 @@ fn test_watch_doc() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_watch_module_graph_error_referrer() {
|
fn test_watch_module_graph_error_referrer() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let file_to_watch = t.path().join("file_to_watch.js");
|
let file_to_watch = t.path().join("file_to_watch.js");
|
||||||
write(&file_to_watch, "import './nonexistent.js';").unwrap();
|
write(&file_to_watch, "import './nonexistent.js';").unwrap();
|
||||||
let mut child = util::deno_cmd()
|
let mut child = util::deno_cmd()
|
||||||
|
@ -991,7 +991,7 @@ fn test_watch_module_graph_error_referrer() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn watch_with_no_clear_screen_flag() {
|
fn watch_with_no_clear_screen_flag() {
|
||||||
let t = TempDir::new().unwrap();
|
let t = TempDir::new();
|
||||||
let file_to_watch = t.path().join("file_to_watch.js");
|
let file_to_watch = t.path().join("file_to_watch.js");
|
||||||
write(&file_to_watch, "export const foo = 0;").unwrap();
|
write(&file_to_watch, "export const foo = 0;").unwrap();
|
||||||
|
|
||||||
|
|
|
@ -401,8 +401,8 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tempfile::TempDir;
|
|
||||||
use test_util::testdata_path;
|
use test_util::testdata_path;
|
||||||
|
use test_util::TempDir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_infer_name_from_url() {
|
fn install_infer_name_from_url() {
|
||||||
|
@ -479,7 +479,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_unstable() {
|
fn install_unstable() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
|
|
||||||
|
@ -663,7 +663,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_local_module() {
|
fn install_local_module() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
let local_module = env::current_dir().unwrap().join("echo_server.ts");
|
let local_module = env::current_dir().unwrap().join("echo_server.ts");
|
||||||
|
@ -694,7 +694,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_force() {
|
fn install_force() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
|
|
||||||
|
@ -755,7 +755,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_with_config() {
|
fn install_with_config() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
let config_file_path = temp_dir.path().join("test_tsconfig.json");
|
let config_file_path = temp_dir.path().join("test_tsconfig.json");
|
||||||
let config = "{}";
|
let config = "{}";
|
||||||
|
@ -791,7 +791,7 @@ mod tests {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
#[test]
|
#[test]
|
||||||
fn install_shell_escaping() {
|
fn install_shell_escaping() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
|
|
||||||
|
@ -826,7 +826,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_unicode() {
|
fn install_unicode() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
let unicode_dir = temp_dir.path().join("Magnús");
|
let unicode_dir = temp_dir.path().join("Magnús");
|
||||||
|
@ -866,7 +866,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_with_import_map() {
|
fn install_with_import_map() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
let import_map_path = temp_dir.path().join("import_map.json");
|
let import_map_path = temp_dir.path().join("import_map.json");
|
||||||
let import_map_url = Url::from_file_path(&import_map_path).unwrap();
|
let import_map_url = Url::from_file_path(&import_map_path).unwrap();
|
||||||
|
@ -914,7 +914,7 @@ mod tests {
|
||||||
// Regression test for https://github.com/denoland/deno/issues/10556.
|
// Regression test for https://github.com/denoland/deno/issues/10556.
|
||||||
#[test]
|
#[test]
|
||||||
fn install_file_url() {
|
fn install_file_url() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
let module_path = fs::canonicalize(testdata_path().join("cat.ts")).unwrap();
|
let module_path = fs::canonicalize(testdata_path().join("cat.ts")).unwrap();
|
||||||
let file_module_string =
|
let file_module_string =
|
||||||
|
@ -950,7 +950,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uninstall_basic() {
|
fn uninstall_basic() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new();
|
||||||
let bin_dir = temp_dir.path().join("bin");
|
let bin_dir = temp_dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin_dir).unwrap();
|
std::fs::create_dir(&bin_dir).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tempfile::TempDir;
|
|
||||||
|
|
||||||
static ARCHIVE_NAME: Lazy<String> =
|
static ARCHIVE_NAME: Lazy<String> =
|
||||||
Lazy::new(|| format!("deno-{}.zip", env!("TARGET")));
|
Lazy::new(|| format!("deno-{}.zip", env!("TARGET")));
|
||||||
|
@ -230,7 +229,7 @@ pub fn unpack(
|
||||||
// We use into_path so that the tempdir is not automatically deleted. This is
|
// We use into_path so that the tempdir is not automatically deleted. This is
|
||||||
// useful for debugging upgrade, but also so this function can return a path
|
// useful for debugging upgrade, but also so this function can return a path
|
||||||
// to the newly uncompressed file without fear of the tempdir being deleted.
|
// to the newly uncompressed file without fear of the tempdir being deleted.
|
||||||
let temp_dir = TempDir::new()?.into_path();
|
let temp_dir = secure_tempfile::TempDir::new()?.into_path();
|
||||||
let exe_ext = if is_windows { "exe" } else { "" };
|
let exe_ext = if is_windows { "exe" } else { "" };
|
||||||
let archive_path = temp_dir.join(EXE_NAME).with_extension("zip");
|
let archive_path = temp_dir.join(EXE_NAME).with_extension("zip");
|
||||||
let exe_path = temp_dir.join(EXE_NAME).with_extension(exe_ext);
|
let exe_path = temp_dir.join(EXE_NAME).with_extension(exe_ext);
|
||||||
|
|
|
@ -19,6 +19,7 @@ base64 = "0.13.0"
|
||||||
futures = "0.3.21"
|
futures = "0.3.21"
|
||||||
hyper = { version = "0.14.12", features = ["server", "http1", "http2", "runtime"] }
|
hyper = { version = "0.14.12", features = ["server", "http1", "http2", "runtime"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
once_cell = "1.10.0"
|
||||||
os_pipe = "1.0.1"
|
os_pipe = "1.0.1"
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
pretty_assertions = "=1.2.0"
|
pretty_assertions = "=1.2.0"
|
||||||
|
@ -26,7 +27,6 @@ regex = "1.5.5"
|
||||||
rustls-pemfile = "0.2.1"
|
rustls-pemfile = "0.2.1"
|
||||||
serde = { version = "1.0.126", features = ["derive"] }
|
serde = { version = "1.0.126", features = ["derive"] }
|
||||||
serde_json = "1.0.65"
|
serde_json = "1.0.65"
|
||||||
tempfile = "3.2.0"
|
|
||||||
tokio = { version = "1.10.1", features = ["full"] }
|
tokio = { version = "1.10.1", features = ["full"] }
|
||||||
tokio-rustls = "0.23"
|
tokio-rustls = "0.23"
|
||||||
tokio-tungstenite = "0.16"
|
tokio-tungstenite = "0.16"
|
||||||
|
|
|
@ -28,6 +28,8 @@ use std::io::Read;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
use std::ops::Deref;
|
||||||
|
use std::ops::DerefMut;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::process::Child;
|
use std::process::Child;
|
||||||
|
@ -40,7 +42,6 @@ use std::sync::Mutex;
|
||||||
use std::sync::MutexGuard;
|
use std::sync::MutexGuard;
|
||||||
use std::task::Context;
|
use std::task::Context;
|
||||||
use std::task::Poll;
|
use std::task::Poll;
|
||||||
use tempfile::TempDir;
|
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
|
@ -50,6 +51,9 @@ use tokio_tungstenite::accept_async;
|
||||||
|
|
||||||
pub mod lsp;
|
pub mod lsp;
|
||||||
pub mod pty;
|
pub mod pty;
|
||||||
|
mod temp_dir;
|
||||||
|
|
||||||
|
pub use temp_dir::TempDir;
|
||||||
|
|
||||||
const PORT: u16 = 4545;
|
const PORT: u16 = 4545;
|
||||||
const TEST_AUTH_TOKEN: &str = "abcdef123456789";
|
const TEST_AUTH_TOKEN: &str = "abcdef123456789";
|
||||||
|
@ -1654,20 +1658,42 @@ pub fn run_and_collect_output_with_args(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_deno_dir() -> TempDir {
|
pub fn new_deno_dir() -> TempDir {
|
||||||
TempDir::new().expect("tempdir fail")
|
TempDir::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deno_cmd() -> Command {
|
pub struct DenoCmd {
|
||||||
|
// keep the deno dir directory alive for the duration of the command
|
||||||
|
_deno_dir: TempDir,
|
||||||
|
cmd: Command,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Deref for DenoCmd {
|
||||||
|
type Target = Command;
|
||||||
|
fn deref(&self) -> &Command {
|
||||||
|
&self.cmd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DerefMut for DenoCmd {
|
||||||
|
fn deref_mut(&mut self) -> &mut Command {
|
||||||
|
&mut self.cmd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deno_cmd() -> DenoCmd {
|
||||||
let deno_dir = new_deno_dir();
|
let deno_dir = new_deno_dir();
|
||||||
deno_cmd_with_deno_dir(deno_dir.path())
|
deno_cmd_with_deno_dir(&deno_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deno_cmd_with_deno_dir(deno_dir: &std::path::Path) -> Command {
|
pub fn deno_cmd_with_deno_dir(deno_dir: &TempDir) -> DenoCmd {
|
||||||
let e = deno_exe_path();
|
let exe_path = deno_exe_path();
|
||||||
assert!(e.exists());
|
assert!(exe_path.exists());
|
||||||
let mut c = Command::new(e);
|
let mut cmd = Command::new(exe_path);
|
||||||
c.env("DENO_DIR", deno_dir);
|
cmd.env("DENO_DIR", deno_dir.path());
|
||||||
c
|
DenoCmd {
|
||||||
|
_deno_dir: deno_dir.clone(),
|
||||||
|
cmd,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_powershell_script_file(
|
pub fn run_powershell_script_file(
|
||||||
|
@ -1735,7 +1761,8 @@ impl CheckOutputIntegrationTest {
|
||||||
|
|
||||||
let (mut reader, writer) = pipe().unwrap();
|
let (mut reader, writer) = pipe().unwrap();
|
||||||
let testdata_dir = testdata_path();
|
let testdata_dir = testdata_path();
|
||||||
let mut command = deno_cmd();
|
let deno_dir = new_deno_dir(); // keep this alive for the test
|
||||||
|
let mut command = deno_cmd_with_deno_dir(&deno_dir);
|
||||||
println!("deno_exe args {}", self.args);
|
println!("deno_exe args {}", self.args);
|
||||||
println!("deno_exe testdata path {:?}", &testdata_dir);
|
println!("deno_exe testdata path {:?}", &testdata_dir);
|
||||||
command.args(args.iter());
|
command.args(args.iter());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use super::new_deno_dir;
|
use super::new_deno_dir;
|
||||||
|
use super::TempDir;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
@ -23,7 +24,6 @@ use std::process::Stdio;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tempfile::TempDir;
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref CONTENT_TYPE_REG: Regex =
|
static ref CONTENT_TYPE_REG: Regex =
|
||||||
|
|
87
test_util/src/temp_dir.rs
Normal file
87
test_util/src/temp_dir.rs
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
use std::path::Path;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::sync::atomic::AtomicU32;
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::time::SystemTime;
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
|
use once_cell::sync::OnceCell;
|
||||||
|
|
||||||
|
static TEMP_DIR_SESSION: OnceCell<TempDirSession> = OnceCell::new();
|
||||||
|
|
||||||
|
struct TempDirSession {
|
||||||
|
default_prefix: String,
|
||||||
|
counter: AtomicU32,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// For creating temporary directories in tests.
|
||||||
|
///
|
||||||
|
/// This was done because `tempfiles::TempDir` was very slow on Windows.
|
||||||
|
///
|
||||||
|
/// Note: Do not use this in actual code as this does not protect against
|
||||||
|
/// "insecure temporary file" security vulnerabilities.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct TempDir(Arc<TempDirInner>);
|
||||||
|
|
||||||
|
struct TempDirInner(PathBuf);
|
||||||
|
|
||||||
|
impl Drop for TempDirInner {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
let _ = std::fs::remove_dir_all(&self.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for TempDir {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TempDir {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self::new_inner(&std::env::temp_dir(), None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_in(path: &Path) -> Self {
|
||||||
|
Self::new_inner(path, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_with_prefix(prefix: &str) -> Self {
|
||||||
|
Self::new_inner(&std::env::temp_dir(), Some(prefix))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_inner(parent_dir: &Path, prefix: Option<&str>) -> Self {
|
||||||
|
let session = TEMP_DIR_SESSION.get_or_init(|| {
|
||||||
|
let default_prefix = format!(
|
||||||
|
"deno-cli-test-{}",
|
||||||
|
SystemTime::now()
|
||||||
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_millis()
|
||||||
|
);
|
||||||
|
TempDirSession {
|
||||||
|
default_prefix,
|
||||||
|
counter: Default::default(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Self({
|
||||||
|
let count = session.counter.fetch_add(1, Ordering::SeqCst);
|
||||||
|
let path = parent_dir.join(format!(
|
||||||
|
"{}{}-{}",
|
||||||
|
prefix.unwrap_or(""),
|
||||||
|
session.default_prefix,
|
||||||
|
count,
|
||||||
|
));
|
||||||
|
std::fs::create_dir_all(&path)
|
||||||
|
.with_context(|| format!("Error creating temp dir: {}", path.display()))
|
||||||
|
.unwrap();
|
||||||
|
Arc::new(TempDirInner(path))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path(&self) -> &Path {
|
||||||
|
let inner = &self.0;
|
||||||
|
inner.0.as_path()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue