From 273fcd1ab032319aeea91e0ee72fad6feb0f61e9 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 29 Jan 2020 12:08:26 +0100 Subject: [PATCH] tests: Replace tempdir with tempfile The tempdir crate, a dev-dependency needed for the tests, has been deprecated in favor of tempfile. This patch replaces tempdir 0.3.7 with tempfile 3.1.0. Note that this patch also removes the prefixes from the temporary directories: They are no longer required by the API, and they are not needed for the tests. --- Cargo.lock | 25 +------------------------ Cargo.toml | 2 +- tests/cargo-upgrade.rs | 5 ++--- tests/utils.rs | 5 ++--- 4 files changed, 6 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc0bb812d1..10eec972b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,7 +162,7 @@ dependencies = [ "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "subprocess 0.1.20 (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)", "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "toml_edit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -943,18 +943,6 @@ dependencies = [ "proc-macro2 1.0.8 (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.66 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand" version = "0.7.3" @@ -1291,15 +1279,6 @@ dependencies = [ "unicode-xid 0.2.0 (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" @@ -1771,7 +1750,6 @@ dependencies = [ "checksum proc-macro-error-attr 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c2bf5d493cf5d3e296beccfd61794e445e830dfc8070a9c248ad3ee071392c6c" "checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" @@ -1809,7 +1787,6 @@ dependencies = [ "checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" "checksum syn-mid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd3937748a7eccff61ba5b90af1a20dbf610858923a9192ea0ecb0cb77db1d0" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -"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 termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" diff --git a/Cargo.toml b/Cargo.toml index ea8681d8d4..f491592459 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,7 @@ version = "0.9.0" [dev-dependencies] assert_cli = "0.6.3" pretty_assertions = "0.6.1" -tempdir = "0.3.7" +tempfile = "3.1" [features] default = [ diff --git a/tests/cargo-upgrade.rs b/tests/cargo-upgrade.rs index ebf49c6329..a81da933d7 100644 --- a/tests/cargo-upgrade.rs +++ b/tests/cargo-upgrade.rs @@ -10,11 +10,10 @@ use crate::utils::{ }; /// Helper function that copies the workspace test into a temporary directory. -pub fn copy_workspace_test() -> (tempdir::TempDir, String, Vec) { +pub fn copy_workspace_test() -> (tempfile::TempDir, String, Vec) { // Create a temporary directory and copy in the root manifest, the dummy rust file, and // workspace member manifests. - let tmpdir = tempdir::TempDir::new("upgrade_workspace") - .expect("failed to construct temporary directory"); + let tmpdir = tempfile::tempdir().expect("failed to construct temporary directory"); let (root_manifest_path, workspace_manifest_paths) = { // Helper to copy in files to the temporary workspace. The standard library doesn't have a diff --git a/tests/utils.rs b/tests/utils.rs index 3babef63cb..5638856bbe 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -4,9 +4,8 @@ use std::io::prelude::*; use std::{env, fs, path::Path, path::PathBuf, process}; /// Create temporary working directory with Cargo.toml manifest -pub fn clone_out_test(source: &str) -> (tempdir::TempDir, String) { - let tmpdir = - tempdir::TempDir::new("cargo-edit-test").expect("failed to construct temporary directory"); +pub fn clone_out_test(source: &str) -> (tempfile::TempDir, String) { + let tmpdir = tempfile::tempdir().expect("failed to construct temporary directory"); fs::copy(source, tmpdir.path().join("Cargo.toml")) .unwrap_or_else(|err| panic!("could not copy test manifest: {}", err)); let path = tmpdir