From 0e1787c6178f70fc6a0332338efaa871133247a9 Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Wed, 25 Jul 2018 12:17:17 -0500 Subject: [PATCH] Don't run index preprocessor on `mdbook test` --- src/book/mod.rs | 5 +++-- tests/dummy_book/mod.rs | 2 +- tests/dummy_book/src/SUMMARY.md | 2 +- tests/testing.rs | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/book/mod.rs b/src/book/mod.rs index 8a7a93f4..d1ed19c4 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -213,12 +213,13 @@ impl MDBook { .flat_map(|x| vec![x.0, x.1]) .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()); 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() { if let BookItem::Chapter(ref ch) = *item { diff --git a/tests/dummy_book/mod.rs b/tests/dummy_book/mod.rs index 4c904132..4fe24455 100644 --- a/tests/dummy_book/mod.rs +++ b/tests/dummy_book/mod.rs @@ -47,7 +47,7 @@ impl DummyBook { /// Write a book to a temporary directory using the provided settings. pub fn build(&self) -> Result { let temp = TempFileBuilder::new() - .prefix("dummy_book") + .prefix("dummy_book-") .tempdir() .chain_err(|| "Unable to create temp directory")?; diff --git a/tests/dummy_book/src/SUMMARY.md b/tests/dummy_book/src/SUMMARY.md index 6a0d0582..0536e5c2 100644 --- a/tests/dummy_book/src/SUMMARY.md +++ b/tests/dummy_book/src/SUMMARY.md @@ -1,6 +1,6 @@ # Summary -[dummy_book](README.md) +[Dummy Book](README.md) [Introduction](intro.md) - [First Chapter](first/index.md) diff --git a/tests/testing.rs b/tests/testing.rs index 2a32dacc..48e02892 100644 --- a/tests/testing.rs +++ b/tests/testing.rs @@ -23,7 +23,7 @@ fn mdbook_can_correctly_test_a_passing_book() { #[test] fn mdbook_detects_book_with_failing_tests() { 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()); }