summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastien Orivel <eijebong@bananium.fr>2018-03-27 01:47:37 +0200
committerMichael Bryan <michaelfbryan@gmail.com>2018-03-27 07:47:37 +0800
commit55f7ed1c37bf453b970d3656a345015361818e3b (patch)
treecbb7e8f09209c35eda4d7f1a2c5be2a326861844
parenteb0f7179ab1822b91360dc758362f7ec359c5cc3 (diff)
Replace tempdir by tempfile (#650)
The former has been deprecated in favor of the latter
-rw-r--r--Cargo.lock22
-rw-r--r--Cargo.toml4
-rw-r--r--src/book/book.rs4
-rw-r--r--src/book/mod.rs4
-rw-r--r--src/lib.rs2
-rw-r--r--src/theme/mod.rs4
-rw-r--r--src/utils/fs.rs4
-rw-r--r--tests/alternate_backends.rs8
-rw-r--r--tests/dummy_book/mod.rs10
-rw-r--r--tests/init.rs10
-rw-r--r--tests/rendered_output.rs6
11 files changed, 40 insertions, 38 deletions
diff --git a/Cargo.lock b/Cargo.lock
index fe784d80..874237cf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -496,7 +496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "mdbook"
-version = "0.1.6-alpha.0"
+version = "0.1.6"
dependencies = [
"ammonia 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -523,7 +523,7 @@ dependencies = [
"serde_json 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)",
"shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"staticfile 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tempfile 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"toml-query 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -884,11 +884,10 @@ dependencies = [
[[package]]
name = "remove_dir_all"
-version = "0.3.0"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1106,12 +1105,15 @@ dependencies = [
]
[[package]]
-name = "tempdir"
-version = "0.3.6"
+name = "tempfile"
+version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "remove_dir_all 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
+ "remove_dir_all 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1490,7 +1492,7 @@ dependencies = [
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "aec3f58d903a7d2a9dc2bf0e41a746f4530e0cab6b615494e058f67a3ef947fb"
"checksum regex-syntax 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b2550876c31dc914696a6c2e01cbce8afba79a93c8ae979d2fe051c0230b3756"
-"checksum remove_dir_all 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d2f806b0fcdabd98acd380dc8daef485e22bcb7cddc811d1337967f2528cf5"
+"checksum remove_dir_all 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dfc5b3ce5d5ea144bb04ebd093a9e14e9765bcfec866aecda9b6dec43b3d1e24"
"checksum rust-stemmers 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fbf06149ec391025664a5634200ced1afb489f0f3f8a140d515ebc0eb04b4bc0"
"checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
@@ -1519,7 +1521,7 @@ dependencies = [
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)" = "8c5bc2d6ff27891209efa5f63e9de78648d7801f085e4653701a692ce938d6fd"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
-"checksum tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f73eebdb68c14bcb24aef74ea96079830e7fa7b31a6106e42ea7ee887c1e134e"
+"checksum tempfile 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "439d9a7c00f98b1b5ee730039bf5b1f9203d508690e3c76b509e7ad59f8f7c99"
"checksum tendril 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1b72f8e2f5b73b65c315b1a70c730f24b9d7a25f39e98de8acbe2bb795caea"
"checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508"
"checksum termcolor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "56c456352e44f9f91f774ddeeed27c1ec60a2455ed66d692059acfb1d731bda1"
diff --git a/Cargo.toml b/Cargo.toml
index 6cf662b7..21ca7bb8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "mdbook"
-version = "0.1.6-alpha.0"
+version = "0.1.6"
authors = ["Mathieu David <mathieudavid@mathieudavid.org>", "Michael-F-Bryan <michaelfbryan@gmail.com>"]
description = "Create books from markdown files"
documentation = "http://rust-lang-nursery.github.io/mdBook/index.html"
@@ -35,7 +35,7 @@ toml = "0.4"
memchr = "2.0"
open = "1.1"
regex = "0.2.1"
-tempdir = "0.3.4"
+tempfile = "3.0"
itertools = "0.7"
shlex = "0.1"
toml-query = "0.6"
diff --git a/src/book/book.rs b/src/book/book.rs
index 5987b8b5..7da28a68 100644
--- a/src/book/book.rs
+++ b/src/book/book.rs
@@ -297,7 +297,7 @@ impl Display for Chapter {
#[cfg(test)]
mod tests {
use super::*;
- use tempdir::TempDir;
+ use tempfile::{TempDir, Builder as TempFileBuilder};
use std::io::Write;
const DUMMY_SRC: &'static str = "
@@ -311,7 +311,7 @@ And here is some \
/// Create a dummy `Link` in a temporary directory.
fn dummy_link() -> (Link, TempDir) {
- let temp = TempDir::new("book").unwrap();
+ let temp = TempFileBuilder::new().prefix("book").tempdir().unwrap();
let chapter_path = temp.path().join("chapter_1.md");
File::create(&chapter_path)
diff --git a/src/book/mod.rs b/src/book/mod.rs
index 9c5aeac2..03871e7d 100644
--- a/src/book/mod.rs
+++ b/src/book/mod.rs
@@ -16,7 +16,7 @@ pub use self::init::BookBuilder;
use std::path::PathBuf;
use std::io::Write;
use std::process::Command;
-use tempdir::TempDir;
+use tempfile::Builder as TempFileBuilder;
use toml::Value;
use utils;
@@ -213,7 +213,7 @@ impl MDBook {
.flat_map(|x| vec![x.0, x.1])
.collect();
- let temp_dir = TempDir::new("mdbook")?;
+ let temp_dir = TempFileBuilder::new().prefix("mdbook").tempdir()?;
let preprocess_context = PreprocessorContext::new(self.root.clone(), self.config.clone());
diff --git a/src/lib.rs b/src/lib.rs
index 92fb8389..6725a65d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -99,7 +99,7 @@ extern crate serde_derive;
#[macro_use]
extern crate serde_json;
extern crate shlex;
-extern crate tempdir;
+extern crate tempfile;
extern crate toml;
extern crate toml_query;
diff --git a/src/theme/mod.rs b/src/theme/mod.rs
index fc7c809f..2f6f7c01 100644
--- a/src/theme/mod.rs
+++ b/src/theme/mod.rs
@@ -134,7 +134,7 @@ fn load_file_contents<P: AsRef<Path>>(filename: P, dest: &mut Vec<u8>) -> Result
#[cfg(test)]
mod tests {
use super::*;
- use tempdir::TempDir;
+ use tempfile::Builder as TempFileBuilder;
use std::path::PathBuf;
#[test]
@@ -159,7 +159,7 @@ mod tests {
.map(|f| f.path())
.filter(|p| p.is_file() && !p.ends_with(".rs"));
- let temp = TempDir::new("mdbook").unwrap();
+ let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
// "touch" all of the special files so we have empty copies
for special_file in special_files {
diff --git a/src/utils/fs.rs b/src/utils/fs.rs
index 7ae13fd1..dc44fa02 100644
--- a/src/utils/fs.rs
+++ b/src/utils/fs.rs
@@ -193,14 +193,14 @@ pub fn copy_files_except_ext(
#[cfg(test)]
mod tests {
- extern crate tempdir;
+ extern crate tempfile;
use super::copy_files_except_ext;
use std::fs;
#[test]
fn copy_files_except_ext_test() {
- let tmp = match tempdir::TempDir::new("") {
+ let tmp = match tempfile::TempDir::new() {
Ok(t) => t,
Err(_) => panic!("Could not create a temp dir"),
};
diff --git a/tests/alternate_backends.rs b/tests/alternate_backends.rs
index 04555f37..4c92f3eb 100644
--- a/tests/alternate_backends.rs
+++ b/tests/alternate_backends.rs
@@ -1,11 +1,11 @@
//! Integration tests to make sure alternate backends work.
extern crate mdbook;
-extern crate tempdir;
+extern crate tempfile;
#[cfg(not(windows))]
use std::path::Path;
-use tempdir::TempDir;
+use tempfile::{TempDir, Builder as TempFileBuilder};
use mdbook::config::Config;
use mdbook::MDBook;
@@ -55,7 +55,7 @@ fn backends_receive_render_context_via_stdin() {
use std::fs::File;
use mdbook::renderer::RenderContext;
- let temp = TempDir::new("output").unwrap();
+ let temp = TempFileBuilder::new().prefix("output").tempdir().unwrap();
let out_file = temp.path().join("out.txt");
let cmd = tee_command(&out_file);
@@ -70,7 +70,7 @@ fn backends_receive_render_context_via_stdin() {
}
fn dummy_book_with_backend(name: &str, command: &str) -> (MDBook, TempDir) {
- let temp = TempDir::new("mdbook").unwrap();
+ let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
let mut config = Config::default();
config
diff --git a/tests/dummy_book/mod.rs b/tests/dummy_book/mod.rs
index 2d27bfaa..b0ae2852 100644
--- a/tests/dummy_book/mod.rs
+++ b/tests/dummy_book/mod.rs
@@ -4,7 +4,7 @@
// Not all features are used in all test crates, so...
#![allow(dead_code, unused_variables, unused_imports, unused_extern_crates)]
extern crate mdbook;
-extern crate tempdir;
+extern crate tempfile;
extern crate walkdir;
use std::path::Path;
@@ -15,7 +15,7 @@ use mdbook::utils::fs::file_to_string;
// The funny `self::` here is because we've got an `extern crate ...` and are
// in a submodule
-use self::tempdir::TempDir;
+use self::tempfile::{TempDir, Builder as TempFileBuilder};
use self::mdbook::MDBook;
use self::walkdir::WalkDir;
@@ -47,7 +47,7 @@ impl DummyBook {
/// Write a book to a temporary directory using the provided settings.
pub fn build(&self) -> Result<TempDir> {
- let temp = TempDir::new("dummy_book").chain_err(|| "Unable to create temp directory")?;
+ let temp = TempFileBuilder::new().prefix("dummy_book").tempdir().chain_err(|| "Unable to create temp directory")?;
let dummy_book_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/dummy_book");
recursive_copy(&dummy_book_root, temp.path()).chain_err(|| {
@@ -128,11 +128,11 @@ fn recursive_copy<A: AsRef<Path>, B: AsRef<Path>>(from: A, to: B) -> Result<()>
}
pub fn new_copy_of_example_book() -> Result<TempDir> {
- let temp = TempDir::new("book-example")?;
+ let temp = TempFileBuilder::new().prefix("book-example").tempdir()?;
let book_example = Path::new(env!("CARGO_MANIFEST_DIR")).join("book-example");
recursive_copy(book_example, temp.path())?;
Ok(temp)
-} \ No newline at end of file
+}
diff --git a/tests/init.rs b/tests/init.rs
index 8bea5792..908f0cc5 100644
--- a/tests/init.rs
+++ b/tests/init.rs
@@ -1,11 +1,11 @@
extern crate mdbook;
-extern crate tempdir;
+extern crate tempfile;
use std::path::PathBuf;
use std::fs;
use mdbook::MDBook;
use mdbook::config::Config;
-use tempdir::TempDir;
+use tempfile::Builder as TempFileBuilder;
/// Run `mdbook init` in an empty directory and make sure the default files
@@ -14,7 +14,7 @@ use tempdir::TempDir;
fn base_mdbook_init_should_create_default_content() {
let created_files = vec!["book", "src", "src/SUMMARY.md", "src/chapter_1.md"];
- let temp = TempDir::new("mdbook").unwrap();
+ let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
for file in &created_files {
assert!(!temp.path().join(file).exists());
}
@@ -34,7 +34,7 @@ fn base_mdbook_init_should_create_default_content() {
fn run_mdbook_init_with_custom_book_and_src_locations() {
let created_files = vec!["out", "in", "in/SUMMARY.md", "in/chapter_1.md"];
- let temp = TempDir::new("mdbook").unwrap();
+ let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
for file in &created_files {
assert!(
!temp.path().join(file).exists(),
@@ -61,7 +61,7 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
#[test]
fn book_toml_isnt_required() {
- let temp = TempDir::new("mdbook").unwrap();
+ let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
let md = MDBook::init(temp.path()).build().unwrap();
let _ = fs::remove_file(temp.path().join("book.toml"));
diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs
index ff6559d6..7a540085 100644
--- a/tests/rendered_output.rs
+++ b/tests/rendered_output.rs
@@ -2,7 +2,7 @@ extern crate mdbook;
#[macro_use]
extern crate pretty_assertions;
extern crate select;
-extern crate tempdir;
+extern crate tempfile;
extern crate walkdir;
mod dummy_book;
@@ -16,7 +16,7 @@ use std::ffi::OsStr;
use walkdir::{DirEntry, WalkDir};
use select::document::Document;
use select::predicate::{Class, Name, Predicate};
-use tempdir::TempDir;
+use tempfile::Builder as TempFileBuilder;
use mdbook::errors::*;
use mdbook::utils::fs::file_to_string;
use mdbook::config::Config;
@@ -324,7 +324,7 @@ fn example_book_can_build() {
#[test]
fn book_with_a_reserved_filename_does_not_build() {
- let tmp_dir = TempDir::new("mdBook").unwrap();
+ let tmp_dir = TempFileBuilder::new().prefix("mdBook").tempdir().unwrap();
let src_path = tmp_dir.path().join("src");
fs::create_dir(&src_path).unwrap();