diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index e25b571acbac5..baded12b7c39d 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2171,6 +2171,7 @@ struct BookTest { path: PathBuf, name: &'static str, is_ext_doc: bool, + cli_args: Vec<&'static str>, } impl Step for BookTest { @@ -2223,6 +2224,11 @@ impl BookTest { // Books often have feature-gated example text. rustbook_cmd.env("RUSTC_BOOTSTRAP", "1"); rustbook_cmd.env("PATH", new_path).arg("test").arg(path); + + if !self.cli_args.is_empty() { + rustbook_cmd.args(self.cli_args); + } + builder.add_rust_test_threads(&mut rustbook_cmd); let _guard = builder.msg( Kind::Test, @@ -2281,6 +2287,7 @@ macro_rules! test_book { $name:ident, $path:expr, $book_name:expr, default=$default:expr $(,submodules = $submodules:expr)? + $(,dependencies=$dependencies:expr)? ; )+) => { $( @@ -2310,11 +2317,33 @@ macro_rules! test_book { builder.require_submodule(submodule, None); } )* + + let dependencies = vec![]; + let cli_args = vec![]; + $( + let mut dependencies = dependencies; + let mut cli_args = cli_args; + for dep in $dependencies { + dependencies.push(dep.into_string()); + } + + if !dependencies.is_empty() { + cli_args.push("--library-path"); + cli_args.extend( + dependencies + .iter() + .map(|dep| format!("{dep}/target/debug/deps")) + .collect() + ); + } + )? + builder.ensure(BookTest { compiler: self.compiler, path: PathBuf::from($path), name: $book_name, is_ext_doc: !$default, + cli_args, }); } } @@ -2329,7 +2358,7 @@ test_book!( RustcBook, "src/doc/rustc", "rustc", default=true; RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false, submodules=["src/doc/rust-by-example"]; EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false, submodules=["src/doc/embedded-book"]; - TheBook, "src/doc/book", "book", default=false, submodules=["src/doc/book"]; + TheBook, "src/doc/book", "book", default=false, submodules=["src/doc/book"], dependencies=["src/doc/book/packages/trpl"]; UnstableBook, "src/doc/unstable-book", "unstable-book", default=true; EditionGuide, "src/doc/edition-guide", "edition-guide", default=false, submodules=["src/doc/edition-guide"]; );