Blob Blame History Raw
From 1abf458554788f6bc91e454b671ec4b41dc0eb44 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Sun, 9 Jun 2019 21:53:22 +0200
Subject: [PATCH] chore: Switch from tempdir to tempfile

Former is deprecated.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
---
 src/icon.rs          | 18 +++++++++---------
 src/main.rs          |  2 +-
 src/meta/filetype.rs | 14 +++++++-------
 src/meta/name.rs     | 13 ++++++-------
 src/sort.rs          | 12 ++++++------
 5 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/src/icon.rs b/src/icon.rs
index ac43e88..634fdd2 100644
--- a/src/icon.rs
+++ b/src/icon.rs
@@ -311,11 +311,11 @@ mod test {
     use super::{Icons, Theme, ICON_SPACE};
     use crate::meta::Meta;
     use std::fs::File;
-    use tempdir::TempDir;
+    use tempfile::tempdir;
 
     #[test]
     fn get_no_icon() {
-        let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let file_path = tmp_dir.path().join("file.txt");
         File::create(&file_path).expect("failed to create file");
         let meta = Meta::from_path(&file_path).unwrap();
@@ -328,7 +328,7 @@ mod test {
 
     #[test]
     fn get_default_file_icon() {
-        let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let file_path = tmp_dir.path().join("file");
         File::create(&file_path).expect("failed to create file");
         let meta = Meta::from_path(&file_path).unwrap();
@@ -341,7 +341,7 @@ mod test {
 
     #[test]
     fn get_default_file_icon_unicode() {
-        let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let file_path = tmp_dir.path().join("file");
         File::create(&file_path).expect("failed to create file");
         let meta = Meta::from_path(&file_path).unwrap();
@@ -354,7 +354,7 @@ mod test {
 
     #[test]
     fn get_directory_icon() {
-        let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let file_path = tmp_dir.path();
         let meta = Meta::from_path(&file_path.to_path_buf()).unwrap();
 
@@ -366,7 +366,7 @@ mod test {
 
     #[test]
     fn get_directory_icon_unicode() {
-        let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let file_path = tmp_dir.path();
         let meta = Meta::from_path(&file_path.to_path_buf()).unwrap();
 
@@ -378,7 +378,7 @@ mod test {
 
     #[test]
     fn get_directory_icon_with_ext() {
-        let tmp_dir = TempDir::new("test_file_type.rs").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let file_path = tmp_dir.path();
         let meta = Meta::from_path(&file_path.to_path_buf()).unwrap();
 
@@ -390,7 +390,7 @@ mod test {
 
     #[test]
     fn get_icon_by_name() {
-        let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         for (file_name, file_icon) in &Icons::get_default_icons_by_name() {
             let file_path = tmp_dir.path().join(file_name);
@@ -406,7 +406,7 @@ mod test {
 
     #[test]
     fn get_icon_by_extension() {
-        let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         for (ext, file_icon) in &Icons::get_default_icons_by_extension() {
             let file_path = tmp_dir.path().join(format!("file.{}", ext));
diff --git a/src/main.rs b/src/main.rs
index d826d84..87440b6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,7 +12,7 @@ extern crate chrono_humanize;
 extern crate libc;
 extern crate lscolors;
 #[cfg(test)]
-extern crate tempdir;
+extern crate tempfile;
 extern crate term_grid;
 extern crate terminal_size;
 extern crate time;
diff --git a/src/meta/filetype.rs b/src/meta/filetype.rs
index d3b3b23..a031a08 100644
--- a/src/meta/filetype.rs
+++ b/src/meta/filetype.rs
@@ -102,12 +102,12 @@ mod test {
     use std::os::unix::net::UnixListener;
     #[cfg(unix)]
     use std::process::Command;
-    use tempdir::TempDir;
+    use tempfile::tempdir;
 
     #[test]
     #[cfg(unix)] // Windows uses different default permissions
     fn test_file_type() {
-        let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the file;
         let file_path = tmp_dir.path().join("file.txt");
@@ -122,7 +122,7 @@ mod test {
 
     #[test]
     fn test_dir_type() {
-        let tmp_dir = TempDir::new("test_dir_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let meta =
             Meta::from_path(&tmp_dir.path().to_path_buf()).expect("failed to get tempdir path");
         let metadata = tmp_dir.path().metadata().expect("failed to get metas");
@@ -136,7 +136,7 @@ mod test {
     #[test]
     #[cfg(unix)] // Symlink support is *hard* on Windows
     fn test_symlink_type() {
-        let tmp_dir = TempDir::new("test_symlink_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the file;
         let file_path = tmp_dir.path().join("file.tmp");
@@ -158,7 +158,7 @@ mod test {
     #[test]
     #[cfg(unix)] // Windows pipes aren't like Unix pipes
     fn test_pipe_type() {
-        let tmp_dir = TempDir::new("test_pipe_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the pipe;
         let pipe_path = tmp_dir.path().join("pipe.tmp");
@@ -179,7 +179,7 @@ mod test {
     #[test]
     #[cfg(feature = "sudo")]
     fn test_char_device_type() {
-        let tmp_dir = TempDir::new("test_char_device_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the char device;
         let char_device_path = tmp_dir.path().join("char-device.tmp");
@@ -204,7 +204,7 @@ mod test {
     #[test]
     #[cfg(unix)] // Sockets don't work the same way on Windows
     fn test_socket_type() {
-        let tmp_dir = TempDir::new("test_socket_type").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the socket;
         let socket_path = tmp_dir.path().join("socket.tmp");
diff --git a/src/meta/name.rs b/src/meta/name.rs
index 36dfb19..7c784f4 100644
--- a/src/meta/name.rs
+++ b/src/meta/name.rs
@@ -112,12 +112,12 @@ mod test {
     use std::path::Path;
     #[cfg(unix)]
     use std::process::Command;
-    use tempdir::TempDir;
+    use tempfile::tempdir;
 
     #[test]
     #[cfg(unix)] // Windows uses different default permissions
     fn test_print_file_name() {
-        let tmp_dir = TempDir::new("test_print_file_name").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let icons = Icons::new(icon::Theme::Fancy);
 
         // Create the file;
@@ -137,7 +137,7 @@ mod test {
 
     #[test]
     fn test_print_dir_name() {
-        let tmp_dir = TempDir::new("test_print_dir_name").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let icons = Icons::new(icon::Theme::Fancy);
 
         // Chreate the directory
@@ -156,7 +156,7 @@ mod test {
     #[test]
     #[cfg(unix)] // Symlinks are hard on Windows
     fn test_print_symlink_name() {
-        let tmp_dir = TempDir::new("test_symlink_name").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let icons = Icons::new(icon::Theme::Fancy);
 
         // Create the file;
@@ -183,7 +183,7 @@ mod test {
     #[test]
     #[cfg(unix)]
     fn test_print_other_type_name() {
-        let tmp_dir = TempDir::new("test_other_type_name").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let icons = Icons::new(icon::Theme::Fancy);
 
         // Create the pipe;
@@ -208,8 +208,7 @@ mod test {
 
     #[test]
     fn test_print_without_icon_or_color() {
-        let tmp_dir =
-            TempDir::new("test_print_without_icon_or_color").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
         let icons = Icons::new(icon::Theme::NoIcon);
 
         // Create the file;
diff --git a/src/sort.rs b/src/sort.rs
index c1fe81b..b6a8c36 100644
--- a/src/sort.rs
+++ b/src/sort.rs
@@ -91,11 +91,11 @@ mod tests {
     use crate::flags::Flags;
     use std::fs::{create_dir, File};
     use std::process::Command;
-    use tempdir::TempDir;
+    use tempfile::tempdir;
 
     #[test]
     fn test_sort_by_meta_by_name_with_dirs_first() {
-        let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the file;
         let path_a = tmp_dir.path().join("zzz");
@@ -120,7 +120,7 @@ mod tests {
 
     #[test]
     fn test_sort_by_meta_by_name_with_files_first() {
-        let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the file;
         let path_a = tmp_dir.path().join("zzz");
@@ -144,7 +144,7 @@ mod tests {
 
     #[test]
     fn test_sort_by_meta_by_name_unordered() {
-        let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the file;
         let path_a = tmp_dir.path().join("aaa");
@@ -169,7 +169,7 @@ mod tests {
 
     #[test]
     fn test_sort_by_meta_by_name_unordered_2() {
-        let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the file;
         let path_a = tmp_dir.path().join("zzz");
@@ -194,7 +194,7 @@ mod tests {
 
     #[test]
     fn test_sort_by_meta_by_time() {
-        let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir");
+        let tmp_dir = tempdir().expect("failed to create temp dir");
 
         // Create the file;
         let path_a = tmp_dir.path().join("aaa");
-- 
2.22.0.rc3