Skip to content

Commit b71d6b9

Browse files
committed
[wip] Update boostrap tests to support book dependencies
Since TRPL now depends on a `trpl` crate, the test needs to be able to build that crate to run mdbook against it, and also to invoke mdbook with `--library-path` in that case. Use the support for that flag added to `rustbook` in the previous change to Still to-do: - [ ] Build `trpl` with the `run_cargo` command. Use its result to pass the correct locations to `--library-path`. - [ ] Test this to make sure it works (!) and that it does not generate any extra noise during build.
1 parent f927307 commit b71d6b9

File tree

1 file changed

+48
-1
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+48
-1
lines changed

src/bootstrap/src/core/build_steps/test.rs

+48-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{env, fs, iter};
99

1010
use clap_complete::shells;
1111

12+
use crate::core::build_steps::compile::run_cargo;
1213
use crate::core::build_steps::doc::DocumentationFormat;
1314
use crate::core::build_steps::synthetic_targets::MirOptPanicAbortSyntheticTarget;
1415
use crate::core::build_steps::tool::{self, SourceType, Tool};
@@ -2171,6 +2172,8 @@ struct BookTest {
21712172
path: PathBuf,
21722173
name: &'static str,
21732174
is_ext_doc: bool,
2175+
dependencies: Vec<PathBuf>,
2176+
cli_args: Vec<String>,
21742177
}
21752178

21762179
impl Step for BookTest {
@@ -2223,6 +2226,27 @@ impl BookTest {
22232226
// Books often have feature-gated example text.
22242227
rustbook_cmd.env("RUSTC_BOOTSTRAP", "1");
22252228
rustbook_cmd.env("PATH", new_path).arg("test").arg(path);
2229+
2230+
if !self.dependencies.is_empty() {
2231+
for dep in self.dependencies {
2232+
// TODO: get a Cargo etc.
2233+
let output_paths = run_cargo(
2234+
builder,
2235+
cargo,
2236+
tail_args,
2237+
stamp,
2238+
additional_target_deps,
2239+
is_check,
2240+
rlib_only_metadata,
2241+
);
2242+
todo!("run cargo build {dep}");
2243+
}
2244+
}
2245+
2246+
if !self.cli_args.is_empty() {
2247+
rustbook_cmd.args(self.cli_args);
2248+
}
2249+
22262250
builder.add_rust_test_threads(&mut rustbook_cmd);
22272251
let _guard = builder.msg(
22282252
Kind::Test,
@@ -2281,6 +2305,7 @@ macro_rules! test_book {
22812305
$name:ident, $path:expr, $book_name:expr,
22822306
default=$default:expr
22832307
$(,submodules = $submodules:expr)?
2308+
$(,dependencies=$dependencies:expr)?
22842309
;
22852310
)+) => {
22862311
$(
@@ -2310,11 +2335,33 @@ macro_rules! test_book {
23102335
builder.require_submodule(submodule, None);
23112336
}
23122337
)*
2338+
2339+
let dependencies = vec![];
2340+
let cli_args = vec![];
2341+
$(
2342+
let mut dependencies = dependencies;
2343+
let mut cli_args = cli_args;
2344+
for dep in $dependencies {
2345+
dependencies.push(dep.to_string());
2346+
}
2347+
2348+
if !dependencies.is_empty() {
2349+
cli_args.push(String::from("--library-path"));
2350+
let lib_paths = dependencies
2351+
.iter()
2352+
.map(|dep| format!("{dep}/target/debug/deps"))
2353+
.collect::<Vec<String>>();
2354+
cli_args.extend(lib_paths);
2355+
}
2356+
)?
2357+
23132358
builder.ensure(BookTest {
23142359
compiler: self.compiler,
23152360
path: PathBuf::from($path),
23162361
name: $book_name,
23172362
is_ext_doc: !$default,
2363+
dependencies,
2364+
cli_args,
23182365
});
23192366
}
23202367
}
@@ -2329,7 +2376,7 @@ test_book!(
23292376
RustcBook, "src/doc/rustc", "rustc", default=true;
23302377
RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false, submodules=["src/doc/rust-by-example"];
23312378
EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false, submodules=["src/doc/embedded-book"];
2332-
TheBook, "src/doc/book", "book", default=false, submodules=["src/doc/book"];
2379+
TheBook, "src/doc/book", "book", default=false, submodules=["src/doc/book"], dependencies=["src/doc/book/packages/trpl"];
23332380
UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
23342381
EditionGuide, "src/doc/edition-guide", "edition-guide", default=false, submodules=["src/doc/edition-guide"];
23352382
);

0 commit comments

Comments
 (0)