Don't run index preprocessor on `mdbook test`

This commit is contained in:
Matt Ickstadt 2018-07-25 12:17:17 -05:00
parent e5563182fc
commit 0e1787c617
4 changed files with 6 additions and 5 deletions

View File

@ -213,12 +213,13 @@ impl MDBook {
.flat_map(|x| vec![x.0, x.1]) .flat_map(|x| vec![x.0, x.1])
.collect(); .collect();
let temp_dir = TempFileBuilder::new().prefix("mdbook").tempdir()?; let temp_dir = TempFileBuilder::new().prefix("mdbook-").tempdir()?;
let preprocess_context = PreprocessorContext::new(self.root.clone(), self.config.clone()); let preprocess_context = PreprocessorContext::new(self.root.clone(), self.config.clone());
LinkPreprocessor::new().run(&preprocess_context, &mut self.book)?; LinkPreprocessor::new().run(&preprocess_context, &mut self.book)?;
IndexPreprocessor::new().run(&preprocess_context, &mut self.book)?; // Index Preprocessor is disabled so that chapter paths continue to point to the
// actual markdown files.
for item in self.iter() { for item in self.iter() {
if let BookItem::Chapter(ref ch) = *item { if let BookItem::Chapter(ref ch) = *item {

View File

@ -47,7 +47,7 @@ impl DummyBook {
/// Write a book to a temporary directory using the provided settings. /// Write a book to a temporary directory using the provided settings.
pub fn build(&self) -> Result<TempDir> { pub fn build(&self) -> Result<TempDir> {
let temp = TempFileBuilder::new() let temp = TempFileBuilder::new()
.prefix("dummy_book") .prefix("dummy_book-")
.tempdir() .tempdir()
.chain_err(|| "Unable to create temp directory")?; .chain_err(|| "Unable to create temp directory")?;

View File

@ -1,6 +1,6 @@
# Summary # Summary
[dummy_book](README.md) [Dummy Book](README.md)
[Introduction](intro.md) [Introduction](intro.md)
- [First Chapter](first/index.md) - [First Chapter](first/index.md)

View File

@ -23,7 +23,7 @@ fn mdbook_can_correctly_test_a_passing_book() {
#[test] #[test]
fn mdbook_detects_book_with_failing_tests() { fn mdbook_detects_book_with_failing_tests() {
let temp = DummyBook::new().with_passing_test(false).build().unwrap(); let temp = DummyBook::new().with_passing_test(false).build().unwrap();
let mut md: MDBook = MDBook::load(temp.path()).unwrap(); let mut md = MDBook::load(temp.path()).unwrap();
assert!(md.test(vec![]).is_err()); assert!(md.test(vec![]).is_err());
} }