]>
Commit | Line | Data |
---|---|---|
2c00a5a8 XL |
1 | //! Implementation of the test-related targets of the build system. |
2 | //! | |
3 | //! This file implements the various regression test suites that we execute on | |
4 | //! our CI. | |
5 | ||
6 | use std::env; | |
7 | use std::ffi::OsString; | |
2c00a5a8 | 8 | use std::fmt; |
0731742a | 9 | use std::fs; |
94b46f34 XL |
10 | use std::iter; |
11 | use std::path::{Path, PathBuf}; | |
12 | use std::process::Command; | |
2c00a5a8 | 13 | |
48663c56 | 14 | use build_helper::{self, output, t}; |
2c00a5a8 | 15 | |
0731742a | 16 | use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; |
5869c6ff | 17 | use crate::cache::Interned; |
0731742a | 18 | use crate::compile; |
3dfed10e | 19 | use crate::config::TargetSelection; |
0731742a XL |
20 | use crate::dist; |
21 | use crate::flags::Subcommand; | |
22 | use crate::native; | |
dfeec247 | 23 | use crate::tool::{self, SourceType, Tool}; |
0731742a | 24 | use crate::toolstate::ToolState; |
ba9703b0 | 25 | use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var}; |
0731742a | 26 | use crate::Crate as CargoCrate; |
dfeec247 | 27 | use crate::{envify, DocTests, GitRepo, Mode}; |
2c00a5a8 XL |
28 | |
29 | const ADB_TEST_DIR: &str = "/data/tmp/work"; | |
30 | ||
31 | /// The two modes of the test runner; tests or benchmarks. | |
83c7162d | 32 | #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)] |
2c00a5a8 | 33 | pub enum TestKind { |
9fa01778 | 34 | /// Run `cargo test`. |
2c00a5a8 | 35 | Test, |
9fa01778 | 36 | /// Run `cargo bench`. |
2c00a5a8 XL |
37 | Bench, |
38 | } | |
39 | ||
94b46f34 XL |
40 | impl From<Kind> for TestKind { |
41 | fn from(kind: Kind) -> Self { | |
42 | match kind { | |
43 | Kind::Test => TestKind::Test, | |
44 | Kind::Bench => TestKind::Bench, | |
45 | _ => panic!("unexpected kind in crate: {:?}", kind), | |
46 | } | |
47 | } | |
48 | } | |
49 | ||
2c00a5a8 XL |
50 | impl TestKind { |
51 | // Return the cargo subcommand for this test kind | |
52 | fn subcommand(self) -> &'static str { | |
53 | match self { | |
54 | TestKind::Test => "test", | |
55 | TestKind::Bench => "bench", | |
56 | } | |
57 | } | |
58 | } | |
59 | ||
60 | impl fmt::Display for TestKind { | |
9fa01778 | 61 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
2c00a5a8 XL |
62 | f.write_str(match *self { |
63 | TestKind::Test => "Testing", | |
64 | TestKind::Bench => "Benchmarking", | |
65 | }) | |
66 | } | |
67 | } | |
68 | ||
9fa01778 | 69 | fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool { |
83c7162d XL |
70 | if !builder.fail_fast { |
71 | if !builder.try_run(cmd) { | |
72 | let mut failures = builder.delayed_failures.borrow_mut(); | |
2c00a5a8 XL |
73 | failures.push(format!("{:?}", cmd)); |
74 | return false; | |
75 | } | |
76 | } else { | |
83c7162d | 77 | builder.run(cmd); |
2c00a5a8 XL |
78 | } |
79 | true | |
80 | } | |
81 | ||
9fa01778 | 82 | fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool { |
83c7162d XL |
83 | if !builder.fail_fast { |
84 | if !builder.try_run_quiet(cmd) { | |
85 | let mut failures = builder.delayed_failures.borrow_mut(); | |
2c00a5a8 | 86 | failures.push(format!("{:?}", cmd)); |
0531ce1d | 87 | return false; |
2c00a5a8 XL |
88 | } |
89 | } else { | |
83c7162d | 90 | builder.run_quiet(cmd); |
2c00a5a8 | 91 | } |
0531ce1d | 92 | true |
2c00a5a8 XL |
93 | } |
94 | ||
95 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
96 | pub struct Linkcheck { | |
3dfed10e | 97 | host: TargetSelection, |
2c00a5a8 XL |
98 | } |
99 | ||
100 | impl Step for Linkcheck { | |
101 | type Output = (); | |
102 | const ONLY_HOSTS: bool = true; | |
103 | const DEFAULT: bool = true; | |
104 | ||
105 | /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler. | |
106 | /// | |
107 | /// This tool in `src/tools` will verify the validity of all our links in the | |
108 | /// documentation to ensure we don't have a bunch of dead ones. | |
9fa01778 | 109 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 | 110 | let host = self.host; |
cdc7bbd5 XL |
111 | let hosts = &builder.hosts; |
112 | let targets = &builder.targets; | |
113 | ||
114 | // if we have different hosts and targets, some things may be built for | |
115 | // the host (e.g. rustc) and others for the target (e.g. std). The | |
116 | // documentation built for each will contain broken links to | |
117 | // docs built for the other platform (e.g. rustc linking to cargo) | |
118 | if (hosts != targets) && !hosts.is_empty() && !targets.is_empty() { | |
119 | panic!( | |
120 | "Linkcheck currently does not support builds with different hosts and targets. | |
121 | You can skip linkcheck with --exclude src/tools/linkchecker" | |
122 | ); | |
123 | } | |
2c00a5a8 | 124 | |
83c7162d | 125 | builder.info(&format!("Linkcheck ({})", host)); |
2c00a5a8 | 126 | |
6a06907d | 127 | builder.default_doc(&[]); |
2c00a5a8 | 128 | |
83c7162d | 129 | let _time = util::timeit(&builder); |
94b46f34 XL |
130 | try_run( |
131 | builder, | |
3dfed10e | 132 | builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")), |
94b46f34 | 133 | ); |
2c00a5a8 XL |
134 | } |
135 | ||
9fa01778 | 136 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 | 137 | let builder = run.builder; |
cdc7bbd5 XL |
138 | let run = run.path("src/tools/linkchecker"); |
139 | run.default_condition(builder.config.docs) | |
2c00a5a8 XL |
140 | } |
141 | ||
9fa01778 | 142 | fn make_run(run: RunConfig<'_>) { |
2c00a5a8 XL |
143 | run.builder.ensure(Linkcheck { host: run.target }); |
144 | } | |
145 | } | |
146 | ||
147 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
148 | pub struct Cargotest { | |
149 | stage: u32, | |
3dfed10e | 150 | host: TargetSelection, |
2c00a5a8 XL |
151 | } |
152 | ||
153 | impl Step for Cargotest { | |
154 | type Output = (); | |
155 | const ONLY_HOSTS: bool = true; | |
156 | ||
9fa01778 | 157 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
158 | run.path("src/tools/cargotest") |
159 | } | |
160 | ||
9fa01778 | 161 | fn make_run(run: RunConfig<'_>) { |
dfeec247 | 162 | run.builder.ensure(Cargotest { stage: run.builder.top_stage, host: run.target }); |
2c00a5a8 XL |
163 | } |
164 | ||
165 | /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler. | |
166 | /// | |
167 | /// This tool in `src/tools` will check out a few Rust projects and run `cargo | |
168 | /// test` to ensure that we don't regress the test suites there. | |
9fa01778 | 169 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 | 170 | let compiler = builder.compiler(self.stage, self.host); |
dfeec247 | 171 | builder.ensure(compile::Rustc { compiler, target: compiler.host }); |
f035d41b | 172 | let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host }); |
2c00a5a8 XL |
173 | |
174 | // Note that this is a short, cryptic, and not scoped directory name. This | |
175 | // is currently to minimize the length of path on Windows where we otherwise | |
176 | // quickly run into path name limit constraints. | |
83c7162d | 177 | let out_dir = builder.out.join("ct"); |
2c00a5a8 XL |
178 | t!(fs::create_dir_all(&out_dir)); |
179 | ||
83c7162d | 180 | let _time = util::timeit(&builder); |
2c00a5a8 | 181 | let mut cmd = builder.tool_cmd(Tool::CargoTest); |
94b46f34 XL |
182 | try_run( |
183 | builder, | |
f035d41b | 184 | cmd.arg(&cargo) |
94b46f34 | 185 | .arg(&out_dir) |
17df50a5 | 186 | .args(builder.config.cmd.test_args()) |
94b46f34 | 187 | .env("RUSTC", builder.rustc(compiler)) |
532ac7d7 | 188 | .env("RUSTDOC", builder.rustdoc(compiler)), |
94b46f34 | 189 | ); |
2c00a5a8 XL |
190 | } |
191 | } | |
192 | ||
193 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
194 | pub struct Cargo { | |
195 | stage: u32, | |
3dfed10e | 196 | host: TargetSelection, |
2c00a5a8 XL |
197 | } |
198 | ||
199 | impl Step for Cargo { | |
200 | type Output = (); | |
201 | const ONLY_HOSTS: bool = true; | |
202 | ||
9fa01778 | 203 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
204 | run.path("src/tools/cargo") |
205 | } | |
206 | ||
9fa01778 | 207 | fn make_run(run: RunConfig<'_>) { |
dfeec247 | 208 | run.builder.ensure(Cargo { stage: run.builder.top_stage, host: run.target }); |
2c00a5a8 XL |
209 | } |
210 | ||
211 | /// Runs `cargo test` for `cargo` packaged with Rust. | |
9fa01778 | 212 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
213 | let compiler = builder.compiler(self.stage, self.host); |
214 | ||
dfeec247 XL |
215 | builder.ensure(tool::Cargo { compiler, target: self.host }); |
216 | let mut cargo = tool::prepare_tool_cargo( | |
217 | builder, | |
94b46f34 | 218 | compiler, |
dfeec247 XL |
219 | Mode::ToolRustc, |
220 | self.host, | |
221 | "test", | |
222 | "src/tools/cargo", | |
223 | SourceType::Submodule, | |
224 | &[], | |
225 | ); | |
8faf50e0 | 226 | |
83c7162d | 227 | if !builder.fail_fast { |
2c00a5a8 XL |
228 | cargo.arg("--no-fail-fast"); |
229 | } | |
6a06907d | 230 | cargo.arg("--").args(builder.config.cmd.test_args()); |
2c00a5a8 | 231 | |
2c00a5a8 XL |
232 | // Don't run cross-compile tests, we may not have cross-compiled libstd libs |
233 | // available. | |
234 | cargo.env("CFG_DISABLE_CROSS_TESTS", "1"); | |
b7449926 XL |
235 | // Disable a test that has issues with mingw. |
236 | cargo.env("CARGO_TEST_DISABLE_GIT_CLI", "1"); | |
416331ca XL |
237 | // Forcibly disable tests using nightly features since any changes to |
238 | // those features won't be able to land. | |
239 | cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1"); | |
2c00a5a8 | 240 | |
e1599b0c XL |
241 | cargo.env("PATH", &path_for_cargo(builder, compiler)); |
242 | ||
243 | try_run(builder, &mut cargo.into()); | |
2c00a5a8 XL |
244 | } |
245 | } | |
246 | ||
247 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
248 | pub struct Rls { | |
249 | stage: u32, | |
3dfed10e | 250 | host: TargetSelection, |
2c00a5a8 XL |
251 | } |
252 | ||
253 | impl Step for Rls { | |
254 | type Output = (); | |
255 | const ONLY_HOSTS: bool = true; | |
256 | ||
9fa01778 | 257 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
258 | run.path("src/tools/rls") |
259 | } | |
260 | ||
9fa01778 | 261 | fn make_run(run: RunConfig<'_>) { |
dfeec247 | 262 | run.builder.ensure(Rls { stage: run.builder.top_stage, host: run.target }); |
2c00a5a8 XL |
263 | } |
264 | ||
265 | /// Runs `cargo test` for the rls. | |
9fa01778 | 266 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
267 | let stage = self.stage; |
268 | let host = self.host; | |
269 | let compiler = builder.compiler(stage, host); | |
270 | ||
dfeec247 XL |
271 | let build_result = |
272 | builder.ensure(tool::Rls { compiler, target: self.host, extra_features: Vec::new() }); | |
83c7162d XL |
273 | if build_result.is_none() { |
274 | eprintln!("failed to test rls: could not build"); | |
275 | return; | |
276 | } | |
277 | ||
dfeec247 XL |
278 | let mut cargo = tool::prepare_tool_cargo( |
279 | builder, | |
280 | compiler, | |
281 | Mode::ToolRustc, | |
282 | host, | |
283 | "test", | |
284 | "src/tools/rls", | |
285 | SourceType::Submodule, | |
286 | &[], | |
287 | ); | |
2c00a5a8 | 288 | |
1b1a35ee | 289 | cargo.add_rustc_lib_path(builder, compiler); |
dfeec247 | 290 | cargo.arg("--").args(builder.config.cmd.test_args()); |
2c00a5a8 | 291 | |
e1599b0c | 292 | if try_run(builder, &mut cargo.into()) { |
83c7162d | 293 | builder.save_toolstate("rls", ToolState::TestPass); |
2c00a5a8 XL |
294 | } |
295 | } | |
296 | } | |
297 | ||
298 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
299 | pub struct Rustfmt { | |
300 | stage: u32, | |
3dfed10e | 301 | host: TargetSelection, |
2c00a5a8 XL |
302 | } |
303 | ||
304 | impl Step for Rustfmt { | |
305 | type Output = (); | |
306 | const ONLY_HOSTS: bool = true; | |
307 | ||
9fa01778 | 308 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
309 | run.path("src/tools/rustfmt") |
310 | } | |
311 | ||
9fa01778 | 312 | fn make_run(run: RunConfig<'_>) { |
dfeec247 | 313 | run.builder.ensure(Rustfmt { stage: run.builder.top_stage, host: run.target }); |
2c00a5a8 XL |
314 | } |
315 | ||
316 | /// Runs `cargo test` for rustfmt. | |
9fa01778 | 317 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
318 | let stage = self.stage; |
319 | let host = self.host; | |
320 | let compiler = builder.compiler(stage, host); | |
321 | ||
17df50a5 XL |
322 | builder |
323 | .ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() }) | |
324 | .expect("in-tree tool"); | |
83c7162d | 325 | |
dfeec247 XL |
326 | let mut cargo = tool::prepare_tool_cargo( |
327 | builder, | |
328 | compiler, | |
329 | Mode::ToolRustc, | |
330 | host, | |
331 | "test", | |
332 | "src/tools/rustfmt", | |
333 | SourceType::Submodule, | |
334 | &[], | |
335 | ); | |
2c00a5a8 | 336 | |
83c7162d XL |
337 | let dir = testdir(builder, compiler.host); |
338 | t!(fs::create_dir_all(&dir)); | |
339 | cargo.env("RUSTFMT_TEST_DIR", dir); | |
2c00a5a8 | 340 | |
1b1a35ee | 341 | cargo.add_rustc_lib_path(builder, compiler); |
2c00a5a8 | 342 | |
17df50a5 | 343 | builder.run(&mut cargo.into()); |
2c00a5a8 XL |
344 | } |
345 | } | |
346 | ||
cdc7bbd5 XL |
347 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
348 | pub struct RustDemangler { | |
349 | stage: u32, | |
350 | host: TargetSelection, | |
351 | } | |
352 | ||
353 | impl Step for RustDemangler { | |
354 | type Output = (); | |
355 | const ONLY_HOSTS: bool = true; | |
356 | ||
357 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
358 | run.path("src/tools/rust-demangler") | |
359 | } | |
360 | ||
361 | fn make_run(run: RunConfig<'_>) { | |
362 | run.builder.ensure(RustDemangler { stage: run.builder.top_stage, host: run.target }); | |
363 | } | |
364 | ||
365 | /// Runs `cargo test` for rust-demangler. | |
366 | fn run(self, builder: &Builder<'_>) { | |
367 | let stage = self.stage; | |
368 | let host = self.host; | |
369 | let compiler = builder.compiler(stage, host); | |
370 | ||
371 | let rust_demangler = builder | |
372 | .ensure(tool::RustDemangler { compiler, target: self.host, extra_features: Vec::new() }) | |
373 | .expect("in-tree tool"); | |
374 | let mut cargo = tool::prepare_tool_cargo( | |
375 | builder, | |
376 | compiler, | |
377 | Mode::ToolRustc, | |
378 | host, | |
379 | "test", | |
380 | "src/tools/rust-demangler", | |
381 | SourceType::InTree, | |
382 | &[], | |
383 | ); | |
384 | ||
385 | let dir = testdir(builder, compiler.host); | |
386 | t!(fs::create_dir_all(&dir)); | |
387 | ||
388 | cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler); | |
389 | ||
390 | cargo.arg("--").args(builder.config.cmd.test_args()); | |
391 | ||
392 | cargo.add_rustc_lib_path(builder, compiler); | |
393 | ||
394 | builder.run(&mut cargo.into()); | |
395 | } | |
396 | } | |
397 | ||
2c00a5a8 XL |
398 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
399 | pub struct Miri { | |
400 | stage: u32, | |
3dfed10e | 401 | host: TargetSelection, |
2c00a5a8 XL |
402 | } |
403 | ||
404 | impl Step for Miri { | |
405 | type Output = (); | |
406 | const ONLY_HOSTS: bool = true; | |
2c00a5a8 | 407 | |
9fa01778 | 408 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
416331ca | 409 | run.path("src/tools/miri") |
2c00a5a8 XL |
410 | } |
411 | ||
9fa01778 | 412 | fn make_run(run: RunConfig<'_>) { |
dfeec247 | 413 | run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target }); |
2c00a5a8 XL |
414 | } |
415 | ||
416 | /// Runs `cargo test` for miri. | |
9fa01778 | 417 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
418 | let stage = self.stage; |
419 | let host = self.host; | |
420 | let compiler = builder.compiler(stage, host); | |
421 | ||
dfeec247 XL |
422 | let miri = |
423 | builder.ensure(tool::Miri { compiler, target: self.host, extra_features: Vec::new() }); | |
f9f354fc XL |
424 | let cargo_miri = builder.ensure(tool::CargoMiri { |
425 | compiler, | |
426 | target: self.host, | |
427 | extra_features: Vec::new(), | |
428 | }); | |
429 | if let (Some(miri), Some(_cargo_miri)) = (miri, cargo_miri) { | |
f035d41b XL |
430 | let mut cargo = |
431 | builder.cargo(compiler, Mode::ToolRustc, SourceType::Submodule, host, "install"); | |
e74abb32 XL |
432 | cargo.arg("xargo"); |
433 | // Configure `cargo install` path. cargo adds a `bin/`. | |
434 | cargo.env("CARGO_INSTALL_ROOT", &builder.out); | |
435 | ||
436 | let mut cargo = Command::from(cargo); | |
437 | if !try_run(builder, &mut cargo) { | |
438 | return; | |
439 | } | |
440 | ||
416331ca | 441 | // # Run `cargo miri setup`. |
416331ca XL |
442 | let mut cargo = tool::prepare_tool_cargo( |
443 | builder, | |
444 | compiler, | |
445 | Mode::ToolRustc, | |
446 | host, | |
447 | "run", | |
f9f354fc | 448 | "src/tools/miri/cargo-miri", |
416331ca XL |
449 | SourceType::Submodule, |
450 | &[], | |
451 | ); | |
17df50a5 | 452 | cargo.add_rustc_lib_path(builder, compiler); |
f9f354fc | 453 | cargo.arg("--").arg("miri").arg("setup"); |
dfeec247 | 454 | |
416331ca | 455 | // Tell `cargo miri setup` where to find the sources. |
3dfed10e | 456 | cargo.env("XARGO_RUST_SRC", builder.src.join("library")); |
f9f354fc XL |
457 | // Tell it where to find Miri. |
458 | cargo.env("MIRI", &miri); | |
416331ca XL |
459 | // Debug things. |
460 | cargo.env("RUST_BACKTRACE", "1"); | |
e74abb32 | 461 | // Let cargo-miri know where xargo ended up. |
74b04a01 | 462 | cargo.env("XARGO_CHECK", builder.out.join("bin").join("xargo-check")); |
416331ca | 463 | |
e1599b0c | 464 | let mut cargo = Command::from(cargo); |
416331ca XL |
465 | if !try_run(builder, &mut cargo) { |
466 | return; | |
467 | } | |
468 | ||
469 | // # Determine where Miri put its sysroot. | |
74b04a01 | 470 | // To this end, we run `cargo miri setup --print-sysroot` and capture the output. |
416331ca XL |
471 | // (We do this separately from the above so that when the setup actually |
472 | // happens we get some output.) | |
473 | // We re-use the `cargo` from above. | |
e74abb32 | 474 | cargo.arg("--print-sysroot"); |
416331ca XL |
475 | |
476 | // FIXME: Is there a way in which we can re-use the usual `run` helpers? | |
477 | let miri_sysroot = if builder.config.dry_run { | |
478 | String::new() | |
479 | } else { | |
480 | builder.verbose(&format!("running: {:?}", cargo)); | |
dfeec247 XL |
481 | let out = cargo |
482 | .output() | |
416331ca XL |
483 | .expect("We already ran `cargo miri setup` before and that worked"); |
484 | assert!(out.status.success(), "`cargo miri setup` returned with non-0 exit code"); | |
e74abb32 | 485 | // Output is "<sysroot>\n". |
416331ca XL |
486 | let stdout = String::from_utf8(out.stdout) |
487 | .expect("`cargo miri setup` stdout is not valid UTF-8"); | |
e74abb32 XL |
488 | let sysroot = stdout.trim_end(); |
489 | builder.verbose(&format!("`cargo miri setup --print-sysroot` said: {:?}", sysroot)); | |
416331ca XL |
490 | sysroot.to_owned() |
491 | }; | |
492 | ||
493 | // # Run `cargo test`. | |
494 | let mut cargo = tool::prepare_tool_cargo( | |
495 | builder, | |
496 | compiler, | |
497 | Mode::ToolRustc, | |
498 | host, | |
499 | "test", | |
500 | "src/tools/miri", | |
501 | SourceType::Submodule, | |
502 | &[], | |
503 | ); | |
17df50a5 | 504 | cargo.add_rustc_lib_path(builder, compiler); |
2c00a5a8 | 505 | |
2c00a5a8 | 506 | // miri tests need to know about the stage sysroot |
416331ca | 507 | cargo.env("MIRI_SYSROOT", miri_sysroot); |
2c00a5a8 | 508 | cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler)); |
f9f354fc XL |
509 | cargo.env("MIRI", miri); |
510 | ||
511 | cargo.arg("--").args(builder.config.cmd.test_args()); | |
2c00a5a8 | 512 | |
cdc7bbd5 XL |
513 | let mut cargo = Command::from(cargo); |
514 | if !try_run(builder, &mut cargo) { | |
515 | return; | |
516 | } | |
517 | ||
518 | // # Run `cargo test` with `-Zmir-opt-level=4`. | |
519 | cargo.env("MIRIFLAGS", "-O -Zmir-opt-level=4"); | |
520 | if !try_run(builder, &mut cargo) { | |
416331ca | 521 | return; |
2c00a5a8 | 522 | } |
416331ca XL |
523 | |
524 | // # Done! | |
525 | builder.save_toolstate("miri", ToolState::TestPass); | |
2c00a5a8 XL |
526 | } else { |
527 | eprintln!("failed to test miri: could not build"); | |
528 | } | |
529 | } | |
530 | } | |
531 | ||
0731742a XL |
532 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
533 | pub struct CompiletestTest { | |
3dfed10e | 534 | host: TargetSelection, |
0731742a XL |
535 | } |
536 | ||
537 | impl Step for CompiletestTest { | |
538 | type Output = (); | |
539 | ||
9fa01778 | 540 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
0731742a XL |
541 | run.path("src/tools/compiletest") |
542 | } | |
543 | ||
9fa01778 | 544 | fn make_run(run: RunConfig<'_>) { |
dfeec247 | 545 | run.builder.ensure(CompiletestTest { host: run.target }); |
0731742a XL |
546 | } |
547 | ||
548 | /// Runs `cargo test` for compiletest. | |
9fa01778 | 549 | fn run(self, builder: &Builder<'_>) { |
0731742a | 550 | let host = self.host; |
532ac7d7 | 551 | let compiler = builder.compiler(0, host); |
0731742a | 552 | |
fc512014 XL |
553 | // We need `ToolStd` for the locally-built sysroot because |
554 | // compiletest uses unstable features of the `test` crate. | |
555 | builder.ensure(compile::Std { compiler, target: host }); | |
dfeec247 XL |
556 | let cargo = tool::prepare_tool_cargo( |
557 | builder, | |
558 | compiler, | |
fc512014 | 559 | Mode::ToolStd, |
dfeec247 XL |
560 | host, |
561 | "test", | |
562 | "src/tools/compiletest", | |
563 | SourceType::InTree, | |
564 | &[], | |
565 | ); | |
0731742a | 566 | |
e1599b0c | 567 | try_run(builder, &mut cargo.into()); |
0731742a XL |
568 | } |
569 | } | |
570 | ||
2c00a5a8 XL |
571 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
572 | pub struct Clippy { | |
573 | stage: u32, | |
3dfed10e | 574 | host: TargetSelection, |
2c00a5a8 XL |
575 | } |
576 | ||
577 | impl Step for Clippy { | |
578 | type Output = (); | |
579 | const ONLY_HOSTS: bool = true; | |
580 | const DEFAULT: bool = false; | |
581 | ||
9fa01778 | 582 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
583 | run.path("src/tools/clippy") |
584 | } | |
585 | ||
9fa01778 | 586 | fn make_run(run: RunConfig<'_>) { |
dfeec247 | 587 | run.builder.ensure(Clippy { stage: run.builder.top_stage, host: run.target }); |
2c00a5a8 XL |
588 | } |
589 | ||
590 | /// Runs `cargo test` for clippy. | |
9fa01778 | 591 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
592 | let stage = self.stage; |
593 | let host = self.host; | |
594 | let compiler = builder.compiler(stage, host); | |
595 | ||
f9f354fc XL |
596 | let clippy = builder |
597 | .ensure(tool::Clippy { compiler, target: self.host, extra_features: Vec::new() }) | |
598 | .expect("in-tree tool"); | |
599 | let mut cargo = tool::prepare_tool_cargo( | |
600 | builder, | |
0531ce1d | 601 | compiler, |
f9f354fc XL |
602 | Mode::ToolRustc, |
603 | host, | |
604 | "test", | |
605 | "src/tools/clippy", | |
606 | SourceType::InTree, | |
607 | &[], | |
608 | ); | |
2c00a5a8 | 609 | |
f9f354fc XL |
610 | // clippy tests need to know about the stage sysroot |
611 | cargo.env("SYSROOT", builder.sysroot(compiler)); | |
612 | cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler)); | |
613 | cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler)); | |
614 | let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir()); | |
3dfed10e XL |
615 | let target_libs = builder |
616 | .stage_out(compiler, Mode::ToolRustc) | |
617 | .join(&self.host.triple) | |
618 | .join(builder.cargo_dir()); | |
f9f354fc XL |
619 | cargo.env("HOST_LIBS", host_libs); |
620 | cargo.env("TARGET_LIBS", target_libs); | |
621 | // clippy tests need to find the driver | |
622 | cargo.env("CLIPPY_DRIVER_PATH", clippy); | |
2c00a5a8 | 623 | |
f9f354fc | 624 | cargo.arg("--").args(builder.config.cmd.test_args()); |
2c00a5a8 | 625 | |
1b1a35ee | 626 | cargo.add_rustc_lib_path(builder, compiler); |
f9f354fc | 627 | |
cdc7bbd5 XL |
628 | if builder.try_run(&mut cargo.into()) { |
629 | // The tests succeeded; nothing to do. | |
630 | return; | |
631 | } | |
632 | ||
633 | if !builder.config.cmd.bless() { | |
634 | std::process::exit(1); | |
635 | } | |
636 | ||
637 | let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run"); | |
638 | cargo.arg("-p").arg("clippy_dev"); | |
639 | // clippy_dev gets confused if it can't find `clippy/Cargo.toml` | |
640 | cargo.current_dir(&builder.src.join("src").join("tools").join("clippy")); | |
641 | if builder.config.rust_optimize { | |
642 | cargo.env("PROFILE", "release"); | |
643 | } else { | |
644 | cargo.env("PROFILE", "debug"); | |
645 | } | |
646 | cargo.arg("--"); | |
647 | cargo.arg("bless"); | |
f035d41b | 648 | builder.run(&mut cargo.into()); |
2c00a5a8 XL |
649 | } |
650 | } | |
651 | ||
9fa01778 | 652 | fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString { |
2c00a5a8 XL |
653 | // Configure PATH to find the right rustc. NB. we have to use PATH |
654 | // and not RUSTC because the Cargo test suite has tests that will | |
655 | // fail if rustc is not spelled `rustc`. | |
656 | let path = builder.sysroot(compiler).join("bin"); | |
657 | let old_path = env::var_os("PATH").unwrap_or_default(); | |
658 | env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("") | |
659 | } | |
660 | ||
661 | #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] | |
662 | pub struct RustdocTheme { | |
663 | pub compiler: Compiler, | |
664 | } | |
665 | ||
666 | impl Step for RustdocTheme { | |
667 | type Output = (); | |
668 | const DEFAULT: bool = true; | |
669 | const ONLY_HOSTS: bool = true; | |
670 | ||
9fa01778 | 671 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
672 | run.path("src/tools/rustdoc-themes") |
673 | } | |
674 | ||
9fa01778 | 675 | fn make_run(run: RunConfig<'_>) { |
1b1a35ee | 676 | let compiler = run.builder.compiler(run.builder.top_stage, run.target); |
2c00a5a8 | 677 | |
a1dfa0c6 | 678 | run.builder.ensure(RustdocTheme { compiler }); |
2c00a5a8 XL |
679 | } |
680 | ||
9fa01778 | 681 | fn run(self, builder: &Builder<'_>) { |
83c7162d | 682 | let rustdoc = builder.out.join("bootstrap/debug/rustdoc"); |
2c00a5a8 XL |
683 | let mut cmd = builder.tool_cmd(Tool::RustdocTheme); |
684 | cmd.arg(rustdoc.to_str().unwrap()) | |
dfeec247 | 685 | .arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()) |
94b46f34 XL |
686 | .env("RUSTC_STAGE", self.compiler.stage.to_string()) |
687 | .env("RUSTC_SYSROOT", builder.sysroot(self.compiler)) | |
dfeec247 | 688 | .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host)) |
94b46f34 | 689 | .env("CFG_RELEASE_CHANNEL", &builder.config.channel) |
532ac7d7 | 690 | .env("RUSTDOC_REAL", builder.rustdoc(self.compiler)) |
94b46f34 | 691 | .env("RUSTC_BOOTSTRAP", "1"); |
1b1a35ee XL |
692 | if let Some(linker) = builder.linker(self.compiler.host) { |
693 | cmd.env("RUSTDOC_LINKER", linker); | |
694 | } | |
695 | if builder.is_fuse_ld_lld(self.compiler.host) { | |
696 | cmd.env("RUSTDOC_FUSE_LD_LLD", "1"); | |
2c00a5a8 | 697 | } |
83c7162d | 698 | try_run(builder, &mut cmd); |
2c00a5a8 XL |
699 | } |
700 | } | |
701 | ||
702 | #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] | |
9fa01778 | 703 | pub struct RustdocJSStd { |
3dfed10e | 704 | pub target: TargetSelection, |
2c00a5a8 XL |
705 | } |
706 | ||
9fa01778 | 707 | impl Step for RustdocJSStd { |
2c00a5a8 XL |
708 | type Output = (); |
709 | const DEFAULT: bool = true; | |
710 | const ONLY_HOSTS: bool = true; | |
711 | ||
9fa01778 XL |
712 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
713 | run.path("src/test/rustdoc-js-std") | |
2c00a5a8 XL |
714 | } |
715 | ||
9fa01778 | 716 | fn make_run(run: RunConfig<'_>) { |
ba9703b0 | 717 | run.builder.ensure(RustdocJSStd { target: run.target }); |
2c00a5a8 XL |
718 | } |
719 | ||
9fa01778 | 720 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
721 | if let Some(ref nodejs) = builder.config.nodejs { |
722 | let mut command = Command::new(nodejs); | |
ba9703b0 XL |
723 | command |
724 | .arg(builder.src.join("src/tools/rustdoc-js/tester.js")) | |
725 | .arg("--crate-name") | |
726 | .arg("std") | |
727 | .arg("--resource-suffix") | |
1b1a35ee | 728 | .arg(&builder.version) |
ba9703b0 XL |
729 | .arg("--doc-folder") |
730 | .arg(builder.doc_out(self.target)) | |
731 | .arg("--test-folder") | |
732 | .arg(builder.src.join("src/test/rustdoc-js-std")); | |
dfeec247 | 733 | builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage }); |
2c00a5a8 | 734 | builder.run(&mut command); |
9fa01778 | 735 | } else { |
dfeec247 | 736 | builder.info("No nodejs found, skipping \"src/test/rustdoc-js-std\" tests"); |
9fa01778 XL |
737 | } |
738 | } | |
739 | } | |
740 | ||
741 | #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] | |
742 | pub struct RustdocJSNotStd { | |
3dfed10e | 743 | pub target: TargetSelection, |
9fa01778 XL |
744 | pub compiler: Compiler, |
745 | } | |
746 | ||
747 | impl Step for RustdocJSNotStd { | |
748 | type Output = (); | |
749 | const DEFAULT: bool = true; | |
750 | const ONLY_HOSTS: bool = true; | |
751 | ||
752 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
753 | run.path("src/test/rustdoc-js") | |
754 | } | |
755 | ||
756 | fn make_run(run: RunConfig<'_>) { | |
1b1a35ee XL |
757 | let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); |
758 | run.builder.ensure(RustdocJSNotStd { target: run.target, compiler }); | |
9fa01778 XL |
759 | } |
760 | ||
761 | fn run(self, builder: &Builder<'_>) { | |
762 | if builder.config.nodejs.is_some() { | |
763 | builder.ensure(Compiletest { | |
764 | compiler: self.compiler, | |
765 | target: self.target, | |
766 | mode: "js-doc-test", | |
767 | suite: "rustdoc-js", | |
74b04a01 | 768 | path: "src/test/rustdoc-js", |
9fa01778 XL |
769 | compare_mode: None, |
770 | }); | |
2c00a5a8 | 771 | } else { |
dfeec247 | 772 | builder.info("No nodejs found, skipping \"src/test/rustdoc-js\" tests"); |
2c00a5a8 XL |
773 | } |
774 | } | |
775 | } | |
776 | ||
17df50a5 XL |
777 | fn check_if_browser_ui_test_is_installed_global(npm: &Path, global: bool) -> bool { |
778 | let mut command = Command::new(&npm); | |
779 | command.arg("list").arg("--depth=0"); | |
780 | if global { | |
781 | command.arg("--global"); | |
782 | } | |
783 | let lines = command | |
784 | .output() | |
785 | .map(|output| String::from_utf8_lossy(&output.stdout).into_owned()) | |
786 | .unwrap_or(String::new()); | |
787 | lines.contains(&" browser-ui-test@") | |
788 | } | |
789 | ||
790 | fn check_if_browser_ui_test_is_installed(npm: &Path) -> bool { | |
791 | check_if_browser_ui_test_is_installed_global(npm, false) | |
792 | || check_if_browser_ui_test_is_installed_global(npm, true) | |
793 | } | |
794 | ||
6a06907d XL |
795 | #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] |
796 | pub struct RustdocGUI { | |
797 | pub target: TargetSelection, | |
798 | pub compiler: Compiler, | |
799 | } | |
800 | ||
801 | impl Step for RustdocGUI { | |
802 | type Output = (); | |
803 | const DEFAULT: bool = true; | |
804 | const ONLY_HOSTS: bool = true; | |
805 | ||
806 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
17df50a5 XL |
807 | let builder = run.builder; |
808 | let run = run.path("src/test/rustdoc-gui"); | |
809 | run.default_condition( | |
810 | builder.config.nodejs.is_some() | |
811 | && builder | |
812 | .config | |
813 | .npm | |
814 | .as_ref() | |
815 | .map(|p| check_if_browser_ui_test_is_installed(p)) | |
816 | .unwrap_or(false), | |
817 | ) | |
6a06907d XL |
818 | } |
819 | ||
820 | fn make_run(run: RunConfig<'_>) { | |
821 | let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); | |
822 | run.builder.ensure(RustdocGUI { target: run.target, compiler }); | |
823 | } | |
824 | ||
825 | fn run(self, builder: &Builder<'_>) { | |
17df50a5 XL |
826 | let nodejs = builder.config.nodejs.as_ref().expect("nodejs isn't available"); |
827 | let npm = builder.config.npm.as_ref().expect("npm isn't available"); | |
6a06907d | 828 | |
17df50a5 XL |
829 | builder.ensure(compile::Std { compiler: self.compiler, target: self.target }); |
830 | ||
831 | // The goal here is to check if the necessary packages are installed, and if not, we | |
832 | // panic. | |
833 | if !check_if_browser_ui_test_is_installed(&npm) { | |
834 | eprintln!( | |
835 | "error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \ | |
836 | dependency is missing", | |
837 | ); | |
838 | eprintln!( | |
839 | "If you want to install the `{0}` dependency, run `npm install {0}`", | |
840 | "browser-ui-test", | |
841 | ); | |
842 | panic!("Cannot run rustdoc-gui tests"); | |
843 | } | |
6a06907d | 844 | |
17df50a5 | 845 | let out_dir = builder.test_out(self.target).join("rustdoc-gui"); |
6a06907d | 846 | |
17df50a5 XL |
847 | // We remove existing folder to be sure there won't be artifacts remaining. |
848 | let _ = fs::remove_dir_all(&out_dir); | |
849 | ||
850 | let mut nb_generated = 0; | |
851 | // We generate docs for the libraries present in the rustdoc-gui's src folder. | |
852 | let libs_dir = builder.build.src.join("src/test/rustdoc-gui/src"); | |
853 | for entry in libs_dir.read_dir().expect("read_dir call failed") { | |
854 | let entry = entry.expect("invalid entry"); | |
855 | let path = entry.path(); | |
856 | if path.extension().map(|e| e == "rs").unwrap_or(false) { | |
857 | let mut command = builder.rustdoc_cmd(self.compiler); | |
858 | command.arg(path).arg("-o").arg(&out_dir); | |
6a06907d | 859 | builder.run(&mut command); |
17df50a5 | 860 | nb_generated += 1; |
6a06907d | 861 | } |
6a06907d | 862 | } |
17df50a5 XL |
863 | assert!(nb_generated > 0, "no documentation was generated..."); |
864 | ||
865 | // We now run GUI tests. | |
866 | let mut command = Command::new(&nodejs); | |
867 | command | |
868 | .arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js")) | |
869 | .arg("--doc-folder") | |
870 | .arg(out_dir) | |
871 | .arg("--tests-folder") | |
872 | .arg(builder.build.src.join("src/test/rustdoc-gui")); | |
873 | builder.run(&mut command); | |
6a06907d XL |
874 | } |
875 | } | |
876 | ||
2c00a5a8 | 877 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
0531ce1d | 878 | pub struct Tidy; |
2c00a5a8 XL |
879 | |
880 | impl Step for Tidy { | |
881 | type Output = (); | |
882 | const DEFAULT: bool = true; | |
883 | const ONLY_HOSTS: bool = true; | |
2c00a5a8 | 884 | |
0531ce1d | 885 | /// Runs the `tidy` tool. |
2c00a5a8 XL |
886 | /// |
887 | /// This tool in `src/tools` checks up on various bits and pieces of style and | |
888 | /// otherwise just implements a few lint-like checks that are specific to the | |
889 | /// compiler itself. | |
dfeec247 XL |
890 | /// |
891 | /// Once tidy passes, this step also runs `fmt --check` if tests are being run | |
892 | /// for the `dev` or `nightly` channels. | |
9fa01778 | 893 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 | 894 | let mut cmd = builder.tool_cmd(Tool::Tidy); |
1b1a35ee | 895 | cmd.arg(&builder.src); |
83c7162d | 896 | cmd.arg(&builder.initial_cargo); |
29967ef6 | 897 | cmd.arg(&builder.out); |
cdc7bbd5 | 898 | cmd.arg(builder.jobs().to_string()); |
dc9dc135 XL |
899 | if builder.is_verbose() { |
900 | cmd.arg("--verbose"); | |
2c00a5a8 | 901 | } |
0531ce1d | 902 | |
a1dfa0c6 | 903 | builder.info("tidy check"); |
83c7162d | 904 | try_run(builder, &mut cmd); |
dfeec247 XL |
905 | |
906 | if builder.config.channel == "dev" || builder.config.channel == "nightly" { | |
907 | builder.info("fmt check"); | |
6a06907d XL |
908 | if builder.config.initial_rustfmt.is_none() { |
909 | let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap(); | |
910 | eprintln!( | |
911 | "\ | |
912 | error: no `rustfmt` binary found in {PATH} | |
913 | info: `rust.channel` is currently set to \"{CHAN}\" | |
914 | help: if you are testing a beta branch, set `rust.channel` to \"beta\" in the `config.toml` file | |
915 | help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy` to `x.py test`", | |
916 | PATH = inferred_rustfmt_dir.display(), | |
917 | CHAN = builder.config.channel, | |
918 | ); | |
919 | std::process::exit(1); | |
920 | } | |
17df50a5 | 921 | crate::format::format(&builder.build, !builder.config.cmd.bless(), &[]); |
dfeec247 | 922 | } |
2c00a5a8 XL |
923 | } |
924 | ||
9fa01778 | 925 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
926 | run.path("src/tools/tidy") |
927 | } | |
928 | ||
9fa01778 | 929 | fn make_run(run: RunConfig<'_>) { |
0531ce1d | 930 | run.builder.ensure(Tidy); |
2c00a5a8 XL |
931 | } |
932 | } | |
933 | ||
ba9703b0 XL |
934 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
935 | pub struct ExpandYamlAnchors; | |
936 | ||
937 | impl Step for ExpandYamlAnchors { | |
938 | type Output = (); | |
939 | const ONLY_HOSTS: bool = true; | |
940 | ||
941 | /// Ensure the `generate-ci-config` tool was run locally. | |
942 | /// | |
943 | /// The tool in `src/tools` reads the CI definition in `src/ci/builders.yml` and generates the | |
944 | /// appropriate configuration for all our CI providers. This step ensures the tool was called | |
945 | /// by the user before committing CI changes. | |
946 | fn run(self, builder: &Builder<'_>) { | |
947 | builder.info("Ensuring the YAML anchors in the GitHub Actions config were expanded"); | |
948 | try_run( | |
949 | builder, | |
950 | &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src), | |
951 | ); | |
952 | } | |
953 | ||
954 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
955 | run.path("src/tools/expand-yaml-anchors") | |
956 | } | |
957 | ||
958 | fn make_run(run: RunConfig<'_>) { | |
959 | run.builder.ensure(ExpandYamlAnchors); | |
960 | } | |
961 | } | |
962 | ||
3dfed10e XL |
963 | fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf { |
964 | builder.out.join(host.triple).join("test") | |
2c00a5a8 XL |
965 | } |
966 | ||
967 | macro_rules! default_test { | |
968 | ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => { | |
969 | test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: false }); | |
dfeec247 | 970 | }; |
2c00a5a8 XL |
971 | } |
972 | ||
83c7162d XL |
973 | macro_rules! default_test_with_compare_mode { |
974 | ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, | |
975 | compare_mode: $compare_mode:expr }) => { | |
dfeec247 XL |
976 | test_with_compare_mode!($name { |
977 | path: $path, | |
978 | mode: $mode, | |
979 | suite: $suite, | |
980 | default: true, | |
981 | host: false, | |
982 | compare_mode: $compare_mode | |
983 | }); | |
984 | }; | |
83c7162d XL |
985 | } |
986 | ||
2c00a5a8 XL |
987 | macro_rules! host_test { |
988 | ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => { | |
989 | test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: true }); | |
dfeec247 | 990 | }; |
2c00a5a8 XL |
991 | } |
992 | ||
993 | macro_rules! test { | |
83c7162d XL |
994 | ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr, |
995 | host: $host:expr }) => { | |
dfeec247 XL |
996 | test_definitions!($name { |
997 | path: $path, | |
998 | mode: $mode, | |
999 | suite: $suite, | |
1000 | default: $default, | |
1001 | host: $host, | |
1002 | compare_mode: None | |
1003 | }); | |
1004 | }; | |
83c7162d XL |
1005 | } |
1006 | ||
1007 | macro_rules! test_with_compare_mode { | |
1008 | ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr, | |
1009 | host: $host:expr, compare_mode: $compare_mode:expr }) => { | |
dfeec247 XL |
1010 | test_definitions!($name { |
1011 | path: $path, | |
1012 | mode: $mode, | |
1013 | suite: $suite, | |
1014 | default: $default, | |
1015 | host: $host, | |
1016 | compare_mode: Some($compare_mode) | |
1017 | }); | |
1018 | }; | |
83c7162d XL |
1019 | } |
1020 | ||
1021 | macro_rules! test_definitions { | |
2c00a5a8 XL |
1022 | ($name:ident { |
1023 | path: $path:expr, | |
1024 | mode: $mode:expr, | |
1025 | suite: $suite:expr, | |
1026 | default: $default:expr, | |
83c7162d XL |
1027 | host: $host:expr, |
1028 | compare_mode: $compare_mode:expr | |
2c00a5a8 XL |
1029 | }) => { |
1030 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
1031 | pub struct $name { | |
1032 | pub compiler: Compiler, | |
3dfed10e | 1033 | pub target: TargetSelection, |
2c00a5a8 XL |
1034 | } |
1035 | ||
1036 | impl Step for $name { | |
1037 | type Output = (); | |
1038 | const DEFAULT: bool = $default; | |
1039 | const ONLY_HOSTS: bool = $host; | |
1040 | ||
9fa01778 | 1041 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
94b46f34 | 1042 | run.suite_path($path) |
2c00a5a8 XL |
1043 | } |
1044 | ||
9fa01778 | 1045 | fn make_run(run: RunConfig<'_>) { |
1b1a35ee | 1046 | let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); |
2c00a5a8 | 1047 | |
dfeec247 | 1048 | run.builder.ensure($name { compiler, target: run.target }); |
2c00a5a8 XL |
1049 | } |
1050 | ||
9fa01778 | 1051 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
1052 | builder.ensure(Compiletest { |
1053 | compiler: self.compiler, | |
1054 | target: self.target, | |
1055 | mode: $mode, | |
1056 | suite: $suite, | |
74b04a01 | 1057 | path: $path, |
83c7162d | 1058 | compare_mode: $compare_mode, |
2c00a5a8 XL |
1059 | }) |
1060 | } | |
1061 | } | |
dfeec247 | 1062 | }; |
2c00a5a8 XL |
1063 | } |
1064 | ||
83c7162d | 1065 | default_test_with_compare_mode!(Ui { |
2c00a5a8 XL |
1066 | path: "src/test/ui", |
1067 | mode: "ui", | |
83c7162d XL |
1068 | suite: "ui", |
1069 | compare_mode: "nll" | |
2c00a5a8 XL |
1070 | }); |
1071 | ||
2c00a5a8 XL |
1072 | default_test!(RunPassValgrind { |
1073 | path: "src/test/run-pass-valgrind", | |
1074 | mode: "run-pass-valgrind", | |
1075 | suite: "run-pass-valgrind" | |
1076 | }); | |
1077 | ||
dfeec247 | 1078 | default_test!(MirOpt { path: "src/test/mir-opt", mode: "mir-opt", suite: "mir-opt" }); |
2c00a5a8 | 1079 | |
dfeec247 | 1080 | default_test!(Codegen { path: "src/test/codegen", mode: "codegen", suite: "codegen" }); |
2c00a5a8 XL |
1081 | |
1082 | default_test!(CodegenUnits { | |
1083 | path: "src/test/codegen-units", | |
1084 | mode: "codegen-units", | |
1085 | suite: "codegen-units" | |
1086 | }); | |
1087 | ||
1088 | default_test!(Incremental { | |
1089 | path: "src/test/incremental", | |
1090 | mode: "incremental", | |
1091 | suite: "incremental" | |
1092 | }); | |
1093 | ||
fc512014 XL |
1094 | default_test_with_compare_mode!(Debuginfo { |
1095 | path: "src/test/debuginfo", | |
1096 | mode: "debuginfo", | |
1097 | suite: "debuginfo", | |
1098 | compare_mode: "split-dwarf" | |
1099 | }); | |
2c00a5a8 | 1100 | |
dfeec247 | 1101 | host_test!(UiFullDeps { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" }); |
2c00a5a8 | 1102 | |
dfeec247 | 1103 | host_test!(Rustdoc { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" }); |
fc512014 XL |
1104 | host_test!(RustdocUi { path: "src/test/rustdoc-ui", mode: "ui", suite: "rustdoc-ui" }); |
1105 | ||
1106 | host_test!(RustdocJson { | |
1107 | path: "src/test/rustdoc-json", | |
1108 | mode: "rustdoc-json", | |
1109 | suite: "rustdoc-json" | |
1110 | }); | |
2c00a5a8 | 1111 | |
dfeec247 | 1112 | host_test!(Pretty { path: "src/test/pretty", mode: "pretty", suite: "pretty" }); |
2c00a5a8 | 1113 | |
dfeec247 | 1114 | default_test!(RunMake { path: "src/test/run-make", mode: "run-make", suite: "run-make" }); |
2c00a5a8 | 1115 | |
0531ce1d XL |
1116 | host_test!(RunMakeFullDeps { |
1117 | path: "src/test/run-make-fulldeps", | |
1118 | mode: "run-make", | |
1119 | suite: "run-make-fulldeps" | |
1120 | }); | |
1121 | ||
dfeec247 | 1122 | default_test!(Assembly { path: "src/test/assembly", mode: "assembly", suite: "assembly" }); |
532ac7d7 | 1123 | |
2c00a5a8 XL |
1124 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
1125 | struct Compiletest { | |
1126 | compiler: Compiler, | |
3dfed10e | 1127 | target: TargetSelection, |
2c00a5a8 XL |
1128 | mode: &'static str, |
1129 | suite: &'static str, | |
74b04a01 | 1130 | path: &'static str, |
83c7162d | 1131 | compare_mode: Option<&'static str>, |
2c00a5a8 XL |
1132 | } |
1133 | ||
1134 | impl Step for Compiletest { | |
1135 | type Output = (); | |
1136 | ||
9fa01778 | 1137 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
1138 | run.never() |
1139 | } | |
1140 | ||
1141 | /// Executes the `compiletest` tool to run a suite of tests. | |
1142 | /// | |
1143 | /// Compiles all tests with `compiler` for `target` with the specified | |
1144 | /// compiletest `mode` and `suite` arguments. For example `mode` can be | |
1145 | /// "run-pass" or `suite` can be something like `debuginfo`. | |
9fa01778 | 1146 | fn run(self, builder: &Builder<'_>) { |
29967ef6 XL |
1147 | if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() { |
1148 | eprintln!("\ | |
1149 | error: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail | |
1150 | help: to test the compiler, use `--stage 1` instead | |
1151 | help: to test the standard library, use `--stage 0 library/std` instead | |
1152 | note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`." | |
1153 | ); | |
1154 | std::process::exit(1); | |
1155 | } | |
1156 | ||
2c00a5a8 XL |
1157 | let compiler = self.compiler; |
1158 | let target = self.target; | |
1159 | let mode = self.mode; | |
1160 | let suite = self.suite; | |
94b46f34 XL |
1161 | |
1162 | // Path for test suite | |
74b04a01 | 1163 | let suite_path = self.path; |
2c00a5a8 XL |
1164 | |
1165 | // Skip codegen tests if they aren't enabled in configuration. | |
83c7162d | 1166 | if !builder.config.codegen_tests && suite == "codegen" { |
2c00a5a8 XL |
1167 | return; |
1168 | } | |
1169 | ||
1170 | if suite == "debuginfo" { | |
dfeec247 XL |
1171 | builder |
1172 | .ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target }); | |
2c00a5a8 XL |
1173 | } |
1174 | ||
532ac7d7 | 1175 | if suite.ends_with("fulldeps") { |
2c00a5a8 XL |
1176 | builder.ensure(compile::Rustc { compiler, target }); |
1177 | } | |
1178 | ||
e1599b0c XL |
1179 | builder.ensure(compile::Std { compiler, target }); |
1180 | // ensure that `libproc_macro` is available on the host. | |
1181 | builder.ensure(compile::Std { compiler, target: compiler.host }); | |
b7449926 | 1182 | |
a1dfa0c6 XL |
1183 | // Also provide `rust_test_helpers` for the host. |
1184 | builder.ensure(native::TestHelpers { target: compiler.host }); | |
1185 | ||
e74abb32 XL |
1186 | // As well as the target, except for plain wasm32, which can't build it |
1187 | if !target.contains("wasm32") || target.contains("emscripten") { | |
48663c56 XL |
1188 | builder.ensure(native::TestHelpers { target }); |
1189 | } | |
e74abb32 | 1190 | |
2c00a5a8 XL |
1191 | builder.ensure(RemoteCopyLibs { compiler, target }); |
1192 | ||
2c00a5a8 XL |
1193 | let mut cmd = builder.tool_cmd(Tool::Compiletest); |
1194 | ||
1195 | // compiletest currently has... a lot of arguments, so let's just pass all | |
1196 | // of them! | |
1197 | ||
dfeec247 XL |
1198 | cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler)); |
1199 | cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target)); | |
2c00a5a8 XL |
1200 | cmd.arg("--rustc-path").arg(builder.rustc(compiler)); |
1201 | ||
9fa01778 | 1202 | let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js"); |
83c7162d | 1203 | |
2c00a5a8 | 1204 | // Avoid depending on rustdoc when we don't need it. |
94b46f34 | 1205 | if mode == "rustdoc" |
6a06907d | 1206 | || mode == "run-make" |
9fa01778 XL |
1207 | || (mode == "ui" && is_rustdoc) |
1208 | || mode == "js-doc-test" | |
fc512014 | 1209 | || mode == "rustdoc-json" |
94b46f34 | 1210 | { |
dfeec247 | 1211 | cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler)); |
2c00a5a8 XL |
1212 | } |
1213 | ||
5869c6ff XL |
1214 | if mode == "rustdoc-json" { |
1215 | // Use the beta compiler for jsondocck | |
1216 | let json_compiler = compiler.with_stage(0); | |
1217 | cmd.arg("--jsondocck-path") | |
1218 | .arg(builder.ensure(tool::JsonDocCk { compiler: json_compiler, target })); | |
1219 | } | |
1220 | ||
3dfed10e | 1221 | if mode == "run-make" && suite.ends_with("fulldeps") { |
cdc7bbd5 XL |
1222 | let rust_demangler = builder |
1223 | .ensure(tool::RustDemangler { compiler, target, extra_features: Vec::new() }) | |
1224 | .expect("in-tree tool"); | |
1225 | cmd.arg("--rust-demangler-path").arg(rust_demangler); | |
3dfed10e XL |
1226 | } |
1227 | ||
dfeec247 XL |
1228 | cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite)); |
1229 | cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite)); | |
1230 | cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target)); | |
29967ef6 | 1231 | cmd.arg("--suite").arg(suite); |
2c00a5a8 | 1232 | cmd.arg("--mode").arg(mode); |
3dfed10e XL |
1233 | cmd.arg("--target").arg(target.rustc_target_arg()); |
1234 | cmd.arg("--host").arg(&*compiler.host.triple); | |
dfeec247 | 1235 | cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build)); |
94b46f34 XL |
1236 | |
1237 | if builder.config.cmd.bless() { | |
1238 | cmd.arg("--bless"); | |
1239 | } | |
1240 | ||
dfeec247 XL |
1241 | let compare_mode = |
1242 | builder.config.cmd.compare_mode().or_else(|| { | |
1243 | if builder.config.test_compare_mode { self.compare_mode } else { None } | |
1244 | }); | |
2c00a5a8 | 1245 | |
dc9dc135 XL |
1246 | if let Some(ref pass) = builder.config.cmd.pass() { |
1247 | cmd.arg("--pass"); | |
1248 | cmd.arg(pass); | |
1249 | } | |
1250 | ||
17df50a5 XL |
1251 | if let Some(ref run) = builder.config.cmd.run() { |
1252 | cmd.arg("--run"); | |
1253 | cmd.arg(run); | |
1254 | } | |
1255 | ||
83c7162d | 1256 | if let Some(ref nodejs) = builder.config.nodejs { |
2c00a5a8 XL |
1257 | cmd.arg("--nodejs").arg(nodejs); |
1258 | } | |
6a06907d XL |
1259 | if let Some(ref npm) = builder.config.npm { |
1260 | cmd.arg("--npm").arg(npm); | |
1261 | } | |
2c00a5a8 | 1262 | |
dfeec247 | 1263 | let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] }; |
9fa01778 | 1264 | if !is_rustdoc { |
83c7162d XL |
1265 | if builder.config.rust_optimize_tests { |
1266 | flags.push("-O".to_string()); | |
1267 | } | |
2c00a5a8 | 1268 | } |
dc9dc135 | 1269 | flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests)); |
83c7162d | 1270 | flags.push(builder.config.cmd.rustc_args().join(" ")); |
2c00a5a8 | 1271 | |
1b1a35ee | 1272 | if let Some(linker) = builder.linker(target) { |
2c00a5a8 XL |
1273 | cmd.arg("--linker").arg(linker); |
1274 | } | |
1275 | ||
a1dfa0c6 | 1276 | let mut hostflags = flags.clone(); |
dfeec247 | 1277 | hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display())); |
17df50a5 | 1278 | hostflags.extend(builder.lld_flags(compiler.host)); |
2c00a5a8 XL |
1279 | cmd.arg("--host-rustcflags").arg(hostflags.join(" ")); |
1280 | ||
0bf4aa26 | 1281 | let mut targetflags = flags; |
dfeec247 | 1282 | targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display())); |
17df50a5 | 1283 | targetflags.extend(builder.lld_flags(target)); |
2c00a5a8 XL |
1284 | cmd.arg("--target-rustcflags").arg(targetflags.join(" ")); |
1285 | ||
83c7162d | 1286 | cmd.arg("--docck-python").arg(builder.python()); |
2c00a5a8 | 1287 | |
83c7162d | 1288 | if builder.config.build.ends_with("apple-darwin") { |
dfeec247 | 1289 | // Force /usr/bin/python3 on macOS for LLDB tests because we're loading the |
2c00a5a8 XL |
1290 | // LLDB plugin's compiled module which only works with the system python |
1291 | // (namely not Homebrew-installed python) | |
dfeec247 | 1292 | cmd.arg("--lldb-python").arg("/usr/bin/python3"); |
2c00a5a8 | 1293 | } else { |
83c7162d | 1294 | cmd.arg("--lldb-python").arg(builder.python()); |
2c00a5a8 XL |
1295 | } |
1296 | ||
83c7162d | 1297 | if let Some(ref gdb) = builder.config.gdb { |
2c00a5a8 XL |
1298 | cmd.arg("--gdb").arg(gdb); |
1299 | } | |
0bf4aa26 XL |
1300 | |
1301 | let run = |cmd: &mut Command| { | |
1302 | cmd.output().map(|output| { | |
1303 | String::from_utf8_lossy(&output.stdout) | |
dfeec247 XL |
1304 | .lines() |
1305 | .next() | |
1306 | .unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output)) | |
1307 | .to_string() | |
0bf4aa26 XL |
1308 | }) |
1309 | }; | |
f9f354fc XL |
1310 | let lldb_exe = "lldb"; |
1311 | let lldb_version = Command::new(lldb_exe) | |
0bf4aa26 XL |
1312 | .arg("--version") |
1313 | .output() | |
dfeec247 | 1314 | .map(|output| String::from_utf8_lossy(&output.stdout).to_string()) |
0bf4aa26 XL |
1315 | .ok(); |
1316 | if let Some(ref vers) = lldb_version { | |
2c00a5a8 | 1317 | cmd.arg("--lldb-version").arg(vers); |
f9f354fc | 1318 | let lldb_python_dir = run(Command::new(lldb_exe).arg("-P")).ok(); |
0bf4aa26 XL |
1319 | if let Some(ref dir) = lldb_python_dir { |
1320 | cmd.arg("--lldb-python-dir").arg(dir); | |
1321 | } | |
2c00a5a8 XL |
1322 | } |
1323 | ||
dc9dc135 XL |
1324 | if util::forcing_clang_based_tests() { |
1325 | let clang_exe = builder.llvm_out(target).join("bin").join("clang"); | |
1326 | cmd.arg("--run-clang-based-tests-with").arg(clang_exe); | |
9fa01778 XL |
1327 | } |
1328 | ||
94b46f34 XL |
1329 | // Get paths from cmd args |
1330 | let paths = match &builder.config.cmd { | |
1331 | Subcommand::Test { ref paths, .. } => &paths[..], | |
1332 | _ => &[], | |
1333 | }; | |
1334 | ||
1335 | // Get test-args by striping suite path | |
1336 | let mut test_args: Vec<&str> = paths | |
1337 | .iter() | |
dfeec247 XL |
1338 | .map(|p| match p.strip_prefix(".") { |
1339 | Ok(path) => path, | |
1340 | Err(_) => p, | |
8faf50e0 | 1341 | }) |
5869c6ff XL |
1342 | .filter(|p| p.starts_with(suite_path)) |
1343 | .filter(|p| { | |
1344 | let exists = p.is_dir() || p.is_file(); | |
1345 | if !exists { | |
1346 | if let Some(p) = p.to_str() { | |
1347 | builder.info(&format!( | |
1348 | "Warning: Skipping \"{}\": not a regular file or directory", | |
1349 | p | |
1350 | )); | |
1351 | } | |
1352 | } | |
1353 | exists | |
1354 | }) | |
48663c56 XL |
1355 | .filter_map(|p| { |
1356 | // Since test suite paths are themselves directories, if we don't | |
1357 | // specify a directory or file, we'll get an empty string here | |
1358 | // (the result of the test suite directory without its suite prefix). | |
1359 | // Therefore, we need to filter these out, as only the first --test-args | |
1360 | // flag is respected, so providing an empty --test-args conflicts with | |
1361 | // any following it. | |
1362 | match p.strip_prefix(suite_path).ok().and_then(|p| p.to_str()) { | |
5869c6ff | 1363 | Some(s) if !s.is_empty() => Some(s), |
48663c56 XL |
1364 | _ => None, |
1365 | } | |
1366 | }) | |
94b46f34 XL |
1367 | .collect(); |
1368 | ||
1369 | test_args.append(&mut builder.config.cmd.test_args()); | |
1370 | ||
1371 | cmd.args(&test_args); | |
2c00a5a8 | 1372 | |
83c7162d | 1373 | if builder.is_verbose() { |
2c00a5a8 XL |
1374 | cmd.arg("--verbose"); |
1375 | } | |
1376 | ||
94b46f34 | 1377 | if !builder.config.verbose_tests { |
2c00a5a8 XL |
1378 | cmd.arg("--quiet"); |
1379 | } | |
1380 | ||
3dfed10e XL |
1381 | let mut llvm_components_passed = false; |
1382 | let mut copts_passed = false; | |
532ac7d7 | 1383 | if builder.config.llvm_enabled() { |
dfeec247 | 1384 | let llvm_config = builder.ensure(native::Llvm { target: builder.config.build }); |
83c7162d XL |
1385 | if !builder.config.dry_run { |
1386 | let llvm_version = output(Command::new(&llvm_config).arg("--version")); | |
3dfed10e | 1387 | let llvm_components = output(Command::new(&llvm_config).arg("--components")); |
ba9703b0 | 1388 | // Remove trailing newline from llvm-config output. |
3dfed10e XL |
1389 | cmd.arg("--llvm-version") |
1390 | .arg(llvm_version.trim()) | |
1391 | .arg("--llvm-components") | |
1392 | .arg(llvm_components.trim()); | |
1393 | llvm_components_passed = true; | |
83c7162d XL |
1394 | } |
1395 | if !builder.is_rust_llvm(target) { | |
2c00a5a8 XL |
1396 | cmd.arg("--system-llvm"); |
1397 | } | |
1398 | ||
ba9703b0 XL |
1399 | // Tests that use compiler libraries may inherit the `-lLLVM` link |
1400 | // requirement, but the `-L` library path is not propagated across | |
1401 | // separate compilations. We can add LLVM's library path to the | |
1402 | // platform-specific environment variable as a workaround. | |
1403 | if !builder.config.dry_run && suite.ends_with("fulldeps") { | |
1404 | let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir")); | |
1405 | add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd); | |
1406 | } | |
1407 | ||
2c00a5a8 XL |
1408 | // Only pass correct values for these flags for the `run-make` suite as it |
1409 | // requires that a C++ compiler was configured which isn't always the case. | |
29967ef6 | 1410 | if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") { |
48663c56 XL |
1411 | // The llvm/bin directory contains many useful cross-platform |
1412 | // tools. Pass the path to run-make tests so they can use them. | |
dfeec247 XL |
1413 | let llvm_bin_path = llvm_config |
1414 | .parent() | |
48663c56 XL |
1415 | .expect("Expected llvm-config to be contained in directory"); |
1416 | assert!(llvm_bin_path.is_dir()); | |
1417 | cmd.arg("--llvm-bin-dir").arg(llvm_bin_path); | |
1418 | ||
1419 | // If LLD is available, add it to the PATH | |
1420 | if builder.config.lld_enabled { | |
dfeec247 XL |
1421 | let lld_install_root = |
1422 | builder.ensure(native::Lld { target: builder.config.build }); | |
48663c56 XL |
1423 | |
1424 | let lld_bin_path = lld_install_root.join("bin"); | |
1425 | ||
1426 | let old_path = env::var_os("PATH").unwrap_or_default(); | |
dfeec247 XL |
1427 | let new_path = env::join_paths( |
1428 | std::iter::once(lld_bin_path).chain(env::split_paths(&old_path)), | |
1429 | ) | |
1430 | .expect("Could not add LLD bin path to PATH"); | |
48663c56 XL |
1431 | cmd.env("PATH", new_path); |
1432 | } | |
2c00a5a8 XL |
1433 | } |
1434 | } | |
2c00a5a8 | 1435 | |
29967ef6 XL |
1436 | // Only pass correct values for these flags for the `run-make` suite as it |
1437 | // requires that a C++ compiler was configured which isn't always the case. | |
1438 | if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") { | |
1439 | cmd.arg("--cc") | |
1440 | .arg(builder.cc(target)) | |
1441 | .arg("--cxx") | |
1442 | .arg(builder.cxx(target).unwrap()) | |
1443 | .arg("--cflags") | |
1444 | .arg(builder.cflags(target, GitRepo::Rustc).join(" ")); | |
1445 | copts_passed = true; | |
1446 | if let Some(ar) = builder.ar(target) { | |
1447 | cmd.arg("--ar").arg(ar); | |
1448 | } | |
1449 | } | |
1450 | ||
3dfed10e XL |
1451 | if !llvm_components_passed { |
1452 | cmd.arg("--llvm-components").arg(""); | |
1453 | } | |
1454 | if !copts_passed { | |
1455 | cmd.arg("--cc").arg("").arg("--cxx").arg("").arg("--cflags").arg(""); | |
2c00a5a8 XL |
1456 | } |
1457 | ||
83c7162d | 1458 | if builder.remote_tested(target) { |
dfeec247 | 1459 | cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient)); |
2c00a5a8 XL |
1460 | } |
1461 | ||
1462 | // Running a C compiler on MSVC requires a few env vars to be set, to be | |
1463 | // sure to set them here. | |
1464 | // | |
1465 | // Note that if we encounter `PATH` we make sure to append to our own `PATH` | |
1466 | // rather than stomp over it. | |
1467 | if target.contains("msvc") { | |
83c7162d | 1468 | for &(ref k, ref v) in builder.cc[&target].env() { |
2c00a5a8 XL |
1469 | if k != "PATH" { |
1470 | cmd.env(k, v); | |
1471 | } | |
1472 | } | |
1473 | } | |
1474 | cmd.env("RUSTC_BOOTSTRAP", "1"); | |
17df50a5 | 1475 | cmd.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel()); |
83c7162d | 1476 | builder.add_rust_test_threads(&mut cmd); |
2c00a5a8 | 1477 | |
29967ef6 | 1478 | if builder.config.sanitizers_enabled(target) { |
48663c56 | 1479 | cmd.env("RUSTC_SANITIZER_SUPPORT", "1"); |
2c00a5a8 XL |
1480 | } |
1481 | ||
29967ef6 | 1482 | if builder.config.profiler_enabled(target) { |
48663c56 | 1483 | cmd.env("RUSTC_PROFILER_SUPPORT", "1"); |
2c00a5a8 XL |
1484 | } |
1485 | ||
e1599b0c XL |
1486 | let tmp = builder.out.join("tmp"); |
1487 | std::fs::create_dir_all(&tmp).unwrap(); | |
1488 | cmd.env("RUST_TEST_TMPDIR", tmp); | |
1489 | ||
2c00a5a8 XL |
1490 | cmd.arg("--adb-path").arg("adb"); |
1491 | cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR); | |
1492 | if target.contains("android") { | |
1493 | // Assume that cc for this target comes from the android sysroot | |
1494 | cmd.arg("--android-cross-path") | |
94b46f34 | 1495 | .arg(builder.cc(target).parent().unwrap().parent().unwrap()); |
2c00a5a8 XL |
1496 | } else { |
1497 | cmd.arg("--android-cross-path").arg(""); | |
1498 | } | |
1499 | ||
532ac7d7 XL |
1500 | if builder.config.cmd.rustfix_coverage() { |
1501 | cmd.arg("--rustfix-coverage"); | |
1502 | } | |
1503 | ||
1b1a35ee XL |
1504 | cmd.env("BOOTSTRAP_CARGO", &builder.initial_cargo); |
1505 | ||
17df50a5 XL |
1506 | cmd.arg("--channel").arg(&builder.config.channel); |
1507 | ||
83c7162d XL |
1508 | builder.ci_env.force_coloring_in_ci(&mut cmd); |
1509 | ||
94b46f34 XL |
1510 | builder.info(&format!( |
1511 | "Check compiletest suite={} mode={} ({} -> {})", | |
1512 | suite, mode, &compiler.host, target | |
1513 | )); | |
83c7162d XL |
1514 | let _time = util::timeit(&builder); |
1515 | try_run(builder, &mut cmd); | |
1516 | ||
1517 | if let Some(compare_mode) = compare_mode { | |
1518 | cmd.arg("--compare-mode").arg(compare_mode); | |
94b46f34 XL |
1519 | builder.info(&format!( |
1520 | "Check compiletest suite={} mode={} compare_mode={} ({} -> {})", | |
1521 | suite, mode, compare_mode, &compiler.host, target | |
1522 | )); | |
83c7162d XL |
1523 | let _time = util::timeit(&builder); |
1524 | try_run(builder, &mut cmd); | |
1525 | } | |
2c00a5a8 XL |
1526 | } |
1527 | } | |
1528 | ||
74b04a01 XL |
1529 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1530 | struct BookTest { | |
2c00a5a8 | 1531 | compiler: Compiler, |
74b04a01 | 1532 | path: PathBuf, |
0531ce1d XL |
1533 | name: &'static str, |
1534 | is_ext_doc: bool, | |
2c00a5a8 XL |
1535 | } |
1536 | ||
74b04a01 | 1537 | impl Step for BookTest { |
2c00a5a8 | 1538 | type Output = (); |
2c00a5a8 XL |
1539 | const ONLY_HOSTS: bool = true; |
1540 | ||
9fa01778 | 1541 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
0531ce1d | 1542 | run.never() |
2c00a5a8 XL |
1543 | } |
1544 | ||
74b04a01 | 1545 | /// Runs the documentation tests for a book in `src/doc`. |
2c00a5a8 | 1546 | /// |
74b04a01 | 1547 | /// This uses the `rustdoc` that sits next to `compiler`. |
9fa01778 | 1548 | fn run(self, builder: &Builder<'_>) { |
74b04a01 XL |
1549 | // External docs are different from local because: |
1550 | // - Some books need pre-processing by mdbook before being tested. | |
1551 | // - They need to save their state to toolstate. | |
1552 | // - They are only tested on the "checktools" builders. | |
1553 | // | |
1554 | // The local docs are tested by default, and we don't want to pay the | |
1555 | // cost of building mdbook, so they use `rustdoc --test` directly. | |
1556 | // Also, the unstable book is special because SUMMARY.md is generated, | |
1557 | // so it is easier to just run `rustdoc` on its files. | |
1558 | if self.is_ext_doc { | |
1559 | self.run_ext_doc(builder); | |
1560 | } else { | |
1561 | self.run_local_doc(builder); | |
1562 | } | |
1563 | } | |
1564 | } | |
1565 | ||
1566 | impl BookTest { | |
1567 | /// This runs the equivalent of `mdbook test` (via the rustbook wrapper) | |
1568 | /// which in turn runs `rustdoc --test` on each file in the book. | |
1569 | fn run_ext_doc(self, builder: &Builder<'_>) { | |
1570 | let compiler = self.compiler; | |
1571 | ||
1572 | builder.ensure(compile::Std { compiler, target: compiler.host }); | |
1573 | ||
1574 | // mdbook just executes a binary named "rustdoc", so we need to update | |
1575 | // PATH so that it points to our rustdoc. | |
1576 | let mut rustdoc_path = builder.rustdoc(compiler); | |
1577 | rustdoc_path.pop(); | |
1578 | let old_path = env::var_os("PATH").unwrap_or_default(); | |
1579 | let new_path = env::join_paths(iter::once(rustdoc_path).chain(env::split_paths(&old_path))) | |
1580 | .expect("could not add rustdoc to PATH"); | |
1581 | ||
1582 | let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook); | |
1583 | let path = builder.src.join(&self.path); | |
1584 | rustbook_cmd.env("PATH", new_path).arg("test").arg(path); | |
1585 | builder.add_rust_test_threads(&mut rustbook_cmd); | |
1586 | builder.info(&format!("Testing rustbook {}", self.path.display())); | |
1587 | let _time = util::timeit(&builder); | |
1588 | let toolstate = if try_run(builder, &mut rustbook_cmd) { | |
1589 | ToolState::TestPass | |
1590 | } else { | |
1591 | ToolState::TestFail | |
1592 | }; | |
1593 | builder.save_toolstate(self.name, toolstate); | |
1594 | } | |
1595 | ||
1596 | /// This runs `rustdoc --test` on all `.md` files in the path. | |
1597 | fn run_local_doc(self, builder: &Builder<'_>) { | |
2c00a5a8 XL |
1598 | let compiler = self.compiler; |
1599 | ||
dfeec247 | 1600 | builder.ensure(compile::Std { compiler, target: compiler.host }); |
2c00a5a8 XL |
1601 | |
1602 | // Do a breadth-first traversal of the `src/doc` directory and just run | |
1603 | // tests for all files that end in `*.md` | |
83c7162d XL |
1604 | let mut stack = vec![builder.src.join(self.path)]; |
1605 | let _time = util::timeit(&builder); | |
83c7162d | 1606 | let mut files = Vec::new(); |
2c00a5a8 XL |
1607 | while let Some(p) = stack.pop() { |
1608 | if p.is_dir() { | |
1609 | stack.extend(t!(p.read_dir()).map(|p| t!(p).path())); | |
94b46f34 | 1610 | continue; |
2c00a5a8 XL |
1611 | } |
1612 | ||
1613 | if p.extension().and_then(|s| s.to_str()) != Some("md") { | |
1614 | continue; | |
1615 | } | |
1616 | ||
83c7162d XL |
1617 | files.push(p); |
1618 | } | |
1619 | ||
1620 | files.sort(); | |
1621 | ||
1622 | for file in files { | |
74b04a01 | 1623 | markdown_test(builder, compiler, &file); |
8faf50e0 | 1624 | } |
2c00a5a8 XL |
1625 | } |
1626 | } | |
1627 | ||
0531ce1d XL |
1628 | macro_rules! test_book { |
1629 | ($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => { | |
1630 | $( | |
1631 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
1632 | pub struct $name { | |
1633 | compiler: Compiler, | |
1634 | } | |
1635 | ||
1636 | impl Step for $name { | |
1637 | type Output = (); | |
1638 | const DEFAULT: bool = $default; | |
1639 | const ONLY_HOSTS: bool = true; | |
1640 | ||
9fa01778 | 1641 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
0531ce1d XL |
1642 | run.path($path) |
1643 | } | |
1644 | ||
9fa01778 | 1645 | fn make_run(run: RunConfig<'_>) { |
0531ce1d | 1646 | run.builder.ensure($name { |
1b1a35ee | 1647 | compiler: run.builder.compiler(run.builder.top_stage, run.target), |
0531ce1d XL |
1648 | }); |
1649 | } | |
1650 | ||
9fa01778 | 1651 | fn run(self, builder: &Builder<'_>) { |
74b04a01 | 1652 | builder.ensure(BookTest { |
0531ce1d | 1653 | compiler: self.compiler, |
74b04a01 | 1654 | path: PathBuf::from($path), |
0531ce1d XL |
1655 | name: $book_name, |
1656 | is_ext_doc: !$default, | |
1657 | }); | |
1658 | } | |
1659 | } | |
1660 | )+ | |
1661 | } | |
1662 | } | |
1663 | ||
1664 | test_book!( | |
1665 | Nomicon, "src/doc/nomicon", "nomicon", default=false; | |
1666 | Reference, "src/doc/reference", "reference", default=false; | |
1667 | RustdocBook, "src/doc/rustdoc", "rustdoc", default=true; | |
83c7162d | 1668 | RustcBook, "src/doc/rustc", "rustc", default=true; |
0531ce1d | 1669 | RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false; |
9fa01778 | 1670 | EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false; |
0531ce1d XL |
1671 | TheBook, "src/doc/book", "book", default=false; |
1672 | UnstableBook, "src/doc/unstable-book", "unstable-book", default=true; | |
532ac7d7 | 1673 | EditionGuide, "src/doc/edition-guide", "edition-guide", default=false; |
0531ce1d XL |
1674 | ); |
1675 | ||
2c00a5a8 XL |
1676 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
1677 | pub struct ErrorIndex { | |
1678 | compiler: Compiler, | |
1679 | } | |
1680 | ||
1681 | impl Step for ErrorIndex { | |
1682 | type Output = (); | |
1683 | const DEFAULT: bool = true; | |
1684 | const ONLY_HOSTS: bool = true; | |
1685 | ||
9fa01778 | 1686 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
1687 | run.path("src/tools/error_index_generator") |
1688 | } | |
1689 | ||
9fa01778 | 1690 | fn make_run(run: RunConfig<'_>) { |
f035d41b XL |
1691 | // error_index_generator depends on librustdoc. Use the compiler that |
1692 | // is normally used to build rustdoc for other tests (like compiletest | |
1693 | // tests in src/test/rustdoc) so that it shares the same artifacts. | |
5869c6ff | 1694 | let compiler = run.builder.compiler(run.builder.top_stage, run.builder.config.build); |
f035d41b | 1695 | run.builder.ensure(ErrorIndex { compiler }); |
2c00a5a8 XL |
1696 | } |
1697 | ||
9fa01778 | 1698 | /// Runs the error index generator tool to execute the tests located in the error |
2c00a5a8 XL |
1699 | /// index. |
1700 | /// | |
1701 | /// The `error_index_generator` tool lives in `src/tools` and is used to | |
1702 | /// generate a markdown file from the error indexes of the code base which is | |
1703 | /// then passed to `rustdoc --test`. | |
9fa01778 | 1704 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
1705 | let compiler = self.compiler; |
1706 | ||
83c7162d | 1707 | let dir = testdir(builder, compiler.host); |
2c00a5a8 XL |
1708 | t!(fs::create_dir_all(&dir)); |
1709 | let output = dir.join("error-index.md"); | |
1710 | ||
5869c6ff | 1711 | let mut tool = tool::ErrorIndex::command(builder); |
f035d41b | 1712 | tool.arg("markdown").arg(&output); |
0531ce1d | 1713 | |
5869c6ff | 1714 | builder.info(&format!("Testing error-index stage{}", compiler.stage)); |
83c7162d | 1715 | let _time = util::timeit(&builder); |
416331ca | 1716 | builder.run_quiet(&mut tool); |
5869c6ff XL |
1717 | // The tests themselves need to link to std, so make sure it is |
1718 | // available. | |
1719 | builder.ensure(compile::Std { compiler, target: compiler.host }); | |
1720 | markdown_test(builder, compiler, &output); | |
2c00a5a8 XL |
1721 | } |
1722 | } | |
1723 | ||
9fa01778 | 1724 | fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool { |
74b04a01 XL |
1725 | if let Ok(contents) = fs::read_to_string(markdown) { |
1726 | if !contents.contains("```") { | |
1727 | return true; | |
83c7162d | 1728 | } |
2c00a5a8 XL |
1729 | } |
1730 | ||
83c7162d | 1731 | builder.info(&format!("doc tests for: {}", markdown.display())); |
532ac7d7 | 1732 | let mut cmd = builder.rustdoc_cmd(compiler); |
83c7162d | 1733 | builder.add_rust_test_threads(&mut cmd); |
17df50a5 XL |
1734 | // allow for unstable options such as new editions |
1735 | cmd.arg("-Z"); | |
1736 | cmd.arg("unstable-options"); | |
2c00a5a8 XL |
1737 | cmd.arg("--test"); |
1738 | cmd.arg(markdown); | |
1739 | cmd.env("RUSTC_BOOTSTRAP", "1"); | |
1740 | ||
83c7162d | 1741 | let test_args = builder.config.cmd.test_args().join(" "); |
2c00a5a8 XL |
1742 | cmd.arg("--test-args").arg(test_args); |
1743 | ||
94b46f34 | 1744 | if builder.config.verbose_tests { |
83c7162d | 1745 | try_run(builder, &mut cmd) |
94b46f34 XL |
1746 | } else { |
1747 | try_run_quiet(builder, &mut cmd) | |
2c00a5a8 XL |
1748 | } |
1749 | } | |
1750 | ||
416331ca XL |
1751 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
1752 | pub struct RustcGuide; | |
1753 | ||
1754 | impl Step for RustcGuide { | |
1755 | type Output = (); | |
1756 | const DEFAULT: bool = false; | |
1757 | const ONLY_HOSTS: bool = true; | |
1758 | ||
1759 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
74b04a01 | 1760 | run.path("src/doc/rustc-dev-guide") |
416331ca XL |
1761 | } |
1762 | ||
1763 | fn make_run(run: RunConfig<'_>) { | |
1764 | run.builder.ensure(RustcGuide); | |
1765 | } | |
1766 | ||
1767 | fn run(self, builder: &Builder<'_>) { | |
74b04a01 | 1768 | let src = builder.src.join("src/doc/rustc-dev-guide"); |
416331ca XL |
1769 | let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook); |
1770 | let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) { | |
1771 | ToolState::TestPass | |
1772 | } else { | |
1773 | ToolState::TestFail | |
1774 | }; | |
74b04a01 | 1775 | builder.save_toolstate("rustc-dev-guide", toolstate); |
416331ca XL |
1776 | } |
1777 | } | |
1778 | ||
2c00a5a8 XL |
1779 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
1780 | pub struct CrateLibrustc { | |
1781 | compiler: Compiler, | |
3dfed10e | 1782 | target: TargetSelection, |
2c00a5a8 XL |
1783 | test_kind: TestKind, |
1784 | krate: Interned<String>, | |
1785 | } | |
1786 | ||
1787 | impl Step for CrateLibrustc { | |
1788 | type Output = (); | |
1789 | const DEFAULT: bool = true; | |
1790 | const ONLY_HOSTS: bool = true; | |
1791 | ||
9fa01778 | 1792 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
1793 | run.krate("rustc-main") |
1794 | } | |
1795 | ||
9fa01778 | 1796 | fn make_run(run: RunConfig<'_>) { |
2c00a5a8 | 1797 | let builder = run.builder; |
1b1a35ee | 1798 | let compiler = builder.compiler(builder.top_stage, run.build_triple()); |
2c00a5a8 | 1799 | |
29967ef6 | 1800 | for krate in builder.in_tree_crates("rustc-main", Some(run.target)) { |
f035d41b | 1801 | if krate.path.ends_with(&run.path) { |
94b46f34 | 1802 | let test_kind = builder.kind.into(); |
2c00a5a8 XL |
1803 | |
1804 | builder.ensure(CrateLibrustc { | |
1805 | compiler, | |
1806 | target: run.target, | |
1807 | test_kind, | |
1808 | krate: krate.name, | |
1809 | }); | |
1810 | } | |
1811 | } | |
1812 | } | |
1813 | ||
9fa01778 | 1814 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
1815 | builder.ensure(Crate { |
1816 | compiler: self.compiler, | |
1817 | target: self.target, | |
94b46f34 | 1818 | mode: Mode::Rustc, |
2c00a5a8 XL |
1819 | test_kind: self.test_kind, |
1820 | krate: self.krate, | |
1821 | }); | |
1822 | } | |
1823 | } | |
1824 | ||
83c7162d | 1825 | #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] |
2c00a5a8 | 1826 | pub struct Crate { |
83c7162d | 1827 | pub compiler: Compiler, |
3dfed10e | 1828 | pub target: TargetSelection, |
83c7162d XL |
1829 | pub mode: Mode, |
1830 | pub test_kind: TestKind, | |
1831 | pub krate: Interned<String>, | |
2c00a5a8 XL |
1832 | } |
1833 | ||
1834 | impl Step for Crate { | |
1835 | type Output = (); | |
1836 | const DEFAULT: bool = true; | |
1837 | ||
f035d41b XL |
1838 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
1839 | run.krate("test") | |
2c00a5a8 XL |
1840 | } |
1841 | ||
9fa01778 | 1842 | fn make_run(run: RunConfig<'_>) { |
2c00a5a8 | 1843 | let builder = run.builder; |
1b1a35ee | 1844 | let compiler = builder.compiler(builder.top_stage, run.build_triple()); |
2c00a5a8 XL |
1845 | |
1846 | let make = |mode: Mode, krate: &CargoCrate| { | |
94b46f34 | 1847 | let test_kind = builder.kind.into(); |
2c00a5a8 XL |
1848 | |
1849 | builder.ensure(Crate { | |
1850 | compiler, | |
1851 | target: run.target, | |
1852 | mode, | |
1853 | test_kind, | |
1854 | krate: krate.name, | |
1855 | }); | |
1856 | }; | |
1857 | ||
29967ef6 | 1858 | for krate in builder.in_tree_crates("test", Some(run.target)) { |
f035d41b | 1859 | if krate.path.ends_with(&run.path) { |
e1599b0c | 1860 | make(Mode::Std, krate); |
2c00a5a8 XL |
1861 | } |
1862 | } | |
1863 | } | |
1864 | ||
9fa01778 | 1865 | /// Runs all unit tests plus documentation tests for a given crate defined |
2c00a5a8 XL |
1866 | /// by a `Cargo.toml` (single manifest) |
1867 | /// | |
1868 | /// This is what runs tests for crates like the standard library, compiler, etc. | |
1869 | /// It essentially is the driver for running `cargo test`. | |
1870 | /// | |
1871 | /// Currently this runs all tests for a DAG by passing a bunch of `-p foo` | |
1872 | /// arguments, and those arguments are discovered from `cargo metadata`. | |
9fa01778 | 1873 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
1874 | let compiler = self.compiler; |
1875 | let target = self.target; | |
1876 | let mode = self.mode; | |
1877 | let test_kind = self.test_kind; | |
1878 | let krate = self.krate; | |
1879 | ||
e1599b0c | 1880 | builder.ensure(compile::Std { compiler, target }); |
2c00a5a8 XL |
1881 | builder.ensure(RemoteCopyLibs { compiler, target }); |
1882 | ||
dc9dc135 XL |
1883 | // If we're not doing a full bootstrap but we're testing a stage2 |
1884 | // version of libstd, then what we're actually testing is the libstd | |
1885 | // produced in stage1. Reflect that here by updating the compiler that | |
1886 | // we're working with automatically. | |
1887 | let compiler = builder.compiler_for(compiler.stage, compiler.host, target); | |
2c00a5a8 | 1888 | |
f035d41b XL |
1889 | let mut cargo = |
1890 | builder.cargo(compiler, mode, SourceType::InTree, target, test_kind.subcommand()); | |
2c00a5a8 | 1891 | match mode { |
94b46f34 | 1892 | Mode::Std => { |
f9f354fc | 1893 | compile::std_cargo(builder, target, compiler.stage, &mut cargo); |
2c00a5a8 | 1894 | } |
94b46f34 | 1895 | Mode::Rustc => { |
2c00a5a8 | 1896 | builder.ensure(compile::Rustc { compiler, target }); |
60c5eb7d | 1897 | compile::rustc_cargo(builder, &mut cargo, target); |
2c00a5a8 XL |
1898 | } |
1899 | _ => panic!("can only test libraries"), | |
1900 | }; | |
2c00a5a8 XL |
1901 | |
1902 | // Build up the base `cargo test` command. | |
1903 | // | |
1904 | // Pass in some standard flags then iterate over the graph we've discovered | |
1905 | // in `cargo metadata` with the maps above and figure out what `-p` | |
1906 | // arguments need to get passed. | |
83c7162d | 1907 | if test_kind.subcommand() == "test" && !builder.fail_fast { |
2c00a5a8 XL |
1908 | cargo.arg("--no-fail-fast"); |
1909 | } | |
83c7162d XL |
1910 | match builder.doc_tests { |
1911 | DocTests::Only => { | |
1912 | cargo.arg("--doc"); | |
1913 | } | |
1914 | DocTests::No => { | |
1915 | cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]); | |
1916 | } | |
1917 | DocTests::Yes => {} | |
0531ce1d | 1918 | } |
2c00a5a8 XL |
1919 | |
1920 | cargo.arg("-p").arg(krate); | |
1921 | ||
1922 | // The tests are going to run with the *target* libraries, so we need to | |
1923 | // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent. | |
1924 | // | |
1925 | // Note that to run the compiler we need to run with the *host* libraries, | |
1926 | // but our wrapper scripts arrange for that to be the case anyway. | |
1927 | let mut dylib_path = dylib_path(); | |
1928 | dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target))); | |
1929 | cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); | |
1930 | ||
1931 | cargo.arg("--"); | |
83c7162d | 1932 | cargo.args(&builder.config.cmd.test_args()); |
2c00a5a8 | 1933 | |
94b46f34 | 1934 | if !builder.config.verbose_tests { |
2c00a5a8 XL |
1935 | cargo.arg("--quiet"); |
1936 | } | |
1937 | ||
2c00a5a8 | 1938 | if target.contains("emscripten") { |
94b46f34 | 1939 | cargo.env( |
3dfed10e | 1940 | format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), |
dfeec247 | 1941 | builder.config.nodejs.as_ref().expect("nodejs not configured"), |
94b46f34 | 1942 | ); |
2c00a5a8 | 1943 | } else if target.starts_with("wasm32") { |
dfeec247 XL |
1944 | let node = builder.config.nodejs.as_ref().expect("nodejs not configured"); |
1945 | let runner = | |
1946 | format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display()); | |
3dfed10e | 1947 | cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner); |
83c7162d | 1948 | } else if builder.remote_tested(target) { |
94b46f34 | 1949 | cargo.env( |
3dfed10e | 1950 | format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), |
f9f354fc | 1951 | format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()), |
94b46f34 | 1952 | ); |
2c00a5a8 | 1953 | } |
0531ce1d | 1954 | |
94b46f34 XL |
1955 | builder.info(&format!( |
1956 | "{} {} stage{} ({} -> {})", | |
1957 | test_kind, krate, compiler.stage, &compiler.host, target | |
1958 | )); | |
83c7162d | 1959 | let _time = util::timeit(&builder); |
e1599b0c | 1960 | try_run(builder, &mut cargo.into()); |
2c00a5a8 XL |
1961 | } |
1962 | } | |
1963 | ||
1964 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
1965 | pub struct CrateRustdoc { | |
3dfed10e | 1966 | host: TargetSelection, |
2c00a5a8 XL |
1967 | test_kind: TestKind, |
1968 | } | |
1969 | ||
1970 | impl Step for CrateRustdoc { | |
1971 | type Output = (); | |
1972 | const DEFAULT: bool = true; | |
1973 | const ONLY_HOSTS: bool = true; | |
1974 | ||
9fa01778 | 1975 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
1976 | run.paths(&["src/librustdoc", "src/tools/rustdoc"]) |
1977 | } | |
1978 | ||
9fa01778 | 1979 | fn make_run(run: RunConfig<'_>) { |
2c00a5a8 XL |
1980 | let builder = run.builder; |
1981 | ||
94b46f34 | 1982 | let test_kind = builder.kind.into(); |
2c00a5a8 | 1983 | |
1b1a35ee | 1984 | builder.ensure(CrateRustdoc { host: run.target, test_kind }); |
2c00a5a8 XL |
1985 | } |
1986 | ||
9fa01778 | 1987 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 | 1988 | let test_kind = self.test_kind; |
f035d41b | 1989 | let target = self.host; |
2c00a5a8 | 1990 | |
f035d41b XL |
1991 | // Use the previous stage compiler to reuse the artifacts that are |
1992 | // created when running compiletest for src/test/rustdoc. If this used | |
1993 | // `compiler`, then it would cause rustdoc to be built *again*, which | |
1994 | // isn't really necessary. | |
1995 | let compiler = builder.compiler_for(builder.top_stage, target, target); | |
8faf50e0 | 1996 | builder.ensure(compile::Rustc { compiler, target }); |
2c00a5a8 | 1997 | |
dfeec247 XL |
1998 | let mut cargo = tool::prepare_tool_cargo( |
1999 | builder, | |
2000 | compiler, | |
2001 | Mode::ToolRustc, | |
2002 | target, | |
2003 | test_kind.subcommand(), | |
2004 | "src/tools/rustdoc", | |
2005 | SourceType::InTree, | |
2006 | &[], | |
2007 | ); | |
83c7162d | 2008 | if test_kind.subcommand() == "test" && !builder.fail_fast { |
2c00a5a8 XL |
2009 | cargo.arg("--no-fail-fast"); |
2010 | } | |
2011 | ||
2012 | cargo.arg("-p").arg("rustdoc:0.0.0"); | |
2013 | ||
2014 | cargo.arg("--"); | |
83c7162d | 2015 | cargo.args(&builder.config.cmd.test_args()); |
2c00a5a8 | 2016 | |
48663c56 XL |
2017 | if self.host.contains("musl") { |
2018 | cargo.arg("'-Ctarget-feature=-crt-static'"); | |
2019 | } | |
2020 | ||
f035d41b XL |
2021 | // This is needed for running doctests on librustdoc. This is a bit of |
2022 | // an unfortunate interaction with how bootstrap works and how cargo | |
2023 | // sets up the dylib path, and the fact that the doctest (in | |
2024 | // html/markdown.rs) links to rustc-private libs. For stage1, the | |
2025 | // compiler host dylibs (in stage1/lib) are not the same as the target | |
2026 | // dylibs (in stage1/lib/rustlib/...). This is different from a normal | |
2027 | // rust distribution where they are the same. | |
2028 | // | |
2029 | // On the cargo side, normal tests use `target_process` which handles | |
2030 | // setting up the dylib for a *target* (stage1/lib/rustlib/... in this | |
2031 | // case). However, for doctests it uses `rustdoc_process` which only | |
2032 | // sets up the dylib path for the *host* (stage1/lib), which is the | |
2033 | // wrong directory. | |
2034 | // | |
2035 | // It should be considered to just stop running doctests on | |
2036 | // librustdoc. There is only one test, and it doesn't look too | |
2037 | // important. There might be other ways to avoid this, but it seems | |
2038 | // pretty convoluted. | |
2039 | // | |
2040 | // See also https://github.com/rust-lang/rust/issues/13983 where the | |
2041 | // host vs target dylibs for rustdoc are consistently tricky to deal | |
2042 | // with. | |
2043 | let mut dylib_path = dylib_path(); | |
2044 | dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target))); | |
2045 | cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); | |
2046 | ||
94b46f34 | 2047 | if !builder.config.verbose_tests { |
2c00a5a8 XL |
2048 | cargo.arg("--quiet"); |
2049 | } | |
2050 | ||
94b46f34 XL |
2051 | builder.info(&format!( |
2052 | "{} rustdoc stage{} ({} -> {})", | |
2053 | test_kind, compiler.stage, &compiler.host, target | |
2054 | )); | |
83c7162d | 2055 | let _time = util::timeit(&builder); |
6a06907d XL |
2056 | |
2057 | try_run(builder, &mut cargo.into()); | |
2058 | } | |
2059 | } | |
2060 | ||
2061 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
2062 | pub struct CrateRustdocJsonTypes { | |
2063 | host: TargetSelection, | |
2064 | test_kind: TestKind, | |
2065 | } | |
2066 | ||
2067 | impl Step for CrateRustdocJsonTypes { | |
2068 | type Output = (); | |
2069 | const DEFAULT: bool = true; | |
2070 | const ONLY_HOSTS: bool = true; | |
2071 | ||
2072 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
2073 | run.path("src/rustdoc-json-types") | |
2074 | } | |
2075 | ||
2076 | fn make_run(run: RunConfig<'_>) { | |
2077 | let builder = run.builder; | |
2078 | ||
2079 | let test_kind = builder.kind.into(); | |
2080 | ||
2081 | builder.ensure(CrateRustdocJsonTypes { host: run.target, test_kind }); | |
2082 | } | |
2083 | ||
2084 | fn run(self, builder: &Builder<'_>) { | |
2085 | let test_kind = self.test_kind; | |
2086 | let target = self.host; | |
2087 | ||
2088 | // Use the previous stage compiler to reuse the artifacts that are | |
2089 | // created when running compiletest for src/test/rustdoc. If this used | |
2090 | // `compiler`, then it would cause rustdoc to be built *again*, which | |
2091 | // isn't really necessary. | |
2092 | let compiler = builder.compiler_for(builder.top_stage, target, target); | |
2093 | builder.ensure(compile::Rustc { compiler, target }); | |
2094 | ||
2095 | let mut cargo = tool::prepare_tool_cargo( | |
2096 | builder, | |
2097 | compiler, | |
2098 | Mode::ToolRustc, | |
2099 | target, | |
2100 | test_kind.subcommand(), | |
2101 | "src/rustdoc-json-types", | |
2102 | SourceType::InTree, | |
2103 | &[], | |
2104 | ); | |
2105 | if test_kind.subcommand() == "test" && !builder.fail_fast { | |
2106 | cargo.arg("--no-fail-fast"); | |
2107 | } | |
2108 | ||
2109 | cargo.arg("-p").arg("rustdoc-json-types"); | |
2110 | ||
2111 | cargo.arg("--"); | |
2112 | cargo.args(&builder.config.cmd.test_args()); | |
2113 | ||
2114 | if self.host.contains("musl") { | |
2115 | cargo.arg("'-Ctarget-feature=-crt-static'"); | |
2116 | } | |
2117 | ||
2118 | if !builder.config.verbose_tests { | |
2119 | cargo.arg("--quiet"); | |
2120 | } | |
2121 | ||
2122 | builder.info(&format!( | |
2123 | "{} rustdoc-json-types stage{} ({} -> {})", | |
2124 | test_kind, compiler.stage, &compiler.host, target | |
2125 | )); | |
2126 | let _time = util::timeit(&builder); | |
2c00a5a8 | 2127 | |
e1599b0c | 2128 | try_run(builder, &mut cargo.into()); |
2c00a5a8 XL |
2129 | } |
2130 | } | |
2131 | ||
2c00a5a8 XL |
2132 | /// Some test suites are run inside emulators or on remote devices, and most |
2133 | /// of our test binaries are linked dynamically which means we need to ship | |
2134 | /// the standard library and such to the emulator ahead of time. This step | |
2135 | /// represents this and is a dependency of all test suites. | |
2136 | /// | |
9fa01778 | 2137 | /// Most of the time this is a no-op. For some steps such as shipping data to |
2c00a5a8 XL |
2138 | /// QEMU we have to build our own tools so we've got conditional dependencies |
2139 | /// on those programs as well. Note that the remote test client is built for | |
2140 | /// the build target (us) and the server is built for the target. | |
2141 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
2142 | pub struct RemoteCopyLibs { | |
2143 | compiler: Compiler, | |
3dfed10e | 2144 | target: TargetSelection, |
2c00a5a8 XL |
2145 | } |
2146 | ||
2147 | impl Step for RemoteCopyLibs { | |
2148 | type Output = (); | |
2149 | ||
9fa01778 | 2150 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
2151 | run.never() |
2152 | } | |
2153 | ||
9fa01778 | 2154 | fn run(self, builder: &Builder<'_>) { |
2c00a5a8 XL |
2155 | let compiler = self.compiler; |
2156 | let target = self.target; | |
83c7162d | 2157 | if !builder.remote_tested(target) { |
94b46f34 | 2158 | return; |
2c00a5a8 XL |
2159 | } |
2160 | ||
e1599b0c | 2161 | builder.ensure(compile::Std { compiler, target }); |
2c00a5a8 | 2162 | |
83c7162d XL |
2163 | builder.info(&format!("REMOTE copy libs to emulator ({})", target)); |
2164 | t!(fs::create_dir_all(builder.out.join("tmp"))); | |
2c00a5a8 | 2165 | |
5869c6ff | 2166 | let server = builder.ensure(tool::RemoteTestServer { compiler, target }); |
2c00a5a8 XL |
2167 | |
2168 | // Spawn the emulator and wait for it to come online | |
2169 | let tool = builder.tool_exe(Tool::RemoteTestClient); | |
2170 | let mut cmd = Command::new(&tool); | |
3dfed10e | 2171 | cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.out.join("tmp")); |
83c7162d | 2172 | if let Some(rootfs) = builder.qemu_rootfs(target) { |
2c00a5a8 XL |
2173 | cmd.arg(rootfs); |
2174 | } | |
83c7162d | 2175 | builder.run(&mut cmd); |
2c00a5a8 XL |
2176 | |
2177 | // Push all our dylibs to the emulator | |
2178 | for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) { | |
2179 | let f = t!(f); | |
2180 | let name = f.file_name().into_string().unwrap(); | |
2181 | if util::is_dylib(&name) { | |
94b46f34 | 2182 | builder.run(Command::new(&tool).arg("push").arg(f.path())); |
2c00a5a8 XL |
2183 | } |
2184 | } | |
2185 | } | |
2186 | } | |
2187 | ||
2188 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
2189 | pub struct Distcheck; | |
2190 | ||
2191 | impl Step for Distcheck { | |
2192 | type Output = (); | |
2c00a5a8 | 2193 | |
9fa01778 | 2194 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
2195 | run.path("distcheck") |
2196 | } | |
2197 | ||
9fa01778 | 2198 | fn make_run(run: RunConfig<'_>) { |
2c00a5a8 XL |
2199 | run.builder.ensure(Distcheck); |
2200 | } | |
2201 | ||
9fa01778 XL |
2202 | /// Runs "distcheck", a 'make check' from a tarball |
2203 | fn run(self, builder: &Builder<'_>) { | |
a1dfa0c6 | 2204 | builder.info("Distcheck"); |
83c7162d | 2205 | let dir = builder.out.join("tmp").join("distcheck"); |
2c00a5a8 XL |
2206 | let _ = fs::remove_dir_all(&dir); |
2207 | t!(fs::create_dir_all(&dir)); | |
2208 | ||
2209 | // Guarantee that these are built before we begin running. | |
2210 | builder.ensure(dist::PlainSourceTarball); | |
2211 | builder.ensure(dist::Src); | |
2212 | ||
2213 | let mut cmd = Command::new("tar"); | |
fc512014 XL |
2214 | cmd.arg("-xf") |
2215 | .arg(builder.ensure(dist::PlainSourceTarball).tarball()) | |
94b46f34 XL |
2216 | .arg("--strip-components=1") |
2217 | .current_dir(&dir); | |
83c7162d | 2218 | builder.run(&mut cmd); |
94b46f34 XL |
2219 | builder.run( |
2220 | Command::new("./configure") | |
2221 | .args(&builder.config.configure_args) | |
2222 | .arg("--enable-vendor") | |
2223 | .current_dir(&dir), | |
2224 | ); | |
2225 | builder.run( | |
3dfed10e XL |
2226 | Command::new(build_helper::make(&builder.config.build.triple)) |
2227 | .arg("check") | |
2228 | .current_dir(&dir), | |
94b46f34 | 2229 | ); |
2c00a5a8 XL |
2230 | |
2231 | // Now make sure that rust-src has all of libstd's dependencies | |
a1dfa0c6 | 2232 | builder.info("Distcheck rust-src"); |
83c7162d | 2233 | let dir = builder.out.join("tmp").join("distcheck-src"); |
2c00a5a8 XL |
2234 | let _ = fs::remove_dir_all(&dir); |
2235 | t!(fs::create_dir_all(&dir)); | |
2236 | ||
2237 | let mut cmd = Command::new("tar"); | |
fc512014 XL |
2238 | cmd.arg("-xf") |
2239 | .arg(builder.ensure(dist::Src).tarball()) | |
94b46f34 XL |
2240 | .arg("--strip-components=1") |
2241 | .current_dir(&dir); | |
83c7162d | 2242 | builder.run(&mut cmd); |
2c00a5a8 | 2243 | |
3dfed10e | 2244 | let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml"); |
94b46f34 XL |
2245 | builder.run( |
2246 | Command::new(&builder.initial_cargo) | |
2247 | .arg("generate-lockfile") | |
2248 | .arg("--manifest-path") | |
2249 | .arg(&toml) | |
2250 | .current_dir(&dir), | |
2251 | ); | |
2c00a5a8 XL |
2252 | } |
2253 | } | |
2254 | ||
2255 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
2256 | pub struct Bootstrap; | |
2257 | ||
2258 | impl Step for Bootstrap { | |
2259 | type Output = (); | |
2260 | const DEFAULT: bool = true; | |
2261 | const ONLY_HOSTS: bool = true; | |
2c00a5a8 | 2262 | |
9fa01778 XL |
2263 | /// Tests the build system itself. |
2264 | fn run(self, builder: &Builder<'_>) { | |
83c7162d | 2265 | let mut cmd = Command::new(&builder.initial_cargo); |
2c00a5a8 | 2266 | cmd.arg("test") |
94b46f34 XL |
2267 | .current_dir(builder.src.join("src/bootstrap")) |
2268 | .env("RUSTFLAGS", "-Cdebuginfo=2") | |
2269 | .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) | |
1b1a35ee XL |
2270 | .env("BOOTSTRAP_OUTPUT_DIRECTORY", &builder.config.out) |
2271 | .env("BOOTSTRAP_INITIAL_CARGO", &builder.config.initial_cargo) | |
94b46f34 XL |
2272 | .env("RUSTC_BOOTSTRAP", "1") |
2273 | .env("RUSTC", &builder.initial_rustc); | |
0531ce1d XL |
2274 | if let Some(flags) = option_env!("RUSTFLAGS") { |
2275 | // Use the same rustc flags for testing as for "normal" compilation, | |
2276 | // so that Cargo doesn’t recompile the entire dependency graph every time: | |
2277 | // https://github.com/rust-lang/rust/issues/49215 | |
2278 | cmd.env("RUSTFLAGS", flags); | |
2279 | } | |
83c7162d | 2280 | if !builder.fail_fast { |
2c00a5a8 XL |
2281 | cmd.arg("--no-fail-fast"); |
2282 | } | |
83c7162d | 2283 | cmd.arg("--").args(&builder.config.cmd.test_args()); |
94b46f34 XL |
2284 | // rustbuild tests are racy on directory creation so just run them one at a time. |
2285 | // Since there's not many this shouldn't be a problem. | |
2286 | cmd.arg("--test-threads=1"); | |
83c7162d | 2287 | try_run(builder, &mut cmd); |
2c00a5a8 XL |
2288 | } |
2289 | ||
9fa01778 | 2290 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
2c00a5a8 XL |
2291 | run.path("src/bootstrap") |
2292 | } | |
2293 | ||
9fa01778 | 2294 | fn make_run(run: RunConfig<'_>) { |
2c00a5a8 XL |
2295 | run.builder.ensure(Bootstrap); |
2296 | } | |
2297 | } | |
3dfed10e XL |
2298 | |
2299 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
2300 | pub struct TierCheck { | |
2301 | pub compiler: Compiler, | |
3dfed10e XL |
2302 | } |
2303 | ||
2304 | impl Step for TierCheck { | |
2305 | type Output = (); | |
2306 | const DEFAULT: bool = true; | |
2307 | const ONLY_HOSTS: bool = true; | |
2308 | ||
2309 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
2310 | run.path("src/tools/tier-check") | |
2311 | } | |
2312 | ||
2313 | fn make_run(run: RunConfig<'_>) { | |
1b1a35ee XL |
2314 | let compiler = |
2315 | run.builder.compiler_for(run.builder.top_stage, run.builder.build.build, run.target); | |
2316 | run.builder.ensure(TierCheck { compiler }); | |
3dfed10e XL |
2317 | } |
2318 | ||
2319 | /// Tests the Platform Support page in the rustc book. | |
2320 | fn run(self, builder: &Builder<'_>) { | |
1b1a35ee | 2321 | builder.ensure(compile::Std { compiler: self.compiler, target: self.compiler.host }); |
3dfed10e XL |
2322 | let mut cargo = tool::prepare_tool_cargo( |
2323 | builder, | |
2324 | self.compiler, | |
1b1a35ee XL |
2325 | Mode::ToolStd, |
2326 | self.compiler.host, | |
3dfed10e XL |
2327 | "run", |
2328 | "src/tools/tier-check", | |
2329 | SourceType::InTree, | |
2330 | &[], | |
2331 | ); | |
2332 | cargo.arg(builder.src.join("src/doc/rustc/src/platform-support.md")); | |
2333 | cargo.arg(&builder.rustc(self.compiler)); | |
2334 | if builder.is_verbose() { | |
2335 | cargo.arg("--verbose"); | |
2336 | } | |
2337 | ||
2338 | builder.info("platform support check"); | |
2339 | try_run(builder, &mut cargo.into()); | |
2340 | } | |
2341 | } | |
fc512014 XL |
2342 | |
2343 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
2344 | pub struct LintDocs { | |
2345 | pub compiler: Compiler, | |
2346 | pub target: TargetSelection, | |
2347 | } | |
2348 | ||
2349 | impl Step for LintDocs { | |
2350 | type Output = (); | |
2351 | const DEFAULT: bool = true; | |
2352 | const ONLY_HOSTS: bool = true; | |
2353 | ||
2354 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
2355 | run.path("src/tools/lint-docs") | |
2356 | } | |
2357 | ||
2358 | fn make_run(run: RunConfig<'_>) { | |
2359 | run.builder.ensure(LintDocs { | |
2360 | compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), | |
2361 | target: run.target, | |
2362 | }); | |
2363 | } | |
2364 | ||
2365 | /// Tests that the lint examples in the rustc book generate the correct | |
2366 | /// lints and have the expected format. | |
2367 | fn run(self, builder: &Builder<'_>) { | |
2368 | builder.ensure(crate::doc::RustcBook { | |
2369 | compiler: self.compiler, | |
2370 | target: self.target, | |
2371 | validate: true, | |
2372 | }); | |
2373 | } | |
2374 | } |