From c8d6619d71d6ea4104589dbc4d3b6527dbc63768 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Fri, 16 Apr 2021 19:29:27 -0400 Subject: [PATCH] Replace tempfile with tempdir --- Cargo.lock | 59 ++------------------------------ cli/Cargo.toml | 2 +- cli/src/invocation/cmd/sync.rs | 4 +-- cli/src/invocation/test.rs | 2 +- sync-server/Cargo.toml | 2 +- sync-server/src/storage/kv.rs | 10 +++--- taskchampion/Cargo.toml | 2 +- taskchampion/src/server/local.rs | 10 +++--- taskchampion/src/storage/kv.rs | 30 ++++++++-------- 9 files changed, 34 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f5ede44f..9f48a47b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -841,12 +841,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -1702,19 +1696,6 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.7.3" @@ -1759,21 +1740,6 @@ dependencies = [ "rand_core 0.6.2", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -1810,15 +1776,6 @@ dependencies = [ "rand_core 0.6.2", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" version = "0.1.57" @@ -2232,7 +2189,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "tempdir", + "tempfile", "thiserror", "tindercrypt", "ureq", @@ -2254,7 +2211,7 @@ dependencies = [ "predicates", "prettytable-rs", "taskchampion", - "tempdir", + "tempfile", "termcolor", "textwrap 0.13.4", ] @@ -2272,20 +2229,10 @@ dependencies = [ "kv", "log", "serde", - "tempdir", + "tempfile", "uuid", ] -[[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -dependencies = [ - "rand 0.4.6", - "remove_dir_all", -] - [[package]] name = "tempfile" version = "3.1.0" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index bc881bc0f..570d106da 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -26,4 +26,4 @@ path = "../taskchampion" [dev-dependencies] assert_cmd = "^1.0.3" predicates = "^1.0.7" -tempdir = "^0.3.7" +tempfile = "3" diff --git a/cli/src/invocation/cmd/sync.rs b/cli/src/invocation/cmd/sync.rs index 9acc8e581..9a1bb18d2 100644 --- a/cli/src/invocation/cmd/sync.rs +++ b/cli/src/invocation/cmd/sync.rs @@ -15,13 +15,13 @@ pub(crate) fn execute( mod test { use super::*; use crate::invocation::test::*; - use tempdir::TempDir; + use tempfile::TempDir; #[test] fn test_add() { let mut w = test_writer(); let mut replica = test_replica(); - let server_dir = TempDir::new("test").unwrap(); + let server_dir = TempDir::new().unwrap(); let mut server = test_server(&server_dir); // Note that the details of the actual sync are tested thoroughly in the taskchampion crate diff --git a/cli/src/invocation/test.rs b/cli/src/invocation/test.rs index 5dcac753c..72f11e137 100644 --- a/cli/src/invocation/test.rs +++ b/cli/src/invocation/test.rs @@ -1,6 +1,6 @@ use std::io; use taskchampion::{storage, Replica, Server, ServerConfig}; -use tempdir::TempDir; +use tempfile::TempDir; pub(super) fn test_replica() -> Replica { let storage = storage::InMemoryStorage::new(); diff --git a/sync-server/Cargo.toml b/sync-server/Cargo.toml index 6ea4ed4ff..2a42298be 100644 --- a/sync-server/Cargo.toml +++ b/sync-server/Cargo.toml @@ -19,4 +19,4 @@ env_logger = "^0.8.3" [dev-dependencies] actix-rt = "^2.2.0" -tempdir = "^0.3.7" +tempfile = "3" diff --git a/sync-server/src/storage/kv.rs b/sync-server/src/storage/kv.rs index 89a4d3380..bd5fa3502 100644 --- a/sync-server/src/storage/kv.rs +++ b/sync-server/src/storage/kv.rs @@ -164,11 +164,11 @@ impl<'t> StorageTxn for Txn<'t> { #[cfg(test)] mod test { use super::*; - use tempdir::TempDir; + use tempfile::TempDir; #[test] fn test_get_client_empty() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let storage = KvStorage::new(&tmp_dir.path())?; let mut txn = storage.txn()?; let maybe_client = txn.get_client(Uuid::new_v4())?; @@ -178,7 +178,7 @@ mod test { #[test] fn test_client_storage() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let storage = KvStorage::new(&tmp_dir.path())?; let mut txn = storage.txn()?; @@ -200,7 +200,7 @@ mod test { #[test] fn test_gvbp_empty() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let storage = KvStorage::new(&tmp_dir.path())?; let mut txn = storage.txn()?; let maybe_version = txn.get_version_by_parent(Uuid::new_v4(), Uuid::new_v4())?; @@ -210,7 +210,7 @@ mod test { #[test] fn test_add_version_and_gvbp() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let storage = KvStorage::new(&tmp_dir.path())?; let mut txn = storage.txn()?; diff --git a/taskchampion/Cargo.toml b/taskchampion/Cargo.toml index e0c04769d..2505d1ef9 100644 --- a/taskchampion/Cargo.toml +++ b/taskchampion/Cargo.toml @@ -25,4 +25,4 @@ tindercrypt = { version = "^0.2.2", default-features = false } [dev-dependencies] proptest = "^1.0.0" -tempdir = "^0.3.7" +tempfile = "3" diff --git a/taskchampion/src/server/local.rs b/taskchampion/src/server/local.rs index 84ee18fa8..bdd3c5dbd 100644 --- a/taskchampion/src/server/local.rs +++ b/taskchampion/src/server/local.rs @@ -151,11 +151,11 @@ impl<'t> Server for LocalServer<'t> { #[cfg(test)] mod test { use super::*; - use tempdir::TempDir; + use tempfile::TempDir; #[test] fn test_empty() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut server = LocalServer::new(&tmp_dir.path())?; let child_version = server.get_child_version(NO_VERSION_ID)?; assert_eq!(child_version, GetVersionResult::NoSuchVersion); @@ -164,7 +164,7 @@ mod test { #[test] fn test_add_zero_base() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut server = LocalServer::new(&tmp_dir.path())?; let history = b"1234".to_vec(); match server.add_version(NO_VERSION_ID, history.clone())? { @@ -189,7 +189,7 @@ mod test { #[test] fn test_add_nonzero_base() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut server = LocalServer::new(&tmp_dir.path())?; let history = b"1234".to_vec(); let parent_version_id = Uuid::new_v4() as VersionId; @@ -217,7 +217,7 @@ mod test { #[test] fn test_add_nonzero_base_forbidden() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut server = LocalServer::new(&tmp_dir.path())?; let history = b"1234".to_vec(); let parent_version_id = Uuid::new_v4() as VersionId; diff --git a/taskchampion/src/storage/kv.rs b/taskchampion/src/storage/kv.rs index c33e78e72..e65e31dfa 100644 --- a/taskchampion/src/storage/kv.rs +++ b/taskchampion/src/storage/kv.rs @@ -354,11 +354,11 @@ impl<'t> StorageTxn for Txn<'t> { mod test { use super::*; use crate::storage::taskmap_with; - use tempdir::TempDir; + use tempfile::TempDir; #[test] fn test_create() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid = Uuid::new_v4(); { @@ -376,7 +376,7 @@ mod test { #[test] fn test_create_exists() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid = Uuid::new_v4(); { @@ -394,7 +394,7 @@ mod test { #[test] fn test_get_missing() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid = Uuid::new_v4(); { @@ -407,7 +407,7 @@ mod test { #[test] fn test_set_task() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid = Uuid::new_v4(); { @@ -428,7 +428,7 @@ mod test { #[test] fn test_delete_task_missing() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid = Uuid::new_v4(); { @@ -440,7 +440,7 @@ mod test { #[test] fn test_delete_task_exists() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid = Uuid::new_v4(); { @@ -457,7 +457,7 @@ mod test { #[test] fn test_all_tasks_empty() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; { let mut txn = storage.txn()?; @@ -469,7 +469,7 @@ mod test { #[test] fn test_all_tasks_and_uuids() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); @@ -523,7 +523,7 @@ mod test { #[test] fn test_base_version_default() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; { let mut txn = storage.txn()?; @@ -534,7 +534,7 @@ mod test { #[test] fn test_base_version_setting() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let u = Uuid::new_v4(); { @@ -551,7 +551,7 @@ mod test { #[test] fn test_operations() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); @@ -615,7 +615,7 @@ mod test { #[test] fn get_working_set_empty() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; { @@ -629,7 +629,7 @@ mod test { #[test] fn add_to_working_set() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); @@ -652,7 +652,7 @@ mod test { #[test] fn clear_working_set() -> anyhow::Result<()> { - let tmp_dir = TempDir::new("test")?; + let tmp_dir = TempDir::new()?; let mut storage = KvStorage::new(&tmp_dir.path())?; let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4();