From 3e6054a9ac4fee91a9d62afe9e988aa06b5b0c06 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 25 Apr 2018 10:28:23 +0200 Subject: [PATCH] tempdir -> tempfile --- Cargo.lock | 17 ++++++++++------- components/content/Cargo.toml | 2 +- components/content/src/lib.rs | 2 +- components/content/src/page.rs | 8 ++++---- components/rebuild/Cargo.toml | 2 +- components/rebuild/tests/rebuild.rs | 10 +++++----- components/site/Cargo.toml | 2 +- components/site/benches/render.rs | 14 +++++++------- components/site/benches/site.rs | 4 ++-- components/site/src/lib.rs | 2 +- components/site/tests/site.rs | 22 +++++++++++----------- components/utils/Cargo.toml | 2 +- components/utils/src/fs.rs | 4 ++-- components/utils/src/lib.rs | 2 +- 14 files changed, 48 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3dd94178..9023ba27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,7 +208,7 @@ dependencies = [ "rendering 0.1.0", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "tera 0.11.8 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "utils 0.1.0", @@ -1040,7 +1040,7 @@ dependencies = [ "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "highlighting 0.1.0", "site 0.1.0", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1256,7 +1256,7 @@ dependencies = [ "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "taxonomies 0.1.0", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "templates 0.1.0", "tera 0.11.8 (registry+https://github.com/rust-lang/crates.io-index)", "utils 0.1.0", @@ -1421,12 +1421,15 @@ dependencies = [ ] [[package]] -name = "tempdir" -version = "0.3.7" +name = "tempfile" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1640,7 +1643,7 @@ name = "utils" version = "0.1.0" dependencies = [ "errors 0.1.0", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "tera 0.11.8 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1888,7 +1891,7 @@ dependencies = [ "checksum syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c67da57e61ebc7b7b6fff56bb34440ca3a83db037320b0507af4c10368deda7d" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum syntect 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc8a6f0db88d4afc340522c20d260411e746b2225b257c6b238a75de9d7cec78" -"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" +"checksum tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "47776f63b85777d984a50ce49d6b9e58826b6a3766a449fc95bc66cd5663c15b" "checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508" "checksum tera 0.11.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fc0624177c585227fee0c5021bd6be3a1acf66bdb6f412acb92373637aad728b" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" diff --git a/components/content/Cargo.toml b/components/content/Cargo.toml index 73aaabff..80cfec13 100644 --- a/components/content/Cargo.toml +++ b/components/content/Cargo.toml @@ -16,6 +16,6 @@ rendering = { path = "../rendering" } front_matter = { path = "../front_matter" } [dev-dependencies] -tempdir = "0.3" +tempfile = "3" toml = "0.4" globset = "0.4" diff --git a/components/content/src/lib.rs b/components/content/src/lib.rs index b3a45183..a0fddac4 100644 --- a/components/content/src/lib.rs +++ b/components/content/src/lib.rs @@ -10,7 +10,7 @@ extern crate rendering; extern crate utils; #[cfg(test)] -extern crate tempdir; +extern crate tempfile; #[cfg(test)] extern crate toml; #[cfg(test)] diff --git a/components/content/src/page.rs b/components/content/src/page.rs index 7b403244..b3cd820b 100644 --- a/components/content/src/page.rs +++ b/components/content/src/page.rs @@ -255,7 +255,7 @@ mod tests { use std::path::Path; use tera::Tera; - use tempdir::TempDir; + use tempfile::tempdir; use globset::{Glob, GlobSetBuilder}; use config::Config; @@ -387,7 +387,7 @@ Hello world #[test] fn page_with_assets_gets_right_info() { - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let path = tmp_dir.path(); create_dir(&path.join("content")).expect("create content temp dir"); create_dir(&path.join("content").join("posts")).expect("create posts temp dir"); @@ -413,7 +413,7 @@ Hello world #[test] fn page_with_assets_and_slug_overrides_path() { - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let path = tmp_dir.path(); create_dir(&path.join("content")).expect("create content temp dir"); create_dir(&path.join("content").join("posts")).expect("create posts temp dir"); @@ -439,7 +439,7 @@ Hello world #[test] fn page_with_ignored_assets_filters_out_correct_files() { - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let path = tmp_dir.path(); create_dir(&path.join("content")).expect("create content temp dir"); create_dir(&path.join("content").join("posts")).expect("create posts temp dir"); diff --git a/components/rebuild/Cargo.toml b/components/rebuild/Cargo.toml index a6ae5b70..b8f37e7d 100644 --- a/components/rebuild/Cargo.toml +++ b/components/rebuild/Cargo.toml @@ -11,5 +11,5 @@ content = { path = "../content" } site = { path = "../site" } [dev-dependencies] -tempdir = "0.3" +tempfile = "3" fs_extra = "1.1" diff --git a/components/rebuild/tests/rebuild.rs b/components/rebuild/tests/rebuild.rs index 9aeabfbc..12cdb415 100644 --- a/components/rebuild/tests/rebuild.rs +++ b/components/rebuild/tests/rebuild.rs @@ -1,6 +1,6 @@ extern crate rebuild; extern crate site; -extern crate tempdir; +extern crate tempfile; extern crate fs_extra; use std::env; @@ -8,7 +8,7 @@ use std::fs::{remove_dir_all, File}; use std::io::prelude::*; use fs_extra::dir; -use tempdir::TempDir; +use tempfile::tempdir; use site::Site; use rebuild::after_content_change; @@ -74,7 +74,7 @@ macro_rules! file_contains { #[test] fn can_rebuild_after_simple_change_to_page_content() { - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let (site_path, mut site) = load_and_build_site!(tmp_dir); let file_path = edit_file!(site_path, "content/rebuild/first.md", br#" +++ @@ -92,7 +92,7 @@ Some content"#); #[test] fn can_rebuild_after_title_change_page_global_func_usage() { - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let (site_path, mut site) = load_and_build_site!(tmp_dir); let file_path = edit_file!(site_path, "content/rebuild/first.md", br#" +++ @@ -110,7 +110,7 @@ date = 2017-01-01 #[test] fn can_rebuild_after_sort_change_in_section() { - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let (site_path, mut site) = load_and_build_site!(tmp_dir); let file_path = edit_file!(site_path, "content/rebuild/_index.md", br#" +++ diff --git a/components/site/Cargo.toml b/components/site/Cargo.toml index 2299932f..eb70efa8 100644 --- a/components/site/Cargo.toml +++ b/components/site/Cargo.toml @@ -22,4 +22,4 @@ content = { path = "../content" } search = { path = "../search" } [dev-dependencies] -tempdir = "0.3" +tempfile = "3" diff --git a/components/site/benches/render.rs b/components/site/benches/render.rs index 3208abec..6d23277b 100644 --- a/components/site/benches/render.rs +++ b/components/site/benches/render.rs @@ -3,12 +3,12 @@ #![feature(test)] extern crate test; extern crate site; -extern crate tempdir; +extern crate tempfile; use std::env; use site::Site; -use tempdir::TempDir; +use tempfile::tempdir; #[bench] @@ -17,7 +17,7 @@ fn bench_rendering_small_blog(b: &mut test::Bencher) { path.push("benches"); path.push("small-blog"); let mut site = Site::new(&path, "config.toml").unwrap(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.load().unwrap(); @@ -31,7 +31,7 @@ fn bench_rendering_medium_blog(b: &mut test::Bencher) { path.push("benches"); path.push("medium-blog"); let mut site = Site::new(&path, "config.toml").unwrap(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.load().unwrap(); @@ -45,7 +45,7 @@ fn bench_rendering_medium_blog(b: &mut test::Bencher) { // path.push("benches"); // path.push("big-blog"); // let mut site = Site::new(&path, "config.toml").unwrap(); -// let tmp_dir = TempDir::new("example").expect("create temp dir"); +// let tmp_dir = tempdir().expect("create temp dir"); // let public = &tmp_dir.path().join("public"); // site.set_output_path(&public); // site.load().unwrap(); @@ -59,7 +59,7 @@ fn bench_rendering_small_kb(b: &mut test::Bencher) { path.push("benches"); path.push("small-kb"); let mut site = Site::new(&path, "config.toml").unwrap(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.load().unwrap(); @@ -73,7 +73,7 @@ fn bench_rendering_medium_kb(b: &mut test::Bencher) { path.push("benches"); path.push("medium-kb"); let mut site = Site::new(&path, "config.toml").unwrap(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.load().unwrap(); diff --git a/components/site/benches/site.rs b/components/site/benches/site.rs index 245e73aa..a3bf4692 100644 --- a/components/site/benches/site.rs +++ b/components/site/benches/site.rs @@ -1,11 +1,11 @@ #![feature(test)] extern crate test; extern crate site; -extern crate tempdir; +extern crate tempfile; use std::env; -use tempdir::TempDir; +use tempfile::tempdir; use site::Site; diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 069d046a..d8e434dc 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -18,7 +18,7 @@ extern crate content; extern crate search; #[cfg(test)] -extern crate tempdir; +extern crate tempfile; use std::collections::HashMap; use std::fs::{create_dir_all, remove_dir_all, copy}; diff --git a/components/site/tests/site.rs b/components/site/tests/site.rs index f62b0e1c..8c78d15e 100644 --- a/components/site/tests/site.rs +++ b/components/site/tests/site.rs @@ -1,12 +1,12 @@ extern crate site; -extern crate tempdir; +extern crate tempfile; use std::env; use std::path::Path; use std::fs::File; use std::io::prelude::*; -use tempdir::TempDir; +use tempfile::tempdir; use site::Site; @@ -95,7 +95,7 @@ fn can_build_site_without_live_reload() { path.push("test_site"); let mut site = Site::new(&path, "config.toml").unwrap(); site.load().unwrap(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.build().unwrap(); @@ -168,7 +168,7 @@ fn can_build_site_with_live_reload() { path.push("test_site"); let mut site = Site::new(&path, "config.toml").unwrap(); site.load().unwrap(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.enable_live_reload(); @@ -220,7 +220,7 @@ fn can_build_site_with_categories() { }; } site.populate_tags_and_categories(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.build().unwrap(); @@ -275,7 +275,7 @@ fn can_build_site_with_tags() { } site.populate_tags_and_categories(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.build().unwrap(); @@ -317,7 +317,7 @@ fn can_build_site_and_insert_anchor_links() { let mut site = Site::new(&path, "config.toml").unwrap(); site.load().unwrap(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.build().unwrap(); @@ -340,7 +340,7 @@ fn can_build_site_with_pagination_for_section() { section.meta.paginate_by = Some(2); section.meta.template = Some("section_paginated.html".to_string()); } - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.build().unwrap(); @@ -397,7 +397,7 @@ fn can_build_site_with_pagination_for_index() { index.meta.paginate_by = Some(2); index.meta.template = Some("index_paginated.html".to_string()); } - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.build().unwrap(); @@ -437,7 +437,7 @@ fn can_build_rss_feed() { path.push("test_site"); let mut site = Site::new(&path, "config.toml").unwrap(); site.load().unwrap(); - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.build().unwrap(); @@ -458,7 +458,7 @@ fn can_build_search_index() { let mut site = Site::new(&path, "config.toml").unwrap(); site.load().unwrap(); site.config.build_search_index = true; - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); let public = &tmp_dir.path().join("public"); site.set_output_path(&public); site.build().unwrap(); diff --git a/components/utils/Cargo.toml b/components/utils/Cargo.toml index ee330ee1..2c5cc0f0 100644 --- a/components/utils/Cargo.toml +++ b/components/utils/Cargo.toml @@ -10,4 +10,4 @@ walkdir = "2" [dev-dependencies] -tempdir = "0.3" +tempfile = "3" diff --git a/components/utils/src/fs.rs b/components/utils/src/fs.rs index 06cd80ce..b783f7de 100644 --- a/components/utils/src/fs.rs +++ b/components/utils/src/fs.rs @@ -97,13 +97,13 @@ pub fn copy_directory(src: &PathBuf, dest: &PathBuf) -> Result<()> { mod tests { use std::fs::File; - use tempdir::TempDir; + use tempfile::tempdir; use super::{find_related_assets}; #[test] fn can_find_related_assets() { - let tmp_dir = TempDir::new("example").expect("create temp dir"); + let tmp_dir = tempdir().expect("create temp dir"); File::create(tmp_dir.path().join("index.md")).unwrap(); File::create(tmp_dir.path().join("example.js")).unwrap(); File::create(tmp_dir.path().join("graph.jpg")).unwrap(); diff --git a/components/utils/src/lib.rs b/components/utils/src/lib.rs index b529aa45..cddcb6ff 100644 --- a/components/utils/src/lib.rs +++ b/components/utils/src/lib.rs @@ -2,7 +2,7 @@ extern crate errors; #[cfg(test)] -extern crate tempdir; +extern crate tempfile; extern crate tera; extern crate walkdir;