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/tools | |
parent | 8ca4c1819f3e7a8716c68034e256355334d53b44 (diff) |
chore(tests): use custom temp dir creation for the tests (#14153)
Diffstat (limited to 'cli/tools')
-rw-r--r-- | cli/tools/installer.rs | 20 | ||||
-rw-r--r-- | cli/tools/upgrade.rs | 3 |
2 files changed, 11 insertions, 12 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index 756395d65..686e127df 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -401,8 +401,8 @@ mod tests { use super::*; use std::process::Command; - use tempfile::TempDir; use test_util::testdata_path; + use test_util::TempDir; #[test] fn install_infer_name_from_url() { @@ -479,7 +479,7 @@ mod tests { #[test] fn install_unstable() { - 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(); @@ -663,7 +663,7 @@ mod tests { #[test] fn install_local_module() { - 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 local_module = env::current_dir().unwrap().join("echo_server.ts"); @@ -694,7 +694,7 @@ mod tests { #[test] fn install_force() { - 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(); @@ -755,7 +755,7 @@ mod tests { #[test] fn install_with_config() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let bin_dir = temp_dir.path().join("bin"); let config_file_path = temp_dir.path().join("test_tsconfig.json"); let config = "{}"; @@ -791,7 +791,7 @@ mod tests { #[cfg(not(windows))] #[test] fn install_shell_escaping() { - 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(); @@ -826,7 +826,7 @@ mod tests { #[test] fn install_unicode() { - 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 unicode_dir = temp_dir.path().join("Magnús"); @@ -866,7 +866,7 @@ mod tests { #[test] 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 import_map_path = temp_dir.path().join("import_map.json"); 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. #[test] fn install_file_url() { - let temp_dir = TempDir::new().unwrap(); + let temp_dir = TempDir::new(); let bin_dir = temp_dir.path().join("bin"); let module_path = fs::canonicalize(testdata_path().join("cat.ts")).unwrap(); let file_module_string = @@ -950,7 +950,7 @@ mod tests { #[test] fn uninstall_basic() { - 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(); diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index 531e72420..d72fb1b0a 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -16,7 +16,6 @@ use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::process::Command; -use tempfile::TempDir; static ARCHIVE_NAME: Lazy<String> = 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 // 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. - 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 archive_path = temp_dir.join(EXE_NAME).with_extension("zip"); let exe_path = temp_dir.join(EXE_NAME).with_extension(exe_ext); |