//! Tests for include preprocessor. use crate::prelude::*; // Basic test for #include. #[test] fn include() { BookTest::from_dir("includes/all_includes") .check_main_file( "book/includes.html", str![[r##"

Basic Includes

Sample

This is a sample include.

"##]], ) .check_main_file( "book/relative/includes.html", str![[r##"

Relative Includes

Sample

This is a sample include.

"##]], ); } // Checks for anchored includes. #[test] fn anchored_include() { BookTest::from_dir("includes/all_includes").check_main_file( "book/anchors.html", str![[r##"

Include Anchors

#![allow(unused)]
fn main() {
let x = 1;
}
"##]], ); } // 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

"#]], ); }