Skip to content

Commit 938a912

Browse files
authored
Merge pull request #2980 from ehuss/fix-test-preprocessor
Don't rebuild preprocessor map during test
2 parents 6457b38 + 7bdea7c commit 938a912

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

crates/mdbook-driver/src/mdbook.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,6 @@ impl MDBook {
263263
}
264264
}
265265

266-
// Index Preprocessor is disabled so that chapter paths
267-
// continue to point to the actual markdown files.
268-
self.preprocessors = determine_preprocessors(&self.config, &self.root)?;
269-
self.preprocessors
270-
.shift_remove_entry(IndexPreprocessor::NAME);
271266
let (book, _) = self.preprocess_book(&TestRenderer)?;
272267

273268
let color_output = std::io::stderr().is_terminal();

tests/testsuite/preprocessor.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ fn runs_preprocessors() {
4444
assert_eq!(inner.rendered_with, ["html"]);
4545
}
4646

47+
// Run tests with a custom preprocessor.
48+
#[test]
49+
fn test_with_custom_preprocessor() {
50+
let test = BookTest::init(|_| {});
51+
let spy: Arc<Mutex<Inner>> = Default::default();
52+
let mut book = test.load_book();
53+
book.with_preprocessor(Spy(Arc::clone(&spy)));
54+
book.test(vec![]).unwrap();
55+
56+
let inner = spy.lock().unwrap();
57+
assert_eq!(inner.run_count, 1);
58+
assert_eq!(inner.rendered_with, ["test"]);
59+
}
60+
4761
// No-op preprocessor works.
4862
#[test]
4963
fn nop_preprocessor() {

0 commit comments

Comments
 (0)