From 0062fedfd71a9813a94f5cbba129a10761749771 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 1 Jul 2019 15:57:40 +0700 Subject: [PATCH] Replace tempdir with tempfile --- Cargo.lock | 27 +------- Cargo.toml | 2 +- download/Cargo.toml | 2 +- download/tests/support/mod.rs | 7 ++- src/cli/common.rs | 10 +-- src/cli/self_update.rs | 6 +- tests/cli-exact.rs | 20 ++++-- tests/cli-misc.rs | 16 +++-- tests/cli-self-upd.rs | 11 +++- tests/cli-v1.rs | 19 +++--- tests/cli-v2.rs | 19 +++--- tests/dist.rs | 14 ++--- tests/dist_install.rs | 37 ++++++----- tests/dist_transactions.rs | 115 +++++++++++++++++----------------- tests/mock/clitools.rs | 43 +++++++------ tests/mock/dist.rs | 3 +- 16 files changed, 180 insertions(+), 171 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d979871673..fc1cf93d7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,7 +367,7 @@ dependencies = [ "hyper 0.12.31 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1047,18 +1047,6 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand" version = "0.6.5" @@ -1361,7 +1349,7 @@ dependencies = [ "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1590,15 +1578,6 @@ dependencies = [ "xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tempfile" version = "3.1.0" @@ -2149,7 +2128,6 @@ dependencies = [ "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5afecba86dcf1e4fd610246f89899d1924fe12e1e89f555eb7c7f710f3c5ad1d" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" -"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" @@ -2206,7 +2184,6 @@ dependencies = [ "checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "b3196bfbffbba3e57481b6ea32249fbaf590396a52505a2615adbb79d9d826d3" -"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561" "checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" diff --git a/Cargo.toml b/Cargo.toml index b5a62bdc5c..1b0f9828b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ semver = "0.9" sha2 = "0.8" strsim = "0.9.1" tar = "0.4.26" -tempdir = "0.3.4" +tempfile = "3.1" # FIXME(issue #1788) term = "=0.5.1" threadpool = "1" diff --git a/download/Cargo.toml b/download/Cargo.toml index 17b4bdc3a6..2c2d2450f8 100644 --- a/download/Cargo.toml +++ b/download/Cargo.toml @@ -25,4 +25,4 @@ reqwest = { version = "0.9.14", features = ["socks"], optional = true } [dev-dependencies] futures = "0.1" hyper = "0.12" -tempdir = "0.3.4" +tempfile = "3" diff --git a/download/tests/support/mod.rs b/download/tests/support/mod.rs index 959eb8751a..576b0cdb68 100644 --- a/download/tests/support/mod.rs +++ b/download/tests/support/mod.rs @@ -4,10 +4,13 @@ use std::net::SocketAddr; use std::path::Path; use futures::sync::oneshot; -use tempdir::TempDir; +use tempfile::TempDir; pub fn tmp_dir() -> TempDir { - TempDir::new("rustup-download-test-").expect("creating tempdir for test") + tempfile::Builder::new() + .prefix("rustup-download-test-") + .tempdir() + .expect("creating tempdir for test") } pub fn write_file(path: &Path, contents: &str) { diff --git a/src/cli/common.rs b/src/cli/common.rs index ad442aa34b..e56a5fb5c5 100644 --- a/src/cli/common.rs +++ b/src/cli/common.rs @@ -258,9 +258,11 @@ pub fn self_update_permitted(explicit: bool) -> Result { } let current_exe = env::current_exe()?; let current_exe_dir = current_exe.parent().expect("Rustup isn't in a directory‽"); - match tempdir::TempDir::new_in(current_exe_dir, "updtest") { - Ok(_) => {} - Err(e) => match e.kind() { + if let Err(e) = tempfile::Builder::new() + .prefix("updtest") + .tempdir_in(current_exe_dir) + { + match e.kind() { ErrorKind::PermissionDenied => { debug!("Skipping self-update because we cannot write to the rustup dir"); if explicit { @@ -270,7 +272,7 @@ pub fn self_update_permitted(explicit: bool) -> Result { } } _ => Err(e)?, - }, + } } Ok(SelfUpdatePermission::Permit) } diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index edb20e690b..2b8968ac50 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -44,7 +44,6 @@ use std::env::consts::EXE_SUFFIX; use std::fs; use std::path::{Component, Path, PathBuf}; use std::process::{self, Command}; -use tempdir::TempDir; pub struct InstallOpts { pub default_host_triple: String, @@ -1457,7 +1456,10 @@ pub fn prepare_update() -> Result> { let update_root = env::var("RUSTUP_UPDATE_ROOT").unwrap_or_else(|_| String::from(UPDATE_ROOT)); - let tempdir = TempDir::new("rustup-update").chain_err(|| "error creating temp directory")?; + let tempdir = tempfile::Builder::new() + .prefix("rustup-update") + .tempdir() + .chain_err(|| "error creating temp directory")?; // Get current version let current_version = env!("CARGO_PKG_VERSION"); diff --git a/tests/cli-exact.rs b/tests/cli-exact.rs index be217a4b21..1c44b99d08 100644 --- a/tests/cli-exact.rs +++ b/tests/cli-exact.rs @@ -162,7 +162,10 @@ info: you may use `--path ` option to remove override toolchain for a spec fn remove_override_with_path() { for keyword in &["remove", "unset"] { setup(&|config| { - let dir = tempdir::TempDir::new("rustup-test").unwrap(); + let dir = tempfile::Builder::new() + .prefix("rustup-test") + .tempdir() + .unwrap(); config.change_dir(dir.path(), || { expect_ok(config, &["rustup", "override", "add", "nightly"]); }); @@ -190,7 +193,10 @@ fn remove_override_with_path_deleted() { for keyword in &["remove", "unset"] { setup(&|config| { let path = { - let dir = tempdir::TempDir::new("rustup-test").unwrap(); + let dir = tempfile::Builder::new() + .prefix("rustup-test") + .tempdir() + .unwrap(); let path = std::fs::canonicalize(dir.path()).unwrap(); config.change_dir(&path, || { expect_ok(config, &["rustup", "override", "add", "nightly"]); @@ -222,7 +228,10 @@ fn remove_override_nonexistent() { for keyword in &["remove", "unset"] { setup(&|config| { let path = { - let dir = tempdir::TempDir::new("rustup-test").unwrap(); + let dir = tempfile::Builder::new() + .prefix("rustup-test") + .tempdir() + .unwrap(); let path = std::fs::canonicalize(dir.path()).unwrap(); config.change_dir(&path, || { expect_ok(config, &["rustup", "override", "add", "nightly"]); @@ -276,7 +285,10 @@ fn list_overrides_with_nonexistent() { let trip = this_host_triple(); let nonexistent_path = { - let dir = tempdir::TempDir::new("rustup-test").unwrap(); + let dir = tempfile::Builder::new() + .prefix("rustup-test") + .tempdir() + .unwrap(); config.change_dir(dir.path(), || { expect_ok(config, &["rustup", "override", "add", "nightly"]); }); diff --git a/tests/cli-misc.rs b/tests/cli-misc.rs index 3a6c7f70fa..2fadaa948e 100644 --- a/tests/cli-misc.rs +++ b/tests/cli-misc.rs @@ -11,7 +11,6 @@ use rustup::errors::TOOLSTATE_MSG; use rustup::utils::{raw, utils}; use std::env::consts::EXE_SUFFIX; -use tempdir::TempDir; macro_rules! for_host { ($s: expr) => { @@ -571,7 +570,10 @@ fn rename_rls_remove() { #[test] fn install_stops_if_rustc_exists() { - let temp_dir = TempDir::new("fakebin").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("fakebin") + .tempdir() + .unwrap(); // Create fake executable let fake_exe = temp_dir.path().join(&format!("{}{}", "rustc", EXE_SUFFIX)); raw::append_file(&fake_exe, "").unwrap(); @@ -600,7 +602,10 @@ fn install_stops_if_rustc_exists() { #[test] fn install_stops_if_cargo_exists() { - let temp_dir = TempDir::new("fakebin").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("fakebin") + .tempdir() + .unwrap(); // Create fake executable let fake_exe = temp_dir.path().join(&format!("{}{}", "cargo", EXE_SUFFIX)); raw::append_file(&fake_exe, "").unwrap(); @@ -629,7 +634,10 @@ fn install_stops_if_cargo_exists() { #[test] fn with_no_prompt_install_succeeds_if_rustc_exists() { - let temp_dir = TempDir::new("fakebin").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("fakebin") + .tempdir() + .unwrap(); // Create fake executable let fake_exe = temp_dir.path().join(&format!("{}{}", "rustc", EXE_SUFFIX)); raw::append_file(&fake_exe, "").unwrap(); diff --git a/tests/cli-self-upd.rs b/tests/cli-self-upd.rs index 1f8c1351f3..ea871cc124 100644 --- a/tests/cli-self-upd.rs +++ b/tests/cli-self-upd.rs @@ -18,7 +18,6 @@ use std::fs; use std::path::Path; use std::process::Command; use std::sync::Mutex; -use tempdir::TempDir; macro_rules! for_host { ($s: expr) => { @@ -48,7 +47,10 @@ pub fn setup(f: &dyn Fn(&Config)) { pub fn update_setup(f: &dyn Fn(&Config, &Path)) { setup(&|config| { // Create a mock self-update server - let self_dist_tmp = TempDir::new("self_dist").unwrap(); + let self_dist_tmp = tempfile::Builder::new() + .prefix("self_dist") + .tempdir() + .unwrap(); let self_dist = self_dist_tmp.path(); let trip = this_host_triple(); @@ -380,7 +382,10 @@ fn install_with_zsh_adds_path_to_zprofile() { #[cfg(unix)] fn install_with_zsh_adds_path_to_zdotdir_zprofile() { setup(&|config| { - let zdotdir = TempDir::new("zdotdir").unwrap(); + let zdotdir = tempfile::Builder::new() + .prefix("zdotdir") + .tempdir() + .unwrap(); let my_rc = "foo\nbar\nbaz"; let rc = zdotdir.path().join(".zprofile"); raw::write_file(&rc, my_rc).unwrap(); diff --git a/tests/cli-v1.rs b/tests/cli-v1.rs index 21060883e7..7b0d9e82bb 100644 --- a/tests/cli-v1.rs +++ b/tests/cli-v1.rs @@ -8,7 +8,6 @@ use crate::mock::clitools::{ this_host_triple, Config, Scenario, }; use std::fs; -use tempdir::TempDir; macro_rules! for_host { ($s: expr) => { @@ -145,7 +144,7 @@ fn remove_default_toolchain_err_handling() { #[test] fn remove_override_toolchain_err_handling() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "default", "nightly"]); expect_ok(config, &["rustup", "override", "add", "beta"]); @@ -223,7 +222,7 @@ fn install_override_toolchain_from_version() { #[test] fn override_overrides_default() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); expect_ok(config, &["rustup", "default", "nightly"]); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "override", "add", "beta"]); @@ -235,8 +234,8 @@ fn override_overrides_default() { #[test] fn multiple_overrides() { setup(&|config| { - let tempdir1 = TempDir::new("rustup").unwrap(); - let tempdir2 = TempDir::new("rustup").unwrap(); + let tempdir1 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let tempdir2 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); expect_ok(config, &["rustup", "default", "nightly"]); config.change_dir(tempdir1.path(), &|| { @@ -260,7 +259,7 @@ fn multiple_overrides() { #[test] fn change_override() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "override", "add", "nightly"]); expect_ok(config, &["rustup", "override", "add", "beta"]); @@ -272,7 +271,7 @@ fn change_override() { #[test] fn remove_override_no_default() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "override", "add", "nightly"]); expect_ok(config, &["rustup", "override", "remove"]); @@ -284,7 +283,7 @@ fn remove_override_no_default() { #[test] fn remove_override_with_default() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "default", "nightly"]); expect_ok(config, &["rustup", "override", "add", "beta"]); @@ -297,8 +296,8 @@ fn remove_override_with_default() { #[test] fn remove_override_with_multiple_overrides() { setup(&|config| { - let tempdir1 = TempDir::new("rustup").unwrap(); - let tempdir2 = TempDir::new("rustup").unwrap(); + let tempdir1 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let tempdir2 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); expect_ok(config, &["rustup", "default", "nightly"]); config.change_dir(tempdir1.path(), &|| { expect_ok(config, &["rustup", "override", "add", "beta"]); diff --git a/tests/cli-v2.rs b/tests/cli-v2.rs index 36cd1c1897..1f6178fc54 100644 --- a/tests/cli-v2.rs +++ b/tests/cli-v2.rs @@ -9,7 +9,6 @@ use crate::mock::clitools::{ }; use std::fs; use std::io::Write; -use tempdir::TempDir; use rustup::dist::dist::TargetTriple; @@ -191,7 +190,7 @@ fn remove_default_toolchain_err_handling() { #[test] fn remove_override_toolchain_err_handling() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "default", "nightly"]); expect_ok(config, &["rustup", "override", "add", "beta"]); @@ -296,7 +295,7 @@ fn install_override_toolchain_from_version() { #[test] fn override_overrides_default() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); expect_ok(config, &["rustup", "default", "nightly"]); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "override", "add", "beta"]); @@ -308,8 +307,8 @@ fn override_overrides_default() { #[test] fn multiple_overrides() { setup(&|config| { - let tempdir1 = TempDir::new("rustup").unwrap(); - let tempdir2 = TempDir::new("rustup").unwrap(); + let tempdir1 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let tempdir2 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); expect_ok(config, &["rustup", "default", "nightly"]); config.change_dir(tempdir1.path(), &|| { @@ -361,7 +360,7 @@ fn override_windows_root() { #[test] fn change_override() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "override", "add", "nightly"]); expect_ok(config, &["rustup", "override", "add", "beta"]); @@ -373,7 +372,7 @@ fn change_override() { #[test] fn remove_override_no_default() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "override", "add", "nightly"]); expect_ok(config, &["rustup", "override", "remove"]); @@ -385,7 +384,7 @@ fn remove_override_no_default() { #[test] fn remove_override_with_default() { setup(&|config| { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.change_dir(tempdir.path(), &|| { expect_ok(config, &["rustup", "default", "nightly"]); expect_ok(config, &["rustup", "override", "add", "beta"]); @@ -398,8 +397,8 @@ fn remove_override_with_default() { #[test] fn remove_override_with_multiple_overrides() { setup(&|config| { - let tempdir1 = TempDir::new("rustup").unwrap(); - let tempdir2 = TempDir::new("rustup").unwrap(); + let tempdir1 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let tempdir2 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); expect_ok(config, &["rustup", "default", "nightly"]); config.change_dir(tempdir1.path(), &|| { expect_ok(config, &["rustup", "override", "add", "beta"]); diff --git a/tests/dist.rs b/tests/dist.rs index 40b0de148f..9e428d850f 100644 --- a/tests/dist.rs +++ b/tests/dist.rs @@ -24,8 +24,6 @@ use std::str::FromStr; use std::sync::Arc; use url::Url; -use tempdir::TempDir; - // Creates a mock dist server populated with some test data pub fn create_mock_dist_server( path: &Path, @@ -221,7 +219,7 @@ fn bonus_component(name: &'static str, contents: Arc>) -> MockPackage { #[test] fn mock_dist_server_smoke_test() { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let path = tempdir.path(); create_mock_dist_server(&path, None).write(&[ManifestVersion::V2], false); @@ -262,7 +260,7 @@ fn mock_dist_server_smoke_test() { // the next day to the new name. #[test] fn rename_component() { - let dist_tempdir = TempDir::new("rustup").unwrap(); + let dist_tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let url = Url::parse(&format!("file://{}", dist_tempdir.path().to_string_lossy())).unwrap(); let edit_1 = &|_: &str, pkgs: &mut [MockPackage]| { @@ -322,7 +320,7 @@ fn rename_component() { // Test that a rename is ignored if the component with the old name was never installed. #[test] fn rename_component_new() { - let dist_tempdir = TempDir::new("rustup").unwrap(); + let dist_tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let url = Url::parse(&format!("file://{}", dist_tempdir.path().to_string_lossy())).unwrap(); let edit_2 = &|_: &str, pkgs: &mut [MockPackage]| { @@ -436,7 +434,7 @@ fn setup( enable_xz: bool, f: &dyn Fn(&Url, &ToolchainDesc, &InstallPrefix, &DownloadCfg<'_>, &temp::Cfg), ) { - let dist_tempdir = TempDir::new("rustup").unwrap(); + let dist_tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock_dist_server = create_mock_dist_server(dist_tempdir.path(), edit); let url = Url::parse(&format!("file://{}", dist_tempdir.path().to_string_lossy())).unwrap(); setup_from_dist_server(mock_dist_server, &url, enable_xz, f); @@ -450,9 +448,9 @@ fn setup_from_dist_server( ) { server.write(&[ManifestVersion::V2], enable_xz); - let prefix_tempdir = TempDir::new("rustup").unwrap(); + let prefix_tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - let work_tempdir = TempDir::new("rustup").unwrap(); + let work_tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let temp_cfg = temp::Cfg::new( work_tempdir.path().to_owned(), DEFAULT_DIST_SERVER, diff --git a/tests/dist_install.rs b/tests/dist_install.rs index 89b1963880..23239b5f19 100644 --- a/tests/dist_install.rs +++ b/tests/dist_install.rs @@ -12,12 +12,11 @@ use rustup::utils::utils; use rustup::ErrorKind; use std::fs::File; use std::io::Write; -use tempdir::TempDir; // Just testing that the mocks work #[test] fn mock_smoke_test() { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock = MockInstallerBuilder { components: vec![ @@ -50,7 +49,7 @@ fn mock_smoke_test() { #[test] fn package_contains() { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock = MockInstallerBuilder { components: vec![ @@ -74,7 +73,7 @@ fn package_contains() { #[test] fn package_bad_version() { - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock = MockInstallerBuilder { components: vec![MockComponentBuilder { @@ -93,7 +92,7 @@ fn package_bad_version() { #[test] fn basic_install() { - let pkgdir = TempDir::new("rustup").unwrap(); + let pkgdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock = MockInstallerBuilder { components: vec![MockComponentBuilder { @@ -108,10 +107,10 @@ fn basic_install() { mock.build(pkgdir.path()); - let instdir = TempDir::new("rustup").unwrap(); + let instdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let prefix = InstallPrefix::from(instdir.path().to_owned()); - let tmpdir = TempDir::new("rustup").unwrap(); + let tmpdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( tmpdir.path().to_owned(), DEFAULT_DIST_SERVER, @@ -137,7 +136,7 @@ fn basic_install() { #[test] fn multiple_component_install() { - let pkgdir = TempDir::new("rustup").unwrap(); + let pkgdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock = MockInstallerBuilder { components: vec![ @@ -154,10 +153,10 @@ fn multiple_component_install() { mock.build(pkgdir.path()); - let instdir = TempDir::new("rustup").unwrap(); + let instdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let prefix = InstallPrefix::from(instdir.path().to_owned()); - let tmpdir = TempDir::new("rustup").unwrap(); + let tmpdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( tmpdir.path().to_owned(), DEFAULT_DIST_SERVER, @@ -183,7 +182,7 @@ fn multiple_component_install() { #[test] fn uninstall() { - let pkgdir = TempDir::new("rustup").unwrap(); + let pkgdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock = MockInstallerBuilder { components: vec![ @@ -204,10 +203,10 @@ fn uninstall() { mock.build(pkgdir.path()); - let instdir = TempDir::new("rustup").unwrap(); + let instdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let prefix = InstallPrefix::from(instdir.path().to_owned()); - let tmpdir = TempDir::new("rustup").unwrap(); + let tmpdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( tmpdir.path().to_owned(), DEFAULT_DIST_SERVER, @@ -250,7 +249,7 @@ fn uninstall_best_effort() { #[test] fn component_bad_version() { - let pkgdir = TempDir::new("rustup").unwrap(); + let pkgdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock = MockInstallerBuilder { components: vec![MockComponentBuilder { @@ -261,10 +260,10 @@ fn component_bad_version() { mock.build(pkgdir.path()); - let instdir = TempDir::new("rustup").unwrap(); + let instdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let prefix = InstallPrefix::from(instdir.path().to_owned()); - let tmpdir = TempDir::new("rustup").unwrap(); + let tmpdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( tmpdir.path().to_owned(), DEFAULT_DIST_SERVER, @@ -294,7 +293,7 @@ fn component_bad_version() { // Installing to a prefix that doesn't exist creates it automatically #[test] fn install_to_prefix_that_does_not_exist() { - let pkgdir = TempDir::new("rustup").unwrap(); + let pkgdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let mock = MockInstallerBuilder { components: vec![MockComponentBuilder { @@ -305,12 +304,12 @@ fn install_to_prefix_that_does_not_exist() { mock.build(pkgdir.path()); - let instdir = TempDir::new("rustup").unwrap(); + let instdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); // The directory that does not exist let does_not_exist = instdir.path().join("super_not_real"); let prefix = InstallPrefix::from(does_not_exist.clone()); - let tmpdir = TempDir::new("rustup").unwrap(); + let tmpdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( tmpdir.path().to_owned(), DEFAULT_DIST_SERVER, diff --git a/tests/dist_transactions.rs b/tests/dist_transactions.rs index 1f62ed28e5..8b90074072 100644 --- a/tests/dist_transactions.rs +++ b/tests/dist_transactions.rs @@ -9,12 +9,11 @@ use rustup::ErrorKind; use std::fs; use std::io::Write; use std::path::PathBuf; -use tempdir::TempDir; #[test] fn add_file() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let prefix = InstallPrefix::from(prefixdir.path().to_owned()); @@ -41,8 +40,8 @@ fn add_file() { #[test] fn add_file_then_rollback() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let prefix = InstallPrefix::from(prefixdir.path().to_owned()); @@ -63,8 +62,8 @@ fn add_file_then_rollback() { #[test] fn add_file_that_exists() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -93,9 +92,9 @@ fn add_file_that_exists() { #[test] fn copy_file() { - let srcdir = TempDir::new("rustup").unwrap(); - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let srcdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -120,9 +119,9 @@ fn copy_file() { #[test] fn copy_file_then_rollback() { - let srcdir = TempDir::new("rustup").unwrap(); - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let srcdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -147,9 +146,9 @@ fn copy_file_then_rollback() { #[test] fn copy_file_that_exists() { - let srcdir = TempDir::new("rustup").unwrap(); - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let srcdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -183,9 +182,9 @@ fn copy_file_that_exists() { #[test] fn copy_dir() { - let srcdir = TempDir::new("rustup").unwrap(); - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let srcdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -217,9 +216,9 @@ fn copy_dir() { #[test] fn copy_dir_then_rollback() { - let srcdir = TempDir::new("rustup").unwrap(); - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let srcdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -251,9 +250,9 @@ fn copy_dir_then_rollback() { #[test] fn copy_dir_that_exists() { - let srcdir = TempDir::new("rustup").unwrap(); - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let srcdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -283,8 +282,8 @@ fn copy_dir_that_exists() { #[test] fn remove_file() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -308,8 +307,8 @@ fn remove_file() { #[test] fn remove_file_then_rollback() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -333,8 +332,8 @@ fn remove_file_then_rollback() { #[test] fn remove_file_that_not_exists() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -360,8 +359,8 @@ fn remove_file_that_not_exists() { #[test] fn remove_dir() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -386,8 +385,8 @@ fn remove_dir() { #[test] fn remove_dir_then_rollback() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -412,8 +411,8 @@ fn remove_dir_then_rollback() { #[test] fn remove_dir_that_not_exists() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -439,8 +438,8 @@ fn remove_dir_that_not_exists() { #[test] fn write_file() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -466,8 +465,8 @@ fn write_file() { #[test] fn write_file_then_rollback() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -490,8 +489,8 @@ fn write_file_then_rollback() { #[test] fn write_file_that_exists() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -523,8 +522,8 @@ fn write_file_that_exists() { // but the file is not. #[test] fn modify_file_that_not_exists() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -547,8 +546,8 @@ fn modify_file_that_not_exists() { // If the file does exist, then it's just backed up #[test] fn modify_file_that_exists() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -571,8 +570,8 @@ fn modify_file_that_exists() { #[test] fn modify_file_that_not_exists_then_rollback() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -593,8 +592,8 @@ fn modify_file_that_not_exists_then_rollback() { #[test] fn modify_file_that_exists_then_rollback() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -620,8 +619,8 @@ fn modify_file_that_exists_then_rollback() { // to overwrite the earliest backup. #[test] fn modify_twice_then_rollback() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -646,9 +645,9 @@ fn modify_twice_then_rollback() { } fn do_multiple_op_transaction(rollback: bool) { - let srcdir = TempDir::new("rustup").unwrap(); - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let srcdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), @@ -748,8 +747,8 @@ fn multiple_op_transaction_then_rollback() { // continue to rollback other steps. #[test] fn rollback_failure_keeps_going() { - let prefixdir = TempDir::new("rustup").unwrap(); - let txdir = TempDir::new("rustup").unwrap(); + let prefixdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); + let txdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tmpcfg = temp::Cfg::new( txdir.path().to_owned(), diff --git a/tests/mock/clitools.rs b/tests/mock/clitools.rs index ebade73900..40e5415617 100644 --- a/tests/mock/clitools.rs +++ b/tests/mock/clitools.rs @@ -17,7 +17,6 @@ use std::io::{self, Read, Write}; use std::path::{Path, PathBuf}; use std::process::Command; use std::sync::Arc; -use tempdir::TempDir; use url::Url; /// The configuration used by the tests in this module @@ -83,29 +82,37 @@ pub fn setup(s: Scenario, f: &dyn Fn(&mut Config)) { let test_dir = exe_dir.parent().unwrap().join("tests"); fs::create_dir_all(&test_dir).unwrap(); - let exedir = TempDir::new_in(&test_dir, "rustup-exe").unwrap(); - let distdir = TempDir::new_in(&test_dir, "rustup-dist").unwrap(); - let rustupdir = TempDir::new_in(&test_dir, "rustup").unwrap(); - let customdir = TempDir::new_in(&test_dir, "rustup-custom").unwrap(); - let cargodir = TempDir::new_in(&test_dir, "rustup-cargo").unwrap(); - let homedir = TempDir::new_in(&test_dir, "rustup-home").unwrap(); - let emptydir = TempDir::new_in(&test_dir, "rustup-empty").unwrap(); - let workdir = TempDir::new_in(&test_dir, "rustup-workdir").unwrap(); + fn tempdir_in_with_prefix(path: &Path, prefix: &str) -> PathBuf { + tempfile::Builder::new() + .prefix(prefix) + .tempdir_in(path) + .unwrap() + .into_path() + } + + let exedir = tempdir_in_with_prefix(&test_dir, "rustup-exe"); + let distdir = tempdir_in_with_prefix(&test_dir, "rustup-dist"); + let rustupdir = tempdir_in_with_prefix(&test_dir, "rustup"); + let customdir = tempdir_in_with_prefix(&test_dir, "rustup-custom"); + let cargodir = tempdir_in_with_prefix(&test_dir, "rustup-cargo"); + let homedir = tempdir_in_with_prefix(&test_dir, "rustup-home"); + let emptydir = tempdir_in_with_prefix(&test_dir, "rustup-empty"); + let workdir = tempdir_in_with_prefix(&test_dir, "rustup-workdir"); // The uninstall process on windows involves using the directory above // CARGO_HOME, so make sure it's a subdir of our tempdir - let cargodir = cargodir.path().join("ch"); + let cargodir = cargodir.join("ch"); fs::create_dir(&cargodir).unwrap(); let mut config = Config { - exedir: exedir.path().to_owned(), - distdir: distdir.path().to_owned(), - rustupdir: rustupdir.path().to_owned(), - customdir: customdir.path().to_owned(), + exedir, + distdir, + rustupdir, + customdir, cargodir, - homedir: homedir.path().to_owned(), - emptydir: emptydir.path().to_owned(), - workdir: RefCell::new(workdir.path().to_owned()), + homedir, + emptydir, + workdir: RefCell::new(workdir), }; create_mock_dist_server(&config.distdir, s); @@ -868,7 +875,7 @@ fn mock_bin(name: &str, version: &str, version_hash: &str) -> Vec { lazy_static! { static ref MOCK_BIN: Arc> = { // Create a temp directory to hold the source and the output - let tempdir = TempDir::new("rustup").unwrap(); + let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let source_path = tempdir.path().join("in.rs"); let dest_path = tempdir.path().join(&format!("out{}", EXE_SUFFIX)); diff --git a/tests/mock/dist.rs b/tests/mock/dist.rs index 5cd0fe7fb9..ff529da962 100644 --- a/tests/mock/dist.rs +++ b/tests/mock/dist.rs @@ -9,7 +9,6 @@ use std::fs::{self, File}; use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use std::sync::Mutex; -use tempdir::TempDir; use url::Url; use crate::mock::clitools::hard_link; @@ -180,7 +179,7 @@ impl MockDistServer { fs::create_dir_all(&archive_dir).unwrap(); - let tmpdir = TempDir::new("rustup").unwrap(); + let tmpdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let workdir = tmpdir.path().join("work"); let installer_name = if target_package.target != "*" {