diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-04-01 11:15:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-01 11:15:37 -0400 |
commit | 1c37ac33526dc45ad0b3f83ca8294dbb55548096 (patch) | |
tree | 426978168928c5e7c2223e4906005fa23fb34cd6 /cli/tests | |
parent | 8ca4c1819f3e7a8716c68034e256355334d53b44 (diff) |
chore(tests): use custom temp dir creation for the tests (#14153)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/bundle_tests.rs | 24 | ||||
-rw-r--r-- | cli/tests/integration/cache_tests.rs | 4 | ||||
-rw-r--r-- | cli/tests/integration/compile_tests.rs | 30 | ||||
-rw-r--r-- | cli/tests/integration/coverage_tests.rs | 22 | ||||
-rw-r--r-- | cli/tests/integration/fmt_tests.rs | 7 | ||||
-rw-r--r-- | cli/tests/integration/info_tests.rs | 4 | ||||
-rw-r--r-- | cli/tests/integration/install_tests.rs | 10 | ||||
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 35 | ||||
-rw-r--r-- | cli/tests/integration/mod.rs | 30 | ||||
-rw-r--r-- | cli/tests/integration/run_tests.rs | 34 | ||||
-rw-r--r-- | cli/tests/integration/upgrade_tests.rs | 19 | ||||
-rw-r--r-- | cli/tests/integration/vendor_tests.rs | 16 | ||||
-rw-r--r-- | cli/tests/integration/watcher_tests.rs | 38 |
13 files changed, 136 insertions, 137 deletions
diff --git a/cli/tests/integration/bundle_tests.rs b/cli/tests/integration/bundle_tests.rs index e6d208897..bb2489e03 100644 --- a/cli/tests/integration/bundle_tests.rs +++ b/cli/tests/integration/bundle_tests.rs @@ -1,15 +1,15 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use crate::itest; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; #[test] fn bundle_exports() { // First we have to generate a bundle of some module that has exports. let mod1 = util::testdata_path().join("subdir/mod1.ts"); assert!(mod1.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("mod1.bundle.js"); let mut deno = util::deno_cmd() .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. let mod1 = util::testdata_path().join("subdir/mod1.ts"); assert!(mod1.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("mod1.bundle.js"); let mut deno = util::deno_cmd() .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. let circular1 = util::testdata_path().join("subdir/circular1.ts"); assert!(circular1.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("circular1.bundle.js"); let mut deno = util::deno_cmd() .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. let single_module = util::testdata_path().join("subdir/single_module.ts"); assert!(single_module.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("single_module.bundle.js"); let mut deno = util::deno_cmd() .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. let tla_import = util::testdata_path().join("subdir/tla.ts"); assert!(tla_import.is_file()); - let t = tempfile::TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("tla.bundle.js"); let mut deno = util::deno_cmd() .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. let mod6 = util::testdata_path().join("subdir/mod6.js"); assert!(mod6.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("mod6.bundle.js"); let mut deno = util::deno_cmd() .current_dir(util::testdata_path()) @@ -228,7 +228,7 @@ fn bundle_dynamic_import() { let _g = util::http_server(); let dynamic_import = util::testdata_path().join("bundle_dynamic_import.ts"); 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 mut deno = util::deno_cmd() .current_dir(util::testdata_path()) @@ -262,7 +262,7 @@ fn bundle_import_map() { let import = util::testdata_path().join("bundle_im.ts"); let import_map_path = util::testdata_path().join("bundle_im.json"); assert!(import.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("import_map.bundle.js"); let mut deno = util::deno_cmd() .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_map_path = util::testdata_path().join("bundle_im.json"); assert!(import.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("import_map.bundle.js"); let mut deno = util::deno_cmd() .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. let mod7 = util::testdata_path().join("subdir/mod7.js"); assert!(mod7.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("mod7.bundle.js"); let mut deno = util::deno_cmd() .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. let mod8 = util::testdata_path().join("subdir/mod8.js"); assert!(mod8.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("mod8.bundle.js"); let mut deno = util::deno_cmd() .current_dir(util::testdata_path()) diff --git a/cli/tests/integration/cache_tests.rs b/cli/tests/integration/cache_tests.rs index f7d9fb486..00fd95149 100644 --- a/cli/tests/integration/cache_tests.rs +++ b/cli/tests/integration/cache_tests.rs @@ -54,10 +54,10 @@ itest!(ignore_require { #[cfg(target_os = "linux")] #[test] fn relative_home_dir() { - use tempfile::TempDir; 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 mut deno_cmd = util::deno_cmd(); diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs index 82a98115a..dad607544 100644 --- a/cli/tests/integration/compile_tests.rs +++ b/cli/tests/integration/compile_tests.rs @@ -2,12 +2,12 @@ use std::fs::File; use std::process::Command; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; #[test] fn compile() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("welcome.exe") } else { @@ -38,7 +38,7 @@ fn compile() { #[test] fn standalone_args() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("args.exe") } else { @@ -74,7 +74,7 @@ fn standalone_args() { #[test] fn standalone_error() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("error.exe") } else { @@ -116,7 +116,7 @@ fn standalone_error() { #[test] fn standalone_error_module_with_imports() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("error.exe") } else { @@ -156,7 +156,7 @@ fn standalone_error_module_with_imports() { #[test] fn standalone_load_datauri() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("load_datauri.exe") } else { @@ -221,7 +221,7 @@ fn standalone_follow_redirects() { #[test] fn standalone_compiler_ops() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("standalone_compiler_ops.exe") } else { @@ -253,7 +253,7 @@ fn standalone_compiler_ops() { #[test] fn compile_with_directory_output_flag() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let output_path = if cfg!(windows) { dir.path().join(r"args\random\") } else { @@ -291,7 +291,7 @@ fn compile_with_directory_output_flag() { #[test] fn compile_with_file_exists_error() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let output_path = if cfg!(windows) { dir.path().join(r"args\") } else { @@ -326,7 +326,7 @@ fn compile_with_file_exists_error() { #[test] fn compile_with_directory_exists_error() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("args.exe") } else { @@ -360,7 +360,7 @@ fn compile_with_directory_exists_error() { #[test] fn compile_with_conflict_file_exists_error() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("args.exe") } else { @@ -398,7 +398,7 @@ fn compile_with_conflict_file_exists_error() { #[test] fn compile_and_overwrite_file() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("args.exe") } else { @@ -436,7 +436,7 @@ fn compile_and_overwrite_file() { #[test] fn standalone_runtime_flags() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("flags.exe") } else { @@ -475,7 +475,7 @@ fn standalone_runtime_flags() { #[test] fn standalone_import_map() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("import_map.exe") } else { @@ -510,7 +510,7 @@ fn standalone_import_map() { #[test] // https://github.com/denoland/deno/issues/12670 fn skip_rebundle() { - let dir = TempDir::new().unwrap(); + let dir = TempDir::new(); let exe = if cfg!(windows) { dir.path().join("hello_world.exe") } else { diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs index 47586184a..628aaab7f 100644 --- a/cli/tests/integration/coverage_tests.rs +++ b/cli/tests/integration/coverage_tests.rs @@ -1,8 +1,8 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use std::fs; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; #[test] fn branch() { @@ -20,11 +20,11 @@ fn final_blankline() { } fn run_coverage_text(test_name: &str, extension: &str) { - let deno_dir = TempDir::new().unwrap(); - let tempdir = TempDir::new().unwrap(); + let deno_dir = TempDir::new(); + let tempdir = TempDir::new(); 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()) .arg("test") .arg("--quiet") @@ -38,7 +38,7 @@ fn run_coverage_text(test_name: &str, extension: &str) { 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()) .arg("coverage") .arg("--unstable") @@ -68,7 +68,7 @@ fn run_coverage_text(test_name: &str, extension: &str) { 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()) .arg("coverage") .arg("--quiet") @@ -100,11 +100,11 @@ fn run_coverage_text(test_name: &str, extension: &str) { #[test] fn multifile_coverage() { - let deno_dir = TempDir::new().unwrap(); - let tempdir = TempDir::new().unwrap(); + let deno_dir = TempDir::new(); + let tempdir = TempDir::new(); 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()) .arg("test") .arg("--quiet") @@ -118,7 +118,7 @@ fn multifile_coverage() { 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()) .arg("coverage") .arg("--unstable") @@ -148,7 +148,7 @@ fn multifile_coverage() { 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()) .arg("coverage") .arg("--quiet") diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs index 28a1dda7d..f38160a15 100644 --- a/cli/tests/integration/fmt_tests.rs +++ b/cli/tests/integration/fmt_tests.rs @@ -1,12 +1,12 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use crate::itest; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; #[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 badly_formatted_original_js = 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(); 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 git_dir = t.join(".git"); create_dir_all(&nest_git).unwrap(); diff --git a/cli/tests/integration/info_tests.rs b/cli/tests/integration/info_tests.rs index 53a13538e..d266daee0 100644 --- a/cli/tests/integration/info_tests.rs +++ b/cli/tests/integration/info_tests.rs @@ -1,14 +1,14 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use crate::itest; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; #[test] fn info_with_compiled_source() { let _g = util::http_server(); 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() .env("DENO_DIR", t.path()) diff --git a/cli/tests/integration/install_tests.rs b/cli/tests/integration/install_tests.rs index 4ad767607..ebe587301 100644 --- a/cli/tests/integration/install_tests.rs +++ b/cli/tests/integration/install_tests.rs @@ -2,13 +2,13 @@ use std::fs; use std::process::Command; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; #[test] fn install_basic() { 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 status = util::deno_cmd() @@ -50,7 +50,7 @@ fn install_basic() { #[test] fn install_custom_dir_env_var() { 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 status = util::deno_cmd() @@ -87,7 +87,7 @@ fn install_custom_dir_env_var() { #[test] 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"); std::fs::create_dir(&bin_dir).unwrap(); let status = util::deno_cmd() @@ -124,7 +124,7 @@ fn installer_test_local_module_run() { #[test] fn installer_test_remote_module_run() { let _g = util::http_server(); - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let bin_dir = temp_dir.path().join("bin"); std::fs::create_dir(&bin_dir).unwrap(); let status = util::deno_cmd() diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 415f0610e..fecfdb001 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -12,11 +12,11 @@ use lspower::lsp; use pretty_assertions::assert_eq; use std::collections::HashSet; use std::fs; -use tempfile::TempDir; use test_util::deno_exe_path; use test_util::http_server; use test_util::lsp::LspClient; use test_util::testdata_path; +use test_util::TempDir; fn load_fixture(path: &str) -> Value { load_fixture_as(path) @@ -233,7 +233,7 @@ fn lsp_startup_shutdown() { #[test] fn lsp_init_tsconfig() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); let tsconfig = @@ -276,7 +276,7 @@ fn lsp_init_tsconfig() { fn lsp_tsconfig_types() { let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let tsconfig = serde_json::to_vec_pretty(&load_fixture("types.tsconfig.json")).unwrap(); fs::write(temp_dir.path().join("types.tsconfig.json"), tsconfig).unwrap(); @@ -341,9 +341,9 @@ fn lsp_tsconfig_bad_config_path() { #[test] fn lsp_triple_slash_types() { + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = 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"); fs::write(temp_dir.path().join("a.d.ts"), a_dts).unwrap(); @@ -377,7 +377,7 @@ fn lsp_triple_slash_types() { #[test] fn lsp_import_map() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); let import_map = @@ -488,7 +488,7 @@ fn lsp_import_map_data_url() { #[test] fn lsp_import_map_config_file() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); @@ -581,7 +581,7 @@ fn lsp_import_map_config_file() { #[test] fn lsp_deno_task() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let workspace_root = temp_dir.path().canonicalize().unwrap(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); @@ -704,7 +704,7 @@ fn lsp_import_assertions() { #[test] fn lsp_import_map_import_completions() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); 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 // 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 - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let root_specifier = ensure_directory_specifier(Url::from_file_path(temp_dir.path()).unwrap()); @@ -1458,7 +1458,8 @@ fn lsp_hover_change_mbc() { #[test] 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"); fs::write(a_path, r#"export const a = "a";"#).unwrap(); let b_path = temp_dir.join("b.ts"); @@ -3669,7 +3670,7 @@ fn lsp_auto_discover_registry() { #[test] fn lsp_cache_location() { let _g = http_server(); - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params_registry.json")) .unwrap(); @@ -4395,7 +4396,7 @@ fn lsp_format_mbc() { #[test] fn lsp_format_exclude_with_config() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); let deno_fmt_jsonc = @@ -4450,7 +4451,7 @@ fn lsp_format_exclude_with_config() { #[test] 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 mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); @@ -4675,7 +4676,7 @@ fn lsp_format_markdown() { #[test] fn lsp_format_with_config() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); let deno_fmt_jsonc = @@ -5154,7 +5155,7 @@ console.log(snake_case); #[test] fn lsp_lint_with_config() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); let deno_lint_jsonc = @@ -5186,7 +5187,7 @@ fn lsp_lint_with_config() { #[test] fn lsp_lint_exclude_with_config() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); let deno_lint_jsonc = @@ -5346,7 +5347,7 @@ struct TestRunResponseParams { fn lsp_testing_api() { let mut params: lsp::InitializeParams = serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let root_specifier = ensure_directory_specifier(Url::from_file_path(temp_dir.path()).unwrap()); diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs index 98b203ee9..86a980f59 100644 --- a/cli/tests/integration/mod.rs +++ b/cli/tests/integration/mod.rs @@ -12,8 +12,8 @@ use std::io::Cursor; use std::io::{Read, Write}; use std::process::Command; use std::sync::Arc; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; use tokio::task::LocalSet; #[macro_export] @@ -139,7 +139,7 @@ itest!(types { #[test] fn cache_test() { let _g = util::http_server(); - let deno_dir = TempDir::new().expect("tempdir fail"); + let deno_dir = TempDir::new(); let module_url = url::Url::parse("http://localhost:4545/006_url_imports.ts").unwrap(); let output = Command::new(util::deno_exe_path()) @@ -184,7 +184,7 @@ fn cache_test() { #[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 mut file = std::fs::File::create(fixture_path.clone()) @@ -224,7 +224,7 @@ fn cache_invalidation_test() { #[test] 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 mut file = std::fs::File::create(fixture_path.clone()) @@ -266,7 +266,7 @@ fn cache_invalidation_test_no_check() { #[test] fn ts_dependency_recompilation() { - let t = TempDir::new().expect("tempdir fail"); + let t = TempDir::new(); let ats = t.path().join("a.ts"); std::fs::write( @@ -365,8 +365,8 @@ fn ts_reload() { let hello_ts = util::testdata_path().join("002_hello.ts"); assert!(hello_ts.is_file()); - let deno_dir = TempDir::new().expect("tempdir fail"); - let mut initial = util::deno_cmd_with_deno_dir(deno_dir.path()) + let deno_dir = TempDir::new(); + let mut initial = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(util::testdata_path()) .arg("cache") .arg(&hello_ts) @@ -376,7 +376,7 @@ fn ts_reload() { initial.wait().expect("failed to wait for child process"); 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()) .arg("cache") .arg("--reload") @@ -539,7 +539,7 @@ itest!(localhost_unsafe_ssl { fn cafile_env_fetch() { use deno_core::url::Url; let _g = util::http_server(); - let deno_dir = TempDir::new().expect("tempdir fail"); + let deno_dir = TempDir::new(); let module_url = Url::parse("https://localhost:5545/cafile_url_imports.ts").unwrap(); let cafile = util::testdata_path().join("tls/RootCA.pem"); @@ -558,7 +558,7 @@ fn cafile_env_fetch() { fn cafile_fetch() { use deno_core::url::Url; let _g = util::http_server(); - let deno_dir = TempDir::new().expect("tempdir fail"); + let deno_dir = TempDir::new(); let module_url = Url::parse("http://localhost:4545/cafile_url_imports.ts").unwrap(); let cafile = util::testdata_path().join("tls/RootCA.pem"); @@ -579,10 +579,10 @@ fn cafile_fetch() { #[flaky_test::flaky_test] fn cafile_install_remote_module() { 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"); 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 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. let mod1 = "https://localhost:5545/subdir/mod1.ts"; 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 mut deno = util::deno_cmd() .current_dir(util::testdata_path()) @@ -1095,7 +1095,7 @@ fn typecheck_declarations_unstable() { #[test] 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"); std::fs::write( &test_file, @@ -1111,7 +1111,7 @@ fn typecheck_core() { ), ) .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(test_file.to_str().unwrap()) .output() diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index fb6f72c6e..43a761204 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -2,8 +2,8 @@ use deno_core::url; use std::process::Command; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; itest!(stdout_write_all { args: "run --quiet stdout_write_all.ts", @@ -253,7 +253,7 @@ itest!(webstorage_serialization { fn webstorage_location_shares_origin() { 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 .current_dir(util::testdata_path()) .arg("run") @@ -268,7 +268,7 @@ fn webstorage_location_shares_origin() { assert!(output.status.success()); 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 .current_dir(util::testdata_path()) .arg("run") @@ -290,7 +290,7 @@ fn webstorage_location_shares_origin() { fn webstorage_config_file() { 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 .current_dir(util::testdata_path()) .arg("run") @@ -305,7 +305,7 @@ fn webstorage_config_file() { assert!(output.status.success()); 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 .current_dir(util::testdata_path()) .arg("run") @@ -320,7 +320,7 @@ fn webstorage_config_file() { assert!(output.status.success()); 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 .current_dir(util::testdata_path()) .arg("run") @@ -342,7 +342,7 @@ fn webstorage_config_file() { fn webstorage_location_precedes_config() { 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 .current_dir(util::testdata_path()) .arg("run") @@ -359,7 +359,7 @@ fn webstorage_location_precedes_config() { assert!(output.status.success()); 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 .current_dir(util::testdata_path()) .arg("run") @@ -383,7 +383,7 @@ fn webstorage_location_precedes_config() { fn webstorage_main_module() { 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 .current_dir(util::testdata_path()) .arg("run") @@ -396,7 +396,7 @@ fn webstorage_main_module() { assert!(output.status.success()); 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 .current_dir(util::testdata_path()) .arg("run") @@ -409,7 +409,7 @@ fn webstorage_main_module() { assert!(output.status.success()); 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 .current_dir(util::testdata_path()) .arg("run") @@ -466,7 +466,7 @@ itest!(_082_prepare_stack_trace_throw { #[test] fn _083_legacy_external_source_map() { let _g = util::http_server(); - let deno_dir = TempDir::new().unwrap(); + let deno_dir = TempDir::new(); let module_url = url::Url::parse("http://localhost:4545/083_legacy_external_source_map.ts") .unwrap(); @@ -1804,7 +1804,7 @@ fn rust_log() { fn dont_cache_on_check_fail() { 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 .current_dir(util::testdata_path()) .arg("run") @@ -1818,7 +1818,7 @@ fn dont_cache_on_check_fail() { assert!(!output.status.success()); 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 .current_dir(util::testdata_path()) .arg("run") @@ -2368,7 +2368,7 @@ itest!(eval_context_throw_dom_exception { fn issue12453() { let _g = util::http_server(); 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 .current_dir(util::testdata_path()) .arg("run") @@ -2385,7 +2385,7 @@ fn issue12453() { /// Regression test for https://github.com/denoland/deno/issues/12740. #[test] fn issue12740() { - let mod_dir = TempDir::new().unwrap(); + let mod_dir = TempDir::new(); let mod1_path = mod_dir.path().join("mod1.ts"); let mod2_path = mod_dir.path().join("mod2.ts"); let mut deno_cmd = util::deno_cmd(); @@ -2419,7 +2419,7 @@ fn issue12740() { /// Regression test for https://github.com/denoland/deno/issues/12807. #[test] fn issue12807() { - let mod_dir = TempDir::new().unwrap(); + let mod_dir = TempDir::new(); let mod1_path = mod_dir.path().join("mod1.ts"); let mod2_path = mod_dir.path().join("mod2.ts"); let mut deno_cmd = util::deno_cmd(); diff --git a/cli/tests/integration/upgrade_tests.rs b/cli/tests/integration/upgrade_tests.rs index 01554f6da..f2cee910b 100644 --- a/cli/tests/integration/upgrade_tests.rs +++ b/cli/tests/integration/upgrade_tests.rs @@ -1,15 +1,15 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use std::process::{Command, Stdio}; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; // Warning: this test requires internet access. // TODO(#7412): reenable. test is flaky #[test] #[ignore] fn upgrade_in_tmpdir() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let exe_path = temp_dir.path().join("deno"); let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap(); assert!(exe_path.exists()); @@ -31,10 +31,7 @@ fn upgrade_in_tmpdir() { #[test] #[ignore] fn upgrade_with_space_in_path() { - let temp_dir = tempfile::Builder::new() - .prefix("directory with spaces") - .tempdir() - .unwrap(); + let temp_dir = TempDir::new_with_prefix("directory with spaces"); let exe_path = temp_dir.path().join("deno"); let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap(); assert!(exe_path.exists()); @@ -54,7 +51,7 @@ fn upgrade_with_space_in_path() { #[test] #[ignore] 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 _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap(); assert!(exe_path.exists()); @@ -83,7 +80,7 @@ fn upgrade_with_version_in_tmpdir() { #[test] #[ignore] 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 _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap(); assert!(exe_path.exists()); @@ -112,7 +109,7 @@ fn upgrade_with_canary_in_tmpdir() { #[test] #[ignore] 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 new_exe_path = temp_dir.path().join("foo"); let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap(); @@ -149,7 +146,7 @@ fn upgrade_with_out_in_tmpdir() { #[test] #[ignore] 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 _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap(); assert!(exe_path.exists()); @@ -174,7 +171,7 @@ fn upgrade_invalid_stable_version() { #[test] #[ignore] 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 _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap(); assert!(exe_path.exists()); diff --git a/cli/tests/integration/vendor_tests.rs b/cli/tests/integration/vendor_tests.rs index 4aa883a7e..5737f0365 100644 --- a/cli/tests/integration/vendor_tests.rs +++ b/cli/tests/integration/vendor_tests.rs @@ -6,13 +6,13 @@ use pretty_assertions::assert_eq; use std::fs; use std::path::PathBuf; use std::process::Stdio; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; use util::http_server; #[test] fn output_dir_exists() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let vendor_dir = t.path().join("vendor"); fs::write(t.path().join("mod.ts"), "").unwrap(); fs::create_dir_all(&vendor_dir).unwrap(); @@ -75,7 +75,7 @@ fn output_dir_exists() { #[test] fn import_map_output_dir() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let vendor_dir = t.path().join("vendor"); fs::write(t.path().join("mod.ts"), "").unwrap(); fs::create_dir_all(&vendor_dir).unwrap(); @@ -109,7 +109,7 @@ fn import_map_output_dir() { #[test] fn standard_test() { let _server = http_server(); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let vendor_dir = t.path().join("vendor2"); fs::write( t.path().join("my_app.ts"), @@ -186,7 +186,7 @@ fn standard_test() { #[test] fn remote_module_test() { let _server = http_server(); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let vendor_dir = t.path().join("vendor"); let deno = util::deno_cmd() @@ -239,7 +239,7 @@ fn remote_module_test() { #[test] fn existing_import_map() { let _server = http_server(); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let vendor_dir = t.path().join("vendor"); fs::write( t.path().join("mod.ts"), @@ -274,7 +274,7 @@ fn existing_import_map() { #[test] fn dynamic_import() { let _server = http_server(); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let vendor_dir = t.path().join("vendor"); fs::write( t.path().join("mod.ts"), @@ -327,7 +327,7 @@ fn dynamic_import() { #[test] fn dynamic_non_analyzable_import() { let _server = http_server(); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); fs::write( t.path().join("mod.ts"), "import {Logger} from 'http://localhost:4545/vendor/dynamic_non_analyzable.ts'; new Logger().log('outputted');", diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs index 4e597cf1b..2f2bc9851 100644 --- a/cli/tests/integration/watcher_tests.rs +++ b/cli/tests/integration/watcher_tests.rs @@ -3,8 +3,8 @@ use flaky_test::flaky_test; use std::fs::write; use std::io::BufRead; -use tempfile::TempDir; use test_util as util; +use test_util::TempDir; const CLEAR_SCREEN: &str = r#"[2J"#; @@ -88,7 +88,7 @@ fn child_lines( #[test] fn lint_watch_test() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let badly_linted_original = util::testdata_path().join("lint/watch/badly_linted.js"); let badly_linted_output = @@ -147,7 +147,7 @@ fn lint_watch_test() { #[test] fn lint_watch_without_args_test() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let badly_linted_original = util::testdata_path().join("lint/watch/badly_linted.js"); let badly_linted_output = @@ -206,7 +206,7 @@ fn lint_watch_without_args_test() { #[test] fn lint_all_files_on_each_change_test() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let badly_linted_fixed0 = util::testdata_path().join("lint/watch/badly_linted.js"); let badly_linted_fixed1 = @@ -245,7 +245,7 @@ fn lint_all_files_on_each_change_test() { #[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 badly_formatted_original = util::testdata_path().join("badly_formatted.mjs"); @@ -295,7 +295,7 @@ fn fmt_watch_test() { #[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 badly_formatted_original = util::testdata_path().join("badly_formatted.mjs"); @@ -343,7 +343,7 @@ fn fmt_watch_without_args_test() { #[test] fn fmt_check_all_files_on_each_change_test() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let badly_formatted_original = util::testdata_path().join("badly_formatted.mjs"); 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() { use std::path::PathBuf; // 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"); write(&file_to_watch, "console.log('Hello world');").unwrap(); assert!(file_to_watch.is_file()); - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let bundle = t.path().join("mod6.bundle.js"); let mut deno = util::deno_cmd() .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 #[test] 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"); write(&file_to_watch, "syntax error ^^").unwrap(); let target_file = t.path().join("target.js"); @@ -485,7 +485,7 @@ fn bundle_watch_not_exit() { #[flaky_test::flaky_test] fn run_watch() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let file_to_watch = t.path().join("file_to_watch.js"); write(&file_to_watch, "console.log('Hello world');").unwrap(); @@ -568,7 +568,7 @@ fn run_watch() { #[test] 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"); write(&file_to_watch, "console.log('Hello world');").unwrap(); @@ -609,7 +609,7 @@ fn run_watch_external_watch_files() { #[test] 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"); write( &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 #[test] 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"); 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()); 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( &temp_directory, "file_to_watch.js", @@ -764,7 +764,7 @@ fn run_watch_with_import_map_and_relative_paths() { #[flaky_test] fn test_watch() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let mut child = util::deno_cmd() .current_dir(util::testdata_path()) @@ -908,7 +908,7 @@ fn test_watch() { #[flaky_test] fn test_watch_doc() { - let t = TempDir::new().unwrap(); + let t = TempDir::new(); let mut child = util::deno_cmd() .current_dir(util::testdata_path()) @@ -961,7 +961,7 @@ fn test_watch_doc() { #[test] 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"); write(&file_to_watch, "import './nonexistent.js';").unwrap(); let mut child = util::deno_cmd() @@ -991,7 +991,7 @@ fn test_watch_module_graph_error_referrer() { #[test] 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"); write(&file_to_watch, "export const foo = 0;").unwrap(); |