diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 46e770f9..a67f01f3 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -350,20 +350,6 @@ fn able_to_include_playground_files_in_chapters() { assert_doesnt_contain_strings(&second, &["{{#playground example.rs}}"]); } -/// Ensure cyclic includes are capped so that no exceptions occur -#[test] -fn recursive_includes_are_capped() { - let temp = DummyBook::new().build().unwrap(); - let md = MDBook::load(temp.path()).unwrap(); - md.build().unwrap(); - - let recursive = temp.path().join("book/first/recursive.html"); - let content = &["Around the world, around the world -Around the world, around the world -Around the world, around the world"]; - assert_contains_strings(recursive, content); -} - #[test] fn example_book_can_build() { let example_book_dir = dummy_book::new_copy_of_example_book().unwrap(); diff --git a/tests/testsuite/includes.rs b/tests/testsuite/includes.rs index f1aca1f0..d63be13c 100644 --- a/tests/testsuite/includes.rs +++ b/tests/testsuite/includes.rs @@ -38,3 +38,33 @@ fn anchored_include() { "##]], ); } + +// Checks behavior of recursive include. +#[test] +fn recursive_include() { + BookTest::from_dir("includes/all_includes") + .run("build", |cmd| { + cmd.expect_stderr(str![[r#" +[TIMESTAMP] [INFO] (mdbook::book): Book building has started +[TIMESTAMP] [ERROR] (mdbook::preprocess::links): Stack depth exceeded in recursive.md. Check for cyclic includes +[TIMESTAMP] [INFO] (mdbook::book): Running the html backend + +"#]]); + }) + .check_main_file( + "book/recursive.html", + str![[r#" +

Around the world, around the world +Around the world, around the world +Around the world, around the world +Around the world, around the world +Around the world, around the world +Around the world, around the world +Around the world, around the world +Around the world, around the world +Around the world, around the world +Around the world, around the world +Around the world, around the world

+"#]], + ); +}