Skip to content

Commit dc9c1c9

Browse files
Fixed some bitrot and removed the (now redundant) tests/helper module
1 parent d11e3f6 commit dc9c1c9

File tree

5 files changed

+19
-51
lines changed

5 files changed

+19
-51
lines changed

tests/dummy/mod.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use std::error::Error;
1515
// The funny `self::` here is because we've got an `extern crate ...` and are
1616
// in a submodule
1717
use self::tempdir::TempDir;
18-
use self::walkdir::WalkDir;
1918
use self::mdbook::MDBook;
19+
use self::walkdir::WalkDir;
2020

2121

2222
const SUMMARY_MD: &'static str = include_str!("book/SUMMARY.md");
@@ -94,6 +94,18 @@ impl Default for DummyBook {
9494
}
9595

9696

97+
/// Copy the example book to a temporary directory and build it.
98+
pub fn build_example_book() -> TempDir {
99+
let temp = TempDir::new("mdbook").expect("Couldn't create a temporary directory");
100+
let book_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("book-example");
101+
102+
recursive_copy(&book_root, temp.path()).expect("Couldn't copy the book example to a temporary directory");
103+
104+
let book = MDBook::new(temp.path()).build().expect("Building failed");
105+
temp
106+
}
107+
108+
97109
/// Read the contents of the provided file into memory and then iterate through
98110
/// the list of strings asserting that the file contains all of them.
99111
pub fn assert_contains_strings<P: AsRef<Path>>(filename: P, strings: &[&str]) {
@@ -111,17 +123,6 @@ pub fn assert_contains_strings<P: AsRef<Path>>(filename: P, strings: &[&str]) {
111123
}
112124

113125

114-
/// Copy the example book to a temporary directory and build it.
115-
pub fn build_example_book() -> TempDir {
116-
let temp = TempDir::new("mdbook").expect("Couldn't create a temporary directory");
117-
let book_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("book-example");
118-
119-
recursive_copy(&book_root, temp.path()).expect("Couldn't copy the book example to a temporary directory");
120-
121-
let book = MDBook::new(temp.path()).build().expect("Building failed");
122-
temp
123-
}
124-
125126

126127
/// Recursively copy an entire directory tree to somewhere else (a la `cp -r`).
127128
fn recursive_copy<A: AsRef<Path>, B: AsRef<Path>>(from: A, to: B) -> Result<(), Box<Error>> {

tests/helpers/mod.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/regression.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77
//! Hopefully Travis will let you know when that happens.
88
99

10-
extern crate mdbook;
1110
#[macro_use]
1211
extern crate pretty_assertions;
1312
extern crate select;
14-
extern crate tempdir;
1513
extern crate walkdir;
1614

17-
mod helpers;
15+
mod dummy;
1816

1917
use std::path::Path;
2018
use walkdir::{DirEntry, WalkDir, WalkDirIterator};
2119
use select::document::Document;
22-
use select::predicate::{Class, Descendant, Name, Predicate};
20+
use select::predicate::{Class, Name, Predicate};
2321

2422

2523
const BOOK_ROOT: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/book-example");
@@ -60,7 +58,7 @@ macro_rules! descendants {
6058
/// and placed in the `book` directory with their extensions set to `*.html`.
6159
#[test]
6260
fn chapter_files_were_rendered_to_html() {
63-
let temp = helpers::build_example_book();
61+
let temp = dummy::build_example_book();
6462
let src = Path::new(BOOK_ROOT).join("src");
6563

6664
let chapter_files = WalkDir::new(&src)
@@ -85,10 +83,10 @@ fn entry_ends_with(entry: &DirEntry, ending: &str) -> bool {
8583
/// Read the main page (`book/index.html`) and expose it as a DOM which we
8684
/// can search with the `select` crate
8785
fn root_index_html() -> Document {
88-
let temp = helpers::build_example_book();
86+
let temp = dummy::build_example_book();
8987

9088
let index_page = temp.path().join("book").join("index.html");
91-
let html = helpers::read_file(&index_page).unwrap();
89+
let html = dummy::read_file(&index_page).unwrap();
9290
Document::from(html.as_str())
9391
}
9492

tests/rendered_output.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
extern crate mdbook;
2-
extern crate tempdir;
32

43
mod dummy;
5-
mod helpers;
64

7-
use dummy::DummyBook;
8-
use helpers::assert_contains_strings;
5+
use dummy::{DummyBook, assert_contains_strings};
96
use mdbook::MDBook;
107

118

tests/testing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
extern crate mdbook;
2-
extern crate tempdir;
32

43
mod dummy;
54

0 commit comments

Comments
 (0)