mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-13 22:32:35 +00:00
8542f7f29d
* Transition to 2018 edition * Update Travis CI badge in README * Remove non-idiomatic `extern crate` lines
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
//! Some integration tests to make sure the `SUMMARY.md` parser can deal with
|
|
//! some real-life examples.
|
|
|
|
use mdbook::book;
|
|
use std::fs::File;
|
|
use std::io::Read;
|
|
use std::path::Path;
|
|
|
|
macro_rules! summary_md_test {
|
|
($name:ident, $filename:expr) => {
|
|
#[test]
|
|
fn $name() {
|
|
env_logger::try_init().ok();
|
|
|
|
let filename = Path::new(env!("CARGO_MANIFEST_DIR"))
|
|
.join("tests")
|
|
.join("summary_md_files")
|
|
.join($filename);
|
|
|
|
if !filename.exists() {
|
|
panic!("{} Doesn't exist", filename.display());
|
|
}
|
|
|
|
let mut content = String::new();
|
|
File::open(&filename)
|
|
.unwrap()
|
|
.read_to_string(&mut content)
|
|
.unwrap();
|
|
|
|
if let Err(e) = book::parse_summary(&content) {
|
|
use error_chain::ChainedError;
|
|
|
|
eprintln!("Error parsing {}", filename.display());
|
|
eprintln!();
|
|
eprintln!("{}", e.display_chain());
|
|
panic!();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
summary_md_test!(rust_by_example, "rust_by_example.md");
|
|
summary_md_test!(rust_ffi_guide, "rust_ffi_guide.md");
|
|
summary_md_test!(example_book, "example_book.md");
|
|
summary_md_test!(the_book_2nd_edition, "the_book-2nd_edition.md");
|