replace tempdir by tempfile (#2143)

## Issue Addressed

Fixes #2141 
Remove [tempdir](https://docs.rs/tempdir/0.3.7/tempdir/) in favor of [tempfile](https://docs.rs/tempfile/3.1.0/tempfile/).

## Proposed Changes

`tempfile` has a slightly different api that makes creating temp folders with a name prefix a chore (`tempdir::TempDir::new("toto")` => `tempfile::Builder::new().prefix("toto").tempdir()`).

So I removed temp folder name prefix where I deemed it not useful.

Otherwise, the functionality is the same.
This commit is contained in:
Arthur Woimbée
2021-01-06 06:36:11 +00:00
parent 7e4b190df0
commit 851a4dca3c
21 changed files with 64 additions and 74 deletions

View File

@@ -8,4 +8,4 @@ edition = "2018"
fs2 = "0.4.3"
[dev-dependencies]
tempdir = "0.3.7"
tempfile = "3.1.0"

View File

@@ -72,14 +72,14 @@ impl Drop for Lockfile {
#[cfg(test)]
mod test {
use super::*;
use tempdir::TempDir;
use tempfile::tempdir;
#[cfg(unix)]
use std::{fs::Permissions, os::unix::fs::PermissionsExt};
#[test]
fn new_lock() {
let temp = TempDir::new("lock_test").unwrap();
let temp = tempdir().unwrap();
let path = temp.path().join("lockfile");
let _lock = Lockfile::new(path.clone()).unwrap();
@@ -91,7 +91,7 @@ mod test {
#[test]
fn relock_after_drop() {
let temp = TempDir::new("lock_test").unwrap();
let temp = tempdir().unwrap();
let path = temp.path().join("lockfile");
let lock1 = Lockfile::new(path.clone()).unwrap();
@@ -105,7 +105,7 @@ mod test {
#[test]
fn lockfile_exists() {
let temp = TempDir::new("lock_test").unwrap();
let temp = tempdir().unwrap();
let path = temp.path().join("lockfile");
let _lockfile = File::create(&path).unwrap();
@@ -117,7 +117,7 @@ mod test {
#[test]
#[cfg(unix)]
fn permission_denied_create() {
let temp = TempDir::new("lock_test").unwrap();
let temp = tempdir().unwrap();
let path = temp.path().join("lockfile");
let lockfile = File::create(&path).unwrap();