tempdir -> tempfile

This commit is contained in:
Vincent Prouillet 2018-04-25 10:28:23 +02:00
parent 691ad922a2
commit 3e6054a9ac
14 changed files with 48 additions and 45 deletions

17
Cargo.lock generated
View file

@ -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"

View file

@ -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"

View file

@ -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)]

View file

@ -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");

View file

@ -11,5 +11,5 @@ content = { path = "../content" }
site = { path = "../site" }
[dev-dependencies]
tempdir = "0.3"
tempfile = "3"
fs_extra = "1.1"

View file

@ -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#"
+++

View file

@ -22,4 +22,4 @@ content = { path = "../content" }
search = { path = "../search" }
[dev-dependencies]
tempdir = "0.3"
tempfile = "3"

View file

@ -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();

View file

@ -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;

View file

@ -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};

View file

@ -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();

View file

@ -10,4 +10,4 @@ walkdir = "2"
[dev-dependencies]
tempdir = "0.3"
tempfile = "3"

View file

@ -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();

View file

@ -2,7 +2,7 @@
extern crate errors;
#[cfg(test)]
extern crate tempdir;
extern crate tempfile;
extern crate tera;
extern crate walkdir;