diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /vendor/mdbook/src/book | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/mdbook/src/book')
-rw-r--r-- | vendor/mdbook/src/book/book.rs | 2 | ||||
-rw-r--r-- | vendor/mdbook/src/book/init.rs | 1 | ||||
-rw-r--r-- | vendor/mdbook/src/book/mod.rs | 28 | ||||
-rw-r--r-- | vendor/mdbook/src/book/summary.rs | 3 |
4 files changed, 30 insertions, 4 deletions
diff --git a/vendor/mdbook/src/book/book.rs b/vendor/mdbook/src/book/book.rs index d28c22dad..b46843df5 100644 --- a/vendor/mdbook/src/book/book.rs +++ b/vendor/mdbook/src/book/book.rs @@ -8,7 +8,7 @@ use super::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem}; use crate::config::BuildConfig; use crate::errors::*; use crate::utils::bracket_escape; - +use log::debug; use serde::{Deserialize, Serialize}; /// Load a book into memory from its `src/` directory. diff --git a/vendor/mdbook/src/book/init.rs b/vendor/mdbook/src/book/init.rs index 264c113d3..dd3fa8b0d 100644 --- a/vendor/mdbook/src/book/init.rs +++ b/vendor/mdbook/src/book/init.rs @@ -6,6 +6,7 @@ use super::MDBook; use crate::config::Config; use crate::errors::*; use crate::theme; +use log::{debug, error, info, trace}; /// A helper for setting up a new book and its directory structure. #[derive(Debug, Clone, PartialEq)] diff --git a/vendor/mdbook/src/book/mod.rs b/vendor/mdbook/src/book/mod.rs index 9745d2b7e..75bbcc714 100644 --- a/vendor/mdbook/src/book/mod.rs +++ b/vendor/mdbook/src/book/mod.rs @@ -14,6 +14,7 @@ pub use self::book::{load_book, Book, BookItem, BookItems, Chapter}; pub use self::init::BookBuilder; pub use self::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem}; +use log::{debug, error, info, log_enabled, trace, warn}; use std::io::Write; use std::path::PathBuf; use std::process::Command; @@ -246,6 +247,13 @@ impl MDBook { /// Run `rustdoc` tests on the book, linking against the provided libraries. pub fn test(&mut self, library_paths: Vec<&str>) -> Result<()> { + // test_chapter with chapter:None will run all tests. + self.test_chapter(library_paths, None) + } + + /// Run `rustdoc` tests on a specific chapter of the book, linking against the provided libraries. + /// If `chapter` is `None`, all tests will be run. + pub fn test_chapter(&mut self, library_paths: Vec<&str>, chapter: Option<&str>) -> Result<()> { let library_args: Vec<&str> = (0..library_paths.len()) .map(|_| "-L") .zip(library_paths.into_iter()) @@ -254,6 +262,8 @@ impl MDBook { let temp_dir = TempFileBuilder::new().prefix("mdbook-").tempdir()?; + let mut chapter_found = false; + // FIXME: Is "test" the proper renderer name to use here? let preprocess_context = PreprocessorContext::new(self.root.clone(), self.config.clone(), "test".to_string()); @@ -270,8 +280,16 @@ impl MDBook { _ => continue, }; - let path = self.source_dir().join(&chapter_path); - info!("Testing file: {:?}", path); + if let Some(chapter) = chapter { + if ch.name != chapter && chapter_path.to_str() != Some(chapter) { + if chapter == "?" { + info!("Skipping chapter '{}'...", ch.name); + } + continue; + } + } + chapter_found = true; + info!("Testing chapter '{}': {:?}", ch.name, chapter_path); // write preprocessed file to tempdir let path = temp_dir.path().join(&chapter_path); @@ -295,6 +313,7 @@ impl MDBook { } } + debug!("running {:?}", cmd); let output = cmd.output()?; if !output.status.success() { @@ -311,6 +330,11 @@ impl MDBook { if failed { bail!("One or more tests failed"); } + if let Some(chapter) = chapter { + if !chapter_found { + bail!("Chapter not found: {}", chapter); + } + } Ok(()) } diff --git a/vendor/mdbook/src/book/summary.rs b/vendor/mdbook/src/book/summary.rs index 2bd81580f..b2784ce5f 100644 --- a/vendor/mdbook/src/book/summary.rs +++ b/vendor/mdbook/src/book/summary.rs @@ -1,4 +1,5 @@ use crate::errors::*; +use log::{debug, trace, warn}; use memchr::{self, Memchr}; use pulldown_cmark::{self, Event, HeadingLevel, Tag}; use serde::{Deserialize, Serialize}; @@ -453,7 +454,7 @@ impl<'a> SummaryParser<'a> { items.push(item); } Some(Event::Start(Tag::List(..))) => { - // Skip this tag after comment bacause it is not nested. + // Skip this tag after comment because it is not nested. if items.is_empty() { continue; } |