blob: 92847786792156e1b44b01f9051fa2831ee4c9a6 [file] [log] [blame]
Alex Crichtondefd1b32016-03-08 07:15:551// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
Alex Crichton0e272de2016-11-16 20:31:1911//! Implementation of the test-related targets of the build system.
Alex Crichtonf72bfe62016-05-02 22:16:1512//!
13//! This file implements the various regression test suites that we execute on
14//! our CI.
15
Alex Crichtonbb9062a2016-04-29 21:23:1516use std::env;
Nick Cameron04415dc2017-06-30 18:58:5417use std::ffi::OsString;
Ulrik Sverdrupb1566ba2016-11-25 21:13:5918use std::fmt;
Mark Simulacrumdd1d75e2017-06-04 23:55:5019use std::fs::{self, File};
Mark Simulacrumdd1d75e2017-06-04 23:55:5020use std::io::Read;
Santiago Pastorinob39a1d62018-05-30 17:33:4321use std::iter;
22use std::path::{Path, PathBuf};
23use std::process::Command;
Alex Crichton73c2d2a2016-04-14 21:27:5124
kennytm2566fa22017-12-06 21:06:4825use build_helper::{self, output};
Alex Crichton126e09e2016-04-14 22:51:0326
Santiago Pastorinob39a1d62018-05-30 17:33:4327use builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
28use cache::{Interned, INTERNER};
Alex Crichton90105672017-07-17 16:32:0829use compile;
30use dist;
Santiago Pastorinob39a1d62018-05-30 17:33:4331use flags::Subcommand;
Alex Crichton90105672017-07-17 16:32:0832use native;
33use tool::{self, Tool};
Oliver Schneiderab018c72017-08-30 16:59:2634use toolstate::ToolState;
Santiago Pastorinob39a1d62018-05-30 17:33:4335use util::{self, dylib_path, dylib_path_var};
36use Crate as CargoCrate;
37use {DocTests, Mode};
Alex Crichton39a5d3f2016-06-28 20:31:3038
Mark Simulacrum5b44cbc2017-06-26 16:23:5039const ADB_TEST_DIR: &str = "/data/tmp/work";
Alex Crichtondefd1b32016-03-08 07:15:5540
Ulrik Sverdrupb1566ba2016-11-25 21:13:5941/// The two modes of the test runner; tests or benchmarks.
kennytmbe9d6692018-05-05 18:33:0142#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)]
Ulrik Sverdrupb1566ba2016-11-25 21:13:5943pub enum TestKind {
44 /// Run `cargo test`
45 Test,
46 /// Run `cargo bench`
47 Bench,
48}
49
Oliver Schneider37dee692018-05-16 15:18:1950impl From<Kind> for TestKind {
51 fn from(kind: Kind) -> Self {
52 match kind {
53 Kind::Test => TestKind::Test,
Oliver Schneider37dee692018-05-16 15:18:1954 Kind::Bench => TestKind::Bench,
Santiago Pastorinob39a1d62018-05-30 17:33:4355 _ => panic!("unexpected kind in crate: {:?}", kind),
Oliver Schneider37dee692018-05-16 15:18:1956 }
57 }
58}
59
Ulrik Sverdrupb1566ba2016-11-25 21:13:5960impl TestKind {
61 // Return the cargo subcommand for this test kind
62 fn subcommand(self) -> &'static str {
63 match self {
64 TestKind::Test => "test",
65 TestKind::Bench => "bench",
66 }
67 }
68}
69
70impl fmt::Display for TestKind {
71 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
72 f.write_str(match *self {
73 TestKind::Test => "Testing",
74 TestKind::Bench => "Benchmarking",
75 })
76 }
77}
78
Mark Simulacrumbe1e7892018-04-14 23:27:5779fn try_run(builder: &Builder, cmd: &mut Command) -> bool {
80 if !builder.fail_fast {
81 if !builder.try_run(cmd) {
82 let mut failures = builder.delayed_failures.borrow_mut();
Ximin Luo8f254972017-09-18 19:21:2483 failures.push(format!("{:?}", cmd));
Oliver Schneideracdf83f2017-12-06 08:25:2984 return false;
Josh Stone617aea42017-06-02 16:27:4485 }
86 } else {
Mark Simulacrumbe1e7892018-04-14 23:27:5787 builder.run(cmd);
Josh Stone617aea42017-06-02 16:27:4488 }
Oliver Schneideracdf83f2017-12-06 08:25:2989 true
Josh Stone617aea42017-06-02 16:27:4490}
91
Mark Simulacrumbe1e7892018-04-14 23:27:5792fn try_run_quiet(builder: &Builder, cmd: &mut Command) -> bool {
93 if !builder.fail_fast {
94 if !builder.try_run_quiet(cmd) {
95 let mut failures = builder.delayed_failures.borrow_mut();
Ximin Luo8f254972017-09-18 19:21:2496 failures.push(format!("{:?}", cmd));
kennytma9f940e2018-02-21 19:25:2397 return false;
Josh Stone617aea42017-06-02 16:27:4498 }
99 } else {
Mark Simulacrumbe1e7892018-04-14 23:27:57100 builder.run_quiet(cmd);
Josh Stone617aea42017-06-02 16:27:44101 }
kennytma9f940e2018-02-21 19:25:23102 true
Josh Stone617aea42017-06-02 16:27:44103}
104
Mark Simulacrum528646e2017-07-14 00:48:44105#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
106pub struct Linkcheck {
107 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43108}
109
Mark Simulacrum528646e2017-07-14 00:48:44110impl Step for Linkcheck {
Mark Simulacrum001e9f32017-07-05 01:41:43111 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27112 const ONLY_HOSTS: bool = true;
113 const DEFAULT: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43114
115 /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
116 ///
117 /// This tool in `src/tools` will verify the validity of all our links in the
118 /// documentation to ensure we don't have a bunch of dead ones.
119 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:43120 let host = self.host;
121
Mark Simulacrumbe1e7892018-04-14 23:27:57122 builder.info(&format!("Linkcheck ({})", host));
Mark Simulacrum6b3413d2017-07-05 12:41:27123
124 builder.default_doc(None);
Mark Simulacrum001e9f32017-07-05 01:41:43125
Mark Simulacrumbe1e7892018-04-14 23:27:57126 let _time = util::timeit(&builder);
Santiago Pastorinob39a1d62018-05-30 17:33:43127 try_run(
128 builder,
129 builder
130 .tool_cmd(Tool::Linkchecker)
131 .arg(builder.out.join(host).join("doc")),
132 );
Mark Simulacrum001e9f32017-07-05 01:41:43133 }
Mark Simulacrum6b3413d2017-07-05 12:41:27134
Mark Simulacrum56128fb2017-07-19 00:03:38135 fn should_run(run: ShouldRun) -> ShouldRun {
Mark Simulacrumb05af492017-07-20 23:24:11136 let builder = run.builder;
Santiago Pastorinob39a1d62018-05-30 17:33:43137 run.path("src/tools/linkchecker")
138 .default_condition(builder.config.docs)
Mark Simulacrum6b3413d2017-07-05 12:41:27139 }
140
Mark Simulacrum6a67a052017-07-20 23:51:07141 fn make_run(run: RunConfig) {
Mark Simulacrum9ee877b2017-07-27 12:50:43142 run.builder.ensure(Linkcheck { host: run.target });
Mark Simulacrum6b3413d2017-07-05 12:41:27143 }
Alex Crichtondefd1b32016-03-08 07:15:55144}
Brian Anderson3a790ac2016-03-18 20:54:31145
Mark Simulacrum528646e2017-07-14 00:48:44146#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
147pub struct Cargotest {
Mark Simulacrum001e9f32017-07-05 01:41:43148 stage: u32,
Mark Simulacrum528646e2017-07-14 00:48:44149 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43150}
Alex Crichton73c2d2a2016-04-14 21:27:51151
Mark Simulacrum528646e2017-07-14 00:48:44152impl Step for Cargotest {
Mark Simulacrum001e9f32017-07-05 01:41:43153 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27154 const ONLY_HOSTS: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43155
Mark Simulacrum56128fb2017-07-19 00:03:38156 fn should_run(run: ShouldRun) -> ShouldRun {
157 run.path("src/tools/cargotest")
Mark Simulacrumceecd622017-07-12 16:12:47158 }
159
Mark Simulacrum6a67a052017-07-20 23:51:07160 fn make_run(run: RunConfig) {
161 run.builder.ensure(Cargotest {
162 stage: run.builder.top_stage,
Mark Simulacrum9ee877b2017-07-27 12:50:43163 host: run.target,
Mark Simulacrumceecd622017-07-12 16:12:47164 });
165 }
166
Mark Simulacrum001e9f32017-07-05 01:41:43167 /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
168 ///
169 /// This tool in `src/tools` will check out a few Rust projects and run `cargo
170 /// test` to ensure that we don't regress the test suites there.
171 fn run(self, builder: &Builder) {
Mark Simulacrum60388302017-07-05 16:46:41172 let compiler = builder.compiler(self.stage, self.host);
Santiago Pastorinob39a1d62018-05-30 17:33:43173 builder.ensure(compile::Rustc {
174 compiler,
175 target: compiler.host,
176 });
Mark Simulacrum001e9f32017-07-05 01:41:43177
178 // Note that this is a short, cryptic, and not scoped directory name. This
179 // is currently to minimize the length of path on Windows where we otherwise
180 // quickly run into path name limit constraints.
Mark Simulacrumbe1e7892018-04-14 23:27:57181 let out_dir = builder.out.join("ct");
Mark Simulacrum001e9f32017-07-05 01:41:43182 t!(fs::create_dir_all(&out_dir));
183
Mark Simulacrumbe1e7892018-04-14 23:27:57184 let _time = util::timeit(&builder);
Mark Simulacrum6b3413d2017-07-05 12:41:27185 let mut cmd = builder.tool_cmd(Tool::CargoTest);
Santiago Pastorinob39a1d62018-05-30 17:33:43186 try_run(
187 builder,
188 cmd.arg(&builder.initial_cargo)
189 .arg(&out_dir)
190 .env("RUSTC", builder.rustc(compiler))
191 .env("RUSTDOC", builder.rustdoc(compiler.host)),
192 );
Mark Simulacrum001e9f32017-07-05 01:41:43193 }
Alex Crichton009f45f2017-04-18 00:24:05194}
195
Mark Simulacrum528646e2017-07-14 00:48:44196#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
197pub struct Cargo {
Mark Simulacrum001e9f32017-07-05 01:41:43198 stage: u32,
Mark Simulacrum528646e2017-07-14 00:48:44199 host: Interned<String>,
Nick Cameron04415dc2017-06-30 18:58:54200}
201
Mark Simulacrum528646e2017-07-14 00:48:44202impl Step for Cargo {
Mark Simulacrum001e9f32017-07-05 01:41:43203 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27204 const ONLY_HOSTS: bool = true;
205
Mark Simulacrum56128fb2017-07-19 00:03:38206 fn should_run(run: ShouldRun) -> ShouldRun {
207 run.path("src/tools/cargo")
Mark Simulacrum6b3413d2017-07-05 12:41:27208 }
209
Mark Simulacrum6a67a052017-07-20 23:51:07210 fn make_run(run: RunConfig) {
211 run.builder.ensure(Cargo {
212 stage: run.builder.top_stage,
213 host: run.target,
Mark Simulacrum6b3413d2017-07-05 12:41:27214 });
215 }
Nick Cameron04415dc2017-06-30 18:58:54216
Mark Simulacrum001e9f32017-07-05 01:41:43217 /// Runs `cargo test` for `cargo` packaged with Rust.
218 fn run(self, builder: &Builder) {
Mark Simulacrum6b3413d2017-07-05 12:41:27219 let compiler = builder.compiler(self.stage, self.host);
Nick Cameron04415dc2017-06-30 18:58:54220
Santiago Pastorinob39a1d62018-05-30 17:33:43221 builder.ensure(tool::Cargo {
222 compiler,
223 target: self.host,
224 });
Mark Simulacrumc114fe52017-07-05 17:21:33225 let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
Santiago Pastorinob39a1d62018-05-30 17:33:43226 cargo
227 .arg("--manifest-path")
228 .arg(builder.src.join("src/tools/cargo/Cargo.toml"));
Mark Simulacrumbe1e7892018-04-14 23:27:57229 if !builder.fail_fast {
Mark Simulacrum001e9f32017-07-05 01:41:43230 cargo.arg("--no-fail-fast");
231 }
Nick Cameron04415dc2017-06-30 18:58:54232
Mark Simulacrum001e9f32017-07-05 01:41:43233 // Don't build tests dynamically, just a pain to work with
234 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
235
236 // Don't run cross-compile tests, we may not have cross-compiled libstd libs
237 // available.
238 cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
239
Santiago Pastorinob39a1d62018-05-30 17:33:43240 try_run(
241 builder,
242 cargo.env("PATH", &path_for_cargo(builder, compiler)),
243 );
Mark Simulacrum001e9f32017-07-05 01:41:43244 }
245}
246
Mark Simulacrumdec44b02017-07-17 15:52:05247#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
248pub struct Rls {
Mark Simulacrum001e9f32017-07-05 01:41:43249 stage: u32,
Mark Simulacrumdec44b02017-07-17 15:52:05250 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43251}
252
Mark Simulacrumdec44b02017-07-17 15:52:05253impl Step for Rls {
Mark Simulacrum001e9f32017-07-05 01:41:43254 type Output = ();
Mark Simulacrumdec44b02017-07-17 15:52:05255 const ONLY_HOSTS: bool = true;
256
Mark Simulacrum56128fb2017-07-19 00:03:38257 fn should_run(run: ShouldRun) -> ShouldRun {
258 run.path("src/tools/rls")
Mark Simulacrumdec44b02017-07-17 15:52:05259 }
260
Mark Simulacrum6a67a052017-07-20 23:51:07261 fn make_run(run: RunConfig) {
262 run.builder.ensure(Rls {
263 stage: run.builder.top_stage,
264 host: run.target,
Mark Simulacrumdec44b02017-07-17 15:52:05265 });
266 }
Mark Simulacrum001e9f32017-07-05 01:41:43267
268 /// Runs `cargo test` for the rls.
269 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:43270 let stage = self.stage;
271 let host = self.host;
Mark Simulacrumdec44b02017-07-17 15:52:05272 let compiler = builder.compiler(stage, host);
Mark Simulacrum001e9f32017-07-05 01:41:43273
kennytm27d96912018-04-20 16:53:36274 let build_result = builder.ensure(tool::Rls {
275 compiler,
276 target: self.host,
277 extra_features: Vec::new(),
278 });
279 if build_result.is_none() {
280 eprintln!("failed to test rls: could not build");
281 return;
282 }
283
Santiago Pastorinob39a1d62018-05-30 17:33:43284 let mut cargo = tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rls");
Mark Simulacrum001e9f32017-07-05 01:41:43285
286 // Don't build tests dynamically, just a pain to work with
287 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
288
Mark Simulacrumdec44b02017-07-17 15:52:05289 builder.add_rustc_lib_path(compiler, &mut cargo);
Mark Simulacrum001e9f32017-07-05 01:41:43290
Mark Simulacrumbe1e7892018-04-14 23:27:57291 if try_run(builder, &mut cargo) {
292 builder.save_toolstate("rls", ToolState::TestPass);
Oliver Schneideracdf83f2017-12-06 08:25:29293 }
Mark Simulacrum001e9f32017-07-05 01:41:43294 }
Nick Cameron04415dc2017-06-30 18:58:54295}
296
Nick Camerond0070e82017-09-01 06:43:00297#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
298pub struct Rustfmt {
299 stage: u32,
300 host: Interned<String>,
301}
302
303impl Step for Rustfmt {
304 type Output = ();
305 const ONLY_HOSTS: bool = true;
306
307 fn should_run(run: ShouldRun) -> ShouldRun {
308 run.path("src/tools/rustfmt")
309 }
310
311 fn make_run(run: RunConfig) {
312 run.builder.ensure(Rustfmt {
313 stage: run.builder.top_stage,
314 host: run.target,
315 });
316 }
317
318 /// Runs `cargo test` for rustfmt.
319 fn run(self, builder: &Builder) {
Nick Camerond0070e82017-09-01 06:43:00320 let stage = self.stage;
321 let host = self.host;
322 let compiler = builder.compiler(stage, host);
323
kennytm27d96912018-04-20 16:53:36324 let build_result = builder.ensure(tool::Rustfmt {
325 compiler,
326 target: self.host,
327 extra_features: Vec::new(),
328 });
329 if build_result.is_none() {
330 eprintln!("failed to test rustfmt: could not build");
331 return;
332 }
333
Santiago Pastorinob39a1d62018-05-30 17:33:43334 let mut cargo =
335 tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rustfmt");
Nick Camerond0070e82017-09-01 06:43:00336
337 // Don't build tests dynamically, just a pain to work with
338 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
Nick Camerondf97dd12018-05-05 20:27:48339 let dir = testdir(builder, compiler.host);
340 t!(fs::create_dir_all(&dir));
341 cargo.env("RUSTFMT_TEST_DIR", dir);
Nick Camerond0070e82017-09-01 06:43:00342
343 builder.add_rustc_lib_path(compiler, &mut cargo);
344
Mark Simulacrumbe1e7892018-04-14 23:27:57345 if try_run(builder, &mut cargo) {
346 builder.save_toolstate("rustfmt", ToolState::TestPass);
Oliver Schneideracdf83f2017-12-06 08:25:29347 }
Nick Camerond0070e82017-09-01 06:43:00348 }
349}
Oliver Schneider01555b12017-09-17 19:45:54350
351#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Oliver Schneiderf3817442017-08-28 14:54:50352pub struct Miri {
Oliver Schneideracdf83f2017-12-06 08:25:29353 stage: u32,
Oliver Schneiderf3817442017-08-28 14:54:50354 host: Interned<String>,
355}
356
357impl Step for Miri {
358 type Output = ();
359 const ONLY_HOSTS: bool = true;
360 const DEFAULT: bool = true;
361
362 fn should_run(run: ShouldRun) -> ShouldRun {
Mark Simulacrumbe1e7892018-04-14 23:27:57363 let test_miri = run.builder.config.test_miri;
Oliver Schneiderf3817442017-08-28 14:54:50364 run.path("src/tools/miri").default_condition(test_miri)
365 }
366
367 fn make_run(run: RunConfig) {
368 run.builder.ensure(Miri {
Oliver Schneideracdf83f2017-12-06 08:25:29369 stage: run.builder.top_stage,
Oliver Schneiderf3817442017-08-28 14:54:50370 host: run.target,
371 });
372 }
373
374 /// Runs `cargo test` for miri.
375 fn run(self, builder: &Builder) {
Oliver Schneideracdf83f2017-12-06 08:25:29376 let stage = self.stage;
Oliver Schneiderf3817442017-08-28 14:54:50377 let host = self.host;
Oliver Schneideracdf83f2017-12-06 08:25:29378 let compiler = builder.compiler(stage, host);
Oliver Schneiderf3817442017-08-28 14:54:50379
Oliver Schneider02ac15c2018-02-09 17:53:41380 let miri = builder.ensure(tool::Miri {
381 compiler,
382 target: self.host,
383 extra_features: Vec::new(),
384 });
385 if let Some(miri) = miri {
Oliver Schneideracdf83f2017-12-06 08:25:29386 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
Santiago Pastorinob39a1d62018-05-30 17:33:43387 cargo
388 .arg("--manifest-path")
389 .arg(builder.src.join("src/tools/miri/Cargo.toml"));
Oliver Schneiderf3817442017-08-28 14:54:50390
Oliver Schneideracdf83f2017-12-06 08:25:29391 // Don't build tests dynamically, just a pain to work with
392 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
393 // miri tests need to know about the stage sysroot
394 cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
395 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
396 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
397 cargo.env("MIRI_PATH", miri);
Oliver Schneiderf3817442017-08-28 14:54:50398
Oliver Schneideracdf83f2017-12-06 08:25:29399 builder.add_rustc_lib_path(compiler, &mut cargo);
Oliver Schneiderf3817442017-08-28 14:54:50400
Mark Simulacrumbe1e7892018-04-14 23:27:57401 if try_run(builder, &mut cargo) {
402 builder.save_toolstate("miri", ToolState::TestPass);
Oliver Schneideracdf83f2017-12-06 08:25:29403 }
404 } else {
405 eprintln!("failed to test miri: could not build");
406 }
Oliver Schneiderf3817442017-08-28 14:54:50407 }
408}
409
Oliver Schneiderd64a0672017-09-18 11:13:57410#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
411pub struct Clippy {
Oliver Schneideracdf83f2017-12-06 08:25:29412 stage: u32,
Oliver Schneiderd64a0672017-09-18 11:13:57413 host: Interned<String>,
414}
415
416impl Step for Clippy {
417 type Output = ();
418 const ONLY_HOSTS: bool = true;
419 const DEFAULT: bool = false;
420
421 fn should_run(run: ShouldRun) -> ShouldRun {
422 run.path("src/tools/clippy")
423 }
424
425 fn make_run(run: RunConfig) {
426 run.builder.ensure(Clippy {
Oliver Schneideracdf83f2017-12-06 08:25:29427 stage: run.builder.top_stage,
Oliver Schneiderd64a0672017-09-18 11:13:57428 host: run.target,
429 });
430 }
431
432 /// Runs `cargo test` for clippy.
433 fn run(self, builder: &Builder) {
Oliver Schneideracdf83f2017-12-06 08:25:29434 let stage = self.stage;
Oliver Schneiderd64a0672017-09-18 11:13:57435 let host = self.host;
Oliver Schneideracdf83f2017-12-06 08:25:29436 let compiler = builder.compiler(stage, host);
Oliver Schneiderd64a0672017-09-18 11:13:57437
Oliver Schneider02ac15c2018-02-09 17:53:41438 let clippy = builder.ensure(tool::Clippy {
439 compiler,
440 target: self.host,
441 extra_features: Vec::new(),
442 });
443 if let Some(clippy) = clippy {
Oliver Schneideracdf83f2017-12-06 08:25:29444 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
Santiago Pastorinob39a1d62018-05-30 17:33:43445 cargo
446 .arg("--manifest-path")
447 .arg(builder.src.join("src/tools/clippy/Cargo.toml"));
Oliver Schneiderd64a0672017-09-18 11:13:57448
Oliver Schneideracdf83f2017-12-06 08:25:29449 // Don't build tests dynamically, just a pain to work with
450 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
451 // clippy tests need to know about the stage sysroot
452 cargo.env("SYSROOT", builder.sysroot(compiler));
453 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
454 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
Santiago Pastorinob39a1d62018-05-30 17:33:43455 let host_libs = builder
456 .stage_out(compiler, Mode::Tool)
457 .join(builder.cargo_dir());
Oliver Schneideracdf83f2017-12-06 08:25:29458 cargo.env("HOST_LIBS", host_libs);
459 // clippy tests need to find the driver
460 cargo.env("CLIPPY_DRIVER_PATH", clippy);
Oliver Schneiderd64a0672017-09-18 11:13:57461
Oliver Schneideracdf83f2017-12-06 08:25:29462 builder.add_rustc_lib_path(compiler, &mut cargo);
Oliver Schneiderd64a0672017-09-18 11:13:57463
Mark Simulacrumbe1e7892018-04-14 23:27:57464 if try_run(builder, &mut cargo) {
465 builder.save_toolstate("clippy-driver", ToolState::TestPass);
Oliver Schneideracdf83f2017-12-06 08:25:29466 }
467 } else {
468 eprintln!("failed to test clippy: could not build");
469 }
Oliver Schneiderd64a0672017-09-18 11:13:57470 }
471}
Nick Camerond0070e82017-09-01 06:43:00472
Mark Simulacrumdec44b02017-07-17 15:52:05473fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
Nick Cameron04415dc2017-06-30 18:58:54474 // Configure PATH to find the right rustc. NB. we have to use PATH
475 // and not RUSTC because the Cargo test suite has tests that will
476 // fail if rustc is not spelled `rustc`.
Mark Simulacrumdec44b02017-07-17 15:52:05477 let path = builder.sysroot(compiler).join("bin");
Nick Cameron04415dc2017-06-30 18:58:54478 let old_path = env::var_os("PATH").unwrap_or_default();
479 env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
Brian Anderson3a790ac2016-03-18 20:54:31480}
Alex Crichton9dd3c542016-03-29 20:14:52481
Guillaume Gomezf18c52b2017-12-12 22:53:24482#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
Guillaume Gomez51580d42018-01-25 23:44:52483pub struct RustdocTheme {
484 pub compiler: Compiler,
Guillaume Gomez51580d42018-01-25 23:44:52485}
486
487impl Step for RustdocTheme {
488 type Output = ();
489 const DEFAULT: bool = true;
490 const ONLY_HOSTS: bool = true;
491
492 fn should_run(run: ShouldRun) -> ShouldRun {
493 run.path("src/tools/rustdoc-themes")
494 }
495
496 fn make_run(run: RunConfig) {
497 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
498
Santiago Pastorinob39a1d62018-05-30 17:33:43499 run.builder.ensure(RustdocTheme { compiler: compiler });
Guillaume Gomez51580d42018-01-25 23:44:52500 }
501
502 fn run(self, builder: &Builder) {
Chris Coulson6f101462018-04-12 14:01:49503 let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
Guillaume Gomezdec9fab2018-02-05 22:43:53504 let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
505 cmd.arg(rustdoc.to_str().unwrap())
Santiago Pastorinob39a1d62018-05-30 17:33:43506 .arg(
507 builder
508 .src
509 .join("src/librustdoc/html/static/themes")
510 .to_str()
511 .unwrap(),
512 )
513 .env("RUSTC_STAGE", self.compiler.stage.to_string())
514 .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
515 .env(
516 "RUSTDOC_LIBDIR",
517 builder.sysroot_libdir(self.compiler, self.compiler.host),
518 )
519 .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
520 .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
521 .env("RUSTDOC_CRATE_VERSION", builder.rust_version())
522 .env("RUSTC_BOOTSTRAP", "1");
Mark Simulacrumbe1e7892018-04-14 23:27:57523 if let Some(linker) = builder.linker(self.compiler.host) {
Guillaume Gomez51580d42018-01-25 23:44:52524 cmd.env("RUSTC_TARGET_LINKER", linker);
525 }
Mark Simulacrumbe1e7892018-04-14 23:27:57526 try_run(builder, &mut cmd);
Guillaume Gomez51580d42018-01-25 23:44:52527 }
528}
529
530#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
Guillaume Gomezf18c52b2017-12-12 22:53:24531pub struct RustdocJS {
532 pub host: Interned<String>,
Guillaume Gomez69521992018-01-12 22:40:00533 pub target: Interned<String>,
Guillaume Gomezf18c52b2017-12-12 22:53:24534}
535
536impl Step for RustdocJS {
Guillaume Gomez50bb6ba2018-01-08 22:43:20537 type Output = ();
Guillaume Gomezf18c52b2017-12-12 22:53:24538 const DEFAULT: bool = true;
539 const ONLY_HOSTS: bool = true;
540
541 fn should_run(run: ShouldRun) -> ShouldRun {
Guillaume Gomez69521992018-01-12 22:40:00542 run.path("src/test/rustdoc-js")
Guillaume Gomezf18c52b2017-12-12 22:53:24543 }
544
545 fn make_run(run: RunConfig) {
546 run.builder.ensure(RustdocJS {
547 host: run.host,
Guillaume Gomez69521992018-01-12 22:40:00548 target: run.target,
Guillaume Gomezf18c52b2017-12-12 22:53:24549 });
550 }
551
Guillaume Gomez50bb6ba2018-01-08 22:43:20552 fn run(self, builder: &Builder) {
Guillaume Gomez026c7492018-01-13 21:35:41553 if let Some(ref nodejs) = builder.config.nodejs {
554 let mut command = Command::new(nodejs);
555 command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]);
556 builder.ensure(::doc::Std {
557 target: self.target,
558 stage: builder.top_stage,
559 });
560 builder.run(&mut command);
561 } else {
Santiago Pastorinob39a1d62018-05-30 17:33:43562 builder.info(&format!(
563 "No nodejs found, skipping \"src/test/rustdoc-js\" tests"
564 ));
Guillaume Gomez026c7492018-01-13 21:35:41565 }
Guillaume Gomezf18c52b2017-12-12 22:53:24566 }
567}
568
Guillaume Gomez035ec5b2018-03-31 12:49:56569#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
570pub struct RustdocUi {
571 pub host: Interned<String>,
572 pub target: Interned<String>,
573 pub compiler: Compiler,
574}
575
576impl Step for RustdocUi {
577 type Output = ();
578 const DEFAULT: bool = true;
579 const ONLY_HOSTS: bool = true;
580
581 fn should_run(run: ShouldRun) -> ShouldRun {
582 run.path("src/test/rustdoc-ui")
583 }
584
585 fn make_run(run: RunConfig) {
586 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
587 run.builder.ensure(RustdocUi {
588 host: run.host,
589 target: run.target,
590 compiler,
591 });
592 }
593
594 fn run(self, builder: &Builder) {
595 builder.ensure(Compiletest {
596 compiler: self.compiler,
597 target: self.target,
598 mode: "ui",
599 suite: "rustdoc-ui",
Collins Abitekaniza41ee6fe2018-04-12 11:49:31600 path: None,
Felix S. Klock II55895502018-04-11 15:15:59601 compare_mode: None,
Guillaume Gomez035ec5b2018-03-31 12:49:56602 })
603 }
604}
605
Mark Simulacrum528646e2017-07-14 00:48:44606#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum1c8f3b02018-02-11 22:41:06607pub struct Tidy;
Mark Simulacrum001e9f32017-07-05 01:41:43608
Mark Simulacrum528646e2017-07-14 00:48:44609impl Step for Tidy {
Mark Simulacrum001e9f32017-07-05 01:41:43610 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27611 const DEFAULT: bool = true;
612 const ONLY_HOSTS: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43613
Mark Simulacrum1c8f3b02018-02-11 22:41:06614 /// Runs the `tidy` tool.
Mark Simulacrum001e9f32017-07-05 01:41:43615 ///
616 /// This tool in `src/tools` checks up on various bits and pieces of style and
617 /// otherwise just implements a few lint-like checks that are specific to the
618 /// compiler itself.
619 fn run(self, builder: &Builder) {
Mark Simulacrum60388302017-07-05 16:46:41620 let mut cmd = builder.tool_cmd(Tool::Tidy);
Mark Simulacrumbe1e7892018-04-14 23:27:57621 cmd.arg(builder.src.join("src"));
622 cmd.arg(&builder.initial_cargo);
623 if !builder.config.vendor {
Mark Simulacrum001e9f32017-07-05 01:41:43624 cmd.arg("--no-vendor");
625 }
Mark Simulacrumbe1e7892018-04-14 23:27:57626 if builder.config.quiet_tests {
Mark Simulacrum001e9f32017-07-05 01:41:43627 cmd.arg("--quiet");
628 }
Alex Crichton6fd4d672018-03-16 15:35:03629
Mark Simulacrumbe1e7892018-04-14 23:27:57630 let _folder = builder.fold_output(|| "tidy");
Mark Simulacrum545b92f2018-03-28 15:25:09631 builder.info(&format!("tidy check"));
Mark Simulacrumbe1e7892018-04-14 23:27:57632 try_run(builder, &mut cmd);
Eduard-Mihai Burtescud29f0bc2017-02-10 20:59:40633 }
Mark Simulacrum6b3413d2017-07-05 12:41:27634
Mark Simulacrum56128fb2017-07-19 00:03:38635 fn should_run(run: ShouldRun) -> ShouldRun {
636 run.path("src/tools/tidy")
Mark Simulacrum6b3413d2017-07-05 12:41:27637 }
638
Mark Simulacrum6a67a052017-07-20 23:51:07639 fn make_run(run: RunConfig) {
Mark Simulacrum1c8f3b02018-02-11 22:41:06640 run.builder.ensure(Tidy);
Mark Simulacrum6b3413d2017-07-05 12:41:27641 }
Alex Crichton9dd3c542016-03-29 20:14:52642}
Alex Crichtonb325baf2016-04-05 18:34:23643
Mark Simulacrumbe1e7892018-04-14 23:27:57644fn testdir(builder: &Builder, host: Interned<String>) -> PathBuf {
645 builder.out.join(host).join("test")
Alex Crichtonb325baf2016-04-05 18:34:23646}
647
Mark Simulacrumf104b122018-02-11 16:51:58648macro_rules! default_test {
649 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
650 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: false });
651 }
Mark Simulacrum1ab89302017-07-07 17:51:57652}
653
Felix S. Klock II55895502018-04-11 15:15:59654macro_rules! default_test_with_compare_mode {
655 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr,
656 compare_mode: $compare_mode:expr }) => {
657 test_with_compare_mode!($name { path: $path, mode: $mode, suite: $suite, default: true,
658 host: false, compare_mode: $compare_mode });
659 }
660}
661
Mark Simulacrumf104b122018-02-11 16:51:58662macro_rules! host_test {
663 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
664 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: true });
665 }
666}
Mark Simulacrum6b3413d2017-07-05 12:41:27667
Mark Simulacrumf104b122018-02-11 16:51:58668macro_rules! test {
Felix S. Klock II55895502018-04-11 15:15:59669 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
670 host: $host:expr }) => {
671 test_definitions!($name { path: $path, mode: $mode, suite: $suite, default: $default,
672 host: $host, compare_mode: None });
673 }
674}
675
676macro_rules! test_with_compare_mode {
677 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
678 host: $host:expr, compare_mode: $compare_mode:expr }) => {
679 test_definitions!($name { path: $path, mode: $mode, suite: $suite, default: $default,
680 host: $host, compare_mode: Some($compare_mode) });
681 }
682}
683
684macro_rules! test_definitions {
Mark Simulacrumf104b122018-02-11 16:51:58685 ($name:ident {
686 path: $path:expr,
687 mode: $mode:expr,
688 suite: $suite:expr,
689 default: $default:expr,
Felix S. Klock II55895502018-04-11 15:15:59690 host: $host:expr,
691 compare_mode: $compare_mode:expr
Mark Simulacrumf104b122018-02-11 16:51:58692 }) => {
693 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
694 pub struct $name {
695 pub compiler: Compiler,
696 pub target: Interned<String>,
697 }
698
699 impl Step for $name {
700 type Output = ();
701 const DEFAULT: bool = $default;
702 const ONLY_HOSTS: bool = $host;
703
704 fn should_run(run: ShouldRun) -> ShouldRun {
Collins Abitekaniza41ee6fe2018-04-12 11:49:31705 run.suite_path($path)
Mark Simulacrumf104b122018-02-11 16:51:58706 }
707
708 fn make_run(run: RunConfig) {
709 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
710
711 run.builder.ensure($name {
712 compiler,
713 target: run.target,
714 });
715 }
716
717 fn run(self, builder: &Builder) {
718 builder.ensure(Compiletest {
719 compiler: self.compiler,
720 target: self.target,
721 mode: $mode,
722 suite: $suite,
Collins Abitekaniza41ee6fe2018-04-12 11:49:31723 path: Some($path),
Felix S. Klock II55895502018-04-11 15:15:59724 compare_mode: $compare_mode,
Mark Simulacrumf104b122018-02-11 16:51:58725 })
726 }
727 }
728 }
729}
730
Felix S. Klock II55895502018-04-11 15:15:59731default_test_with_compare_mode!(Ui {
Mark Simulacrumf104b122018-02-11 16:51:58732 path: "src/test/ui",
733 mode: "ui",
Felix S. Klock II55895502018-04-11 15:15:59734 suite: "ui",
735 compare_mode: "nll"
Mark Simulacrumf104b122018-02-11 16:51:58736});
737
738default_test!(RunPass {
739 path: "src/test/run-pass",
740 mode: "run-pass",
741 suite: "run-pass"
742});
743
744default_test!(CompileFail {
745 path: "src/test/compile-fail",
746 mode: "compile-fail",
747 suite: "compile-fail"
748});
749
750default_test!(ParseFail {
751 path: "src/test/parse-fail",
752 mode: "parse-fail",
753 suite: "parse-fail"
754});
755
756default_test!(RunFail {
757 path: "src/test/run-fail",
758 mode: "run-fail",
759 suite: "run-fail"
760});
761
762default_test!(RunPassValgrind {
763 path: "src/test/run-pass-valgrind",
764 mode: "run-pass-valgrind",
765 suite: "run-pass-valgrind"
766});
767
768default_test!(MirOpt {
769 path: "src/test/mir-opt",
770 mode: "mir-opt",
771 suite: "mir-opt"
772});
773
774default_test!(Codegen {
775 path: "src/test/codegen",
776 mode: "codegen",
777 suite: "codegen"
778});
779
780default_test!(CodegenUnits {
781 path: "src/test/codegen-units",
782 mode: "codegen-units",
783 suite: "codegen-units"
784});
785
786default_test!(Incremental {
787 path: "src/test/incremental",
788 mode: "incremental",
789 suite: "incremental"
790});
791
792default_test!(Debuginfo {
793 path: "src/test/debuginfo",
Mark Simulacrumaa8b93b2017-07-07 18:31:29794 // What this runs varies depending on the native platform being apple
Mark Simulacrumf104b122018-02-11 16:51:58795 mode: "debuginfo-XXX",
796 suite: "debuginfo"
797});
Mark Simulacrum6b3413d2017-07-05 12:41:27798
Mark Simulacrumf104b122018-02-11 16:51:58799host_test!(UiFullDeps {
800 path: "src/test/ui-fulldeps",
801 mode: "ui",
802 suite: "ui-fulldeps"
803});
Mark Simulacrumf1d04a32017-07-20 15:42:18804
Mark Simulacrumf104b122018-02-11 16:51:58805host_test!(RunPassFullDeps {
806 path: "src/test/run-pass-fulldeps",
807 mode: "run-pass",
808 suite: "run-pass-fulldeps"
809});
Mark Simulacrumf1d04a32017-07-20 15:42:18810
Mark Simulacrumf104b122018-02-11 16:51:58811host_test!(RunFailFullDeps {
812 path: "src/test/run-fail-fulldeps",
813 mode: "run-fail",
814 suite: "run-fail-fulldeps"
815});
Mark Simulacrumf1d04a32017-07-20 15:42:18816
Mark Simulacrumf104b122018-02-11 16:51:58817host_test!(CompileFailFullDeps {
818 path: "src/test/compile-fail-fulldeps",
819 mode: "compile-fail",
820 suite: "compile-fail-fulldeps"
821});
Mark Simulacrumf1d04a32017-07-20 15:42:18822
Mark Simulacrumf104b122018-02-11 16:51:58823host_test!(IncrementalFullDeps {
824 path: "src/test/incremental-fulldeps",
825 mode: "incremental",
826 suite: "incremental-fulldeps"
827});
Mark Simulacrumf1d04a32017-07-20 15:42:18828
Mark Simulacrumf104b122018-02-11 16:51:58829host_test!(Rustdoc {
830 path: "src/test/rustdoc",
831 mode: "rustdoc",
832 suite: "rustdoc"
833});
Mark Simulacrumf1d04a32017-07-20 15:42:18834
Mark Simulacrumf104b122018-02-11 16:51:58835test!(Pretty {
836 path: "src/test/pretty",
837 mode: "pretty",
838 suite: "pretty",
839 default: false,
840 host: true
841});
842test!(RunPassPretty {
843 path: "src/test/run-pass/pretty",
844 mode: "pretty",
845 suite: "run-pass",
846 default: false,
847 host: true
848});
849test!(RunFailPretty {
850 path: "src/test/run-fail/pretty",
851 mode: "pretty",
852 suite: "run-fail",
853 default: false,
854 host: true
855});
856test!(RunPassValgrindPretty {
857 path: "src/test/run-pass-valgrind/pretty",
858 mode: "pretty",
859 suite: "run-pass-valgrind",
860 default: false,
861 host: true
862});
863test!(RunPassFullDepsPretty {
864 path: "src/test/run-pass-fulldeps/pretty",
865 mode: "pretty",
866 suite: "run-pass-fulldeps",
867 default: false,
868 host: true
869});
870test!(RunFailFullDepsPretty {
871 path: "src/test/run-fail-fulldeps/pretty",
872 mode: "pretty",
873 suite: "run-fail-fulldeps",
874 default: false,
875 host: true
876});
Mark Simulacrumf1d04a32017-07-20 15:42:18877
Eric Hussa90a9632018-05-15 23:39:21878default_test!(RunMake {
Mark Simulacrumf104b122018-02-11 16:51:58879 path: "src/test/run-make",
880 mode: "run-make",
881 suite: "run-make"
882});
Mark Simulacrumf1d04a32017-07-20 15:42:18883
Alex Crichton7df6f412018-03-09 17:26:15884host_test!(RunMakeFullDeps {
885 path: "src/test/run-make-fulldeps",
886 mode: "run-make",
887 suite: "run-make-fulldeps"
888});
889
Mark Simulacrumf1d04a32017-07-20 15:42:18890#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
891struct Compiletest {
892 compiler: Compiler,
893 target: Interned<String>,
894 mode: &'static str,
895 suite: &'static str,
Collins Abitekaniza41ee6fe2018-04-12 11:49:31896 path: Option<&'static str>,
Felix S. Klock II55895502018-04-11 15:15:59897 compare_mode: Option<&'static str>,
Mark Simulacrumf1d04a32017-07-20 15:42:18898}
899
900impl Step for Compiletest {
901 type Output = ();
902
903 fn should_run(run: ShouldRun) -> ShouldRun {
904 run.never()
905 }
906
Mark Simulacrum001e9f32017-07-05 01:41:43907 /// Executes the `compiletest` tool to run a suite of tests.
908 ///
909 /// Compiles all tests with `compiler` for `target` with the specified
910 /// compiletest `mode` and `suite` arguments. For example `mode` can be
911 /// "run-pass" or `suite` can be something like `debuginfo`.
912 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:43913 let compiler = self.compiler;
914 let target = self.target;
915 let mode = self.mode;
916 let suite = self.suite;
Mark Simulacrum6b3413d2017-07-05 12:41:27917
Collins Abitekaniza41ee6fe2018-04-12 11:49:31918 // Path for test suite
919 let suite_path = self.path.unwrap_or("");
920
Mark Simulacrum6b3413d2017-07-05 12:41:27921 // Skip codegen tests if they aren't enabled in configuration.
Mark Simulacrumbe1e7892018-04-14 23:27:57922 if !builder.config.codegen_tests && suite == "codegen" {
Mark Simulacrum6b3413d2017-07-05 12:41:27923 return;
924 }
925
926 if suite == "debuginfo" {
Mark Simulacrum951616c2017-07-20 17:23:29927 // Skip debuginfo tests on MSVC
Mark Simulacrumbe1e7892018-04-14 23:27:57928 if builder.config.build.contains("msvc") {
Mark Simulacrum951616c2017-07-20 17:23:29929 return;
930 }
931
Mark Simulacrum6b3413d2017-07-05 12:41:27932 if mode == "debuginfo-XXX" {
Mark Simulacrumbe1e7892018-04-14 23:27:57933 return if builder.config.build.contains("apple") {
Mark Simulacrum6b3413d2017-07-05 12:41:27934 builder.ensure(Compiletest {
935 mode: "debuginfo-lldb",
936 ..self
Mark Simulacrum528646e2017-07-14 00:48:44937 });
Mark Simulacrum6b3413d2017-07-05 12:41:27938 } else {
939 builder.ensure(Compiletest {
940 mode: "debuginfo-gdb",
941 ..self
Mark Simulacrum528646e2017-07-14 00:48:44942 });
Mark Simulacrum6b3413d2017-07-05 12:41:27943 };
944 }
945
Mark Simulacrum6b3413d2017-07-05 12:41:27946 builder.ensure(dist::DebuggerScripts {
Mark Simulacrum528646e2017-07-14 00:48:44947 sysroot: builder.sysroot(compiler),
Santiago Pastorinob39a1d62018-05-30 17:33:43948 host: target,
Mark Simulacrum6b3413d2017-07-05 12:41:27949 });
950 }
951
952 if suite.ends_with("fulldeps") ||
953 // FIXME: Does pretty need librustc compiled? Note that there are
954 // fulldeps test suites with mode = pretty as well.
955 mode == "pretty" ||
Santiago Pastorinob39a1d62018-05-30 17:33:43956 mode == "rustdoc"
957 {
Mark Simulacrum6b3413d2017-07-05 12:41:27958 builder.ensure(compile::Rustc { compiler, target });
959 }
960
961 builder.ensure(compile::Test { compiler, target });
962 builder.ensure(native::TestHelpers { target });
Mark Simulacrumaa8b93b2017-07-07 18:31:29963 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum6b3413d2017-07-05 12:41:27964
Mark Simulacrum6b3413d2017-07-05 12:41:27965 let mut cmd = builder.tool_cmd(Tool::Compiletest);
Alex Crichtonb325baf2016-04-05 18:34:23966
Mark Simulacrum001e9f32017-07-05 01:41:43967 // compiletest currently has... a lot of arguments, so let's just pass all
968 // of them!
Brian Anderson8401e372016-09-15 19:42:26969
Santiago Pastorinob39a1d62018-05-30 17:33:43970 cmd.arg("--compile-lib-path")
971 .arg(builder.rustc_libdir(compiler));
972 cmd.arg("--run-lib-path")
973 .arg(builder.sysroot_libdir(compiler, target));
Mark Simulacrumc114fe52017-07-05 17:21:33974 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
Mark Simulacrum4e5333c2017-07-25 22:54:33975
Guillaume Gomezb2192ae2018-04-01 19:06:35976 let is_rustdoc_ui = suite.ends_with("rustdoc-ui");
977
Mark Simulacrum4e5333c2017-07-25 22:54:33978 // Avoid depending on rustdoc when we don't need it.
Santiago Pastorinob39a1d62018-05-30 17:33:43979 if mode == "rustdoc"
980 || (mode == "run-make" && suite.ends_with("fulldeps"))
981 || (mode == "ui" && is_rustdoc_ui)
982 {
983 cmd.arg("--rustdoc-path")
984 .arg(builder.rustdoc(compiler.host));
Mark Simulacrum4e5333c2017-07-25 22:54:33985 }
986
Santiago Pastorinob39a1d62018-05-30 17:33:43987 cmd.arg("--src-base")
988 .arg(builder.src.join("src/test").join(suite));
989 cmd.arg("--build-base")
990 .arg(testdir(builder, compiler.host).join(suite));
991 cmd.arg("--stage-id")
992 .arg(format!("stage{}-{}", compiler.stage, target));
Mark Simulacrum001e9f32017-07-05 01:41:43993 cmd.arg("--mode").arg(mode);
994 cmd.arg("--target").arg(target);
Mark Simulacrum528646e2017-07-14 00:48:44995 cmd.arg("--host").arg(&*compiler.host);
Santiago Pastorinob39a1d62018-05-30 17:33:43996 cmd.arg("--llvm-filecheck")
997 .arg(builder.llvm_filecheck(builder.config.build));
Alex Crichtonf4e4ec72016-05-13 22:26:41998
Oliver Schneiderceed8eb2018-05-16 16:17:29999 if builder.config.cmd.bless() {
Oliver Schneider37dee692018-05-16 15:18:191000 cmd.arg("--bless");
1001 }
1002
Santiago Pastorinob970fee2018-05-28 22:44:331003 let compare_mode = builder.config.cmd.compare_mode().or(self.compare_mode);
1004
Mark Simulacrumbe1e7892018-04-14 23:27:571005 if let Some(ref nodejs) = builder.config.nodejs {
Mark Simulacrum001e9f32017-07-05 01:41:431006 cmd.arg("--nodejs").arg(nodejs);
1007 }
Alex Crichtonf4e4ec72016-05-13 22:26:411008
Guillaume Gomezb2192ae2018-04-01 19:06:351009 let mut flags = if is_rustdoc_ui {
1010 Vec::new()
1011 } else {
1012 vec!["-Crpath".to_string()]
1013 };
1014 if !is_rustdoc_ui {
Mark Simulacrumbe1e7892018-04-14 23:27:571015 if builder.config.rust_optimize_tests {
Guillaume Gomezb2192ae2018-04-01 19:06:351016 flags.push("-O".to_string());
1017 }
Mark Simulacrumbe1e7892018-04-14 23:27:571018 if builder.config.rust_debuginfo_tests {
Guillaume Gomezb2192ae2018-04-01 19:06:351019 flags.push("-g".to_string());
1020 }
Mark Simulacrum001e9f32017-07-05 01:41:431021 }
Guillaume Gomeza3ed2ab2018-04-15 11:05:141022 flags.push("-Zunstable-options".to_string());
Mark Simulacrumbe1e7892018-04-14 23:27:571023 flags.push(builder.config.cmd.rustc_args().join(" "));
Alex Crichtoncbe62922016-04-19 16:44:191024
Mark Simulacrumbe1e7892018-04-14 23:27:571025 if let Some(linker) = builder.linker(target) {
Oliver Schneideracdf83f2017-12-06 08:25:291026 cmd.arg("--linker").arg(linker);
1027 }
1028
1029 let hostflags = flags.clone();
Mark Simulacrum001e9f32017-07-05 01:41:431030 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
Alex Crichtoncbe62922016-04-19 16:44:191031
Oliver Schneideracdf83f2017-12-06 08:25:291032 let mut targetflags = flags.clone();
Santiago Pastorinob39a1d62018-05-30 17:33:431033 targetflags.push(format!(
1034 "-Lnative={}",
1035 builder.test_helpers_out(target).display()
1036 ));
Mark Simulacrum001e9f32017-07-05 01:41:431037 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
Alex Crichtonb325baf2016-04-05 18:34:231038
Mark Simulacrumbe1e7892018-04-14 23:27:571039 cmd.arg("--docck-python").arg(builder.python());
Alex Crichtonb325baf2016-04-05 18:34:231040
Mark Simulacrumbe1e7892018-04-14 23:27:571041 if builder.config.build.ends_with("apple-darwin") {
Mark Simulacrum001e9f32017-07-05 01:41:431042 // Force /usr/bin/python on macOS for LLDB tests because we're loading the
1043 // LLDB plugin's compiled module which only works with the system python
1044 // (namely not Homebrew-installed python)
1045 cmd.arg("--lldb-python").arg("/usr/bin/python");
1046 } else {
Mark Simulacrumbe1e7892018-04-14 23:27:571047 cmd.arg("--lldb-python").arg(builder.python());
Mark Simulacrum001e9f32017-07-05 01:41:431048 }
Alex Crichtonb325baf2016-04-05 18:34:231049
Mark Simulacrumbe1e7892018-04-14 23:27:571050 if let Some(ref gdb) = builder.config.gdb {
Mark Simulacrum001e9f32017-07-05 01:41:431051 cmd.arg("--gdb").arg(gdb);
1052 }
Mark Simulacrumbe1e7892018-04-14 23:27:571053 if let Some(ref vers) = builder.lldb_version {
Mark Simulacrum001e9f32017-07-05 01:41:431054 cmd.arg("--lldb-version").arg(vers);
1055 }
Mark Simulacrumbe1e7892018-04-14 23:27:571056 if let Some(ref dir) = builder.lldb_python_dir {
Mark Simulacrum001e9f32017-07-05 01:41:431057 cmd.arg("--lldb-python-dir").arg(dir);
1058 }
Alex Crichtonb325baf2016-04-05 18:34:231059
Collins Abitekaniza41ee6fe2018-04-12 11:49:311060 // Get paths from cmd args
1061 let paths = match &builder.config.cmd {
Santiago Pastorinob39a1d62018-05-30 17:33:431062 Subcommand::Test { ref paths, .. } => &paths[..],
1063 _ => &[],
Collins Abitekaniza41ee6fe2018-04-12 11:49:311064 };
1065
1066 // Get test-args by striping suite path
Santiago Pastorinob39a1d62018-05-30 17:33:431067 let mut test_args: Vec<&str> = paths
1068 .iter()
1069 .filter(|p| p.starts_with(suite_path) && p.is_file())
1070 .map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
1071 .collect();
Collins Abitekaniza41ee6fe2018-04-12 11:49:311072
1073 test_args.append(&mut builder.config.cmd.test_args());
1074
1075 cmd.args(&test_args);
Corey Farwellc8c6d2c2016-10-30 01:58:521076
Mark Simulacrumbe1e7892018-04-14 23:27:571077 if builder.is_verbose() {
Mark Simulacrum001e9f32017-07-05 01:41:431078 cmd.arg("--verbose");
1079 }
Alex Crichton126e09e2016-04-14 22:51:031080
Mark Simulacrumbe1e7892018-04-14 23:27:571081 if builder.config.quiet_tests {
Mark Simulacrum001e9f32017-07-05 01:41:431082 cmd.arg("--quiet");
1083 }
Alex Crichton1747ce22017-01-28 21:38:061084
Mark Simulacrumbe1e7892018-04-14 23:27:571085 if builder.config.llvm_enabled {
Alex Crichtonbe902e72018-03-05 17:47:541086 let llvm_config = builder.ensure(native::Llvm {
Mark Simulacrumbe1e7892018-04-14 23:27:571087 target: builder.config.build,
Alex Crichtonbe902e72018-03-05 17:47:541088 emscripten: false,
1089 });
Mark Simulacrumbe1e7892018-04-14 23:27:571090 if !builder.config.dry_run {
Mark Simulacrum0ce5cf02018-04-01 01:21:141091 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
1092 cmd.arg("--llvm-version").arg(llvm_version);
1093 }
Mark Simulacrumbe1e7892018-04-14 23:27:571094 if !builder.is_rust_llvm(target) {
bjorn30c97bbf2017-08-13 10:30:541095 cmd.arg("--system-llvm");
1096 }
1097
1098 // Only pass correct values for these flags for the `run-make` suite as it
1099 // requires that a C++ compiler was configured which isn't always the case.
Eric Hussa90a9632018-05-15 23:39:211100 if !builder.config.dry_run && suite == "run-make-fulldeps" {
bjorn30c97bbf2017-08-13 10:30:541101 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
1102 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
Santiago Pastorinob39a1d62018-05-30 17:33:431103 cmd.arg("--cc")
1104 .arg(builder.cc(target))
1105 .arg("--cxx")
1106 .arg(builder.cxx(target).unwrap())
1107 .arg("--cflags")
1108 .arg(builder.cflags(target).join(" "))
1109 .arg("--llvm-components")
1110 .arg(llvm_components.trim())
1111 .arg("--llvm-cxxflags")
1112 .arg(llvm_cxxflags.trim());
Mark Simulacrumbe1e7892018-04-14 23:27:571113 if let Some(ar) = builder.ar(target) {
Oliver Schneideracdf83f2017-12-06 08:25:291114 cmd.arg("--ar").arg(ar);
1115 }
bjorn30c97bbf2017-08-13 10:30:541116 }
1117 }
Eric Hussa90a9632018-05-15 23:39:211118 if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
Santiago Pastorinob39a1d62018-05-30 17:33:431119 builder.info(&format!(
1120 "Ignoring run-make test suite as they generally don't work without LLVM"
1121 ));
bjorn30c97bbf2017-08-13 10:30:541122 return;
1123 }
1124
Eric Hussa90a9632018-05-15 23:39:211125 if suite != "run-make-fulldeps" {
Santiago Pastorinob39a1d62018-05-30 17:33:431126 cmd.arg("--cc")
1127 .arg("")
1128 .arg("--cxx")
1129 .arg("")
1130 .arg("--cflags")
1131 .arg("")
1132 .arg("--llvm-components")
1133 .arg("")
1134 .arg("--llvm-cxxflags")
1135 .arg("");
Mark Simulacrum001e9f32017-07-05 01:41:431136 }
1137
Mark Simulacrumbe1e7892018-04-14 23:27:571138 if builder.remote_tested(target) {
Santiago Pastorinob39a1d62018-05-30 17:33:431139 cmd.arg("--remote-test-client")
1140 .arg(builder.tool_exe(Tool::RemoteTestClient));
Mark Simulacrum001e9f32017-07-05 01:41:431141 }
1142
1143 // Running a C compiler on MSVC requires a few env vars to be set, to be
1144 // sure to set them here.
1145 //
1146 // Note that if we encounter `PATH` we make sure to append to our own `PATH`
1147 // rather than stomp over it.
1148 if target.contains("msvc") {
Mark Simulacrumbe1e7892018-04-14 23:27:571149 for &(ref k, ref v) in builder.cc[&target].env() {
Mark Simulacrum001e9f32017-07-05 01:41:431150 if k != "PATH" {
1151 cmd.env(k, v);
1152 }
Alex Crichton126e09e2016-04-14 22:51:031153 }
1154 }
Mark Simulacrum001e9f32017-07-05 01:41:431155 cmd.env("RUSTC_BOOTSTRAP", "1");
Mark Simulacrumbe1e7892018-04-14 23:27:571156 builder.add_rust_test_threads(&mut cmd);
Mark Simulacrum001e9f32017-07-05 01:41:431157
Mark Simulacrumbe1e7892018-04-14 23:27:571158 if builder.config.sanitizers {
Mark Simulacrum001e9f32017-07-05 01:41:431159 cmd.env("SANITIZER_SUPPORT", "1");
1160 }
1161
Mark Simulacrumbe1e7892018-04-14 23:27:571162 if builder.config.profiler {
Mark Simulacrum001e9f32017-07-05 01:41:431163 cmd.env("PROFILER_SUPPORT", "1");
1164 }
1165
Mark Simulacrumbe1e7892018-04-14 23:27:571166 cmd.env("RUST_TEST_TMPDIR", builder.out.join("tmp"));
Alex Crichton884715c2018-01-22 15:29:241167
Mark Simulacrum001e9f32017-07-05 01:41:431168 cmd.arg("--adb-path").arg("adb");
1169 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
1170 if target.contains("android") {
1171 // Assume that cc for this target comes from the android sysroot
1172 cmd.arg("--android-cross-path")
Santiago Pastorinob39a1d62018-05-30 17:33:431173 .arg(builder.cc(target).parent().unwrap().parent().unwrap());
Mark Simulacrum001e9f32017-07-05 01:41:431174 } else {
1175 cmd.arg("--android-cross-path").arg("");
1176 }
1177
Mark Simulacrumbe1e7892018-04-14 23:27:571178 builder.ci_env.force_coloring_in_ci(&mut cmd);
Mark Simulacrum001e9f32017-07-05 01:41:431179
Mark Simulacrumbe1e7892018-04-14 23:27:571180 let _folder = builder.fold_output(|| format!("test_{}", suite));
Santiago Pastorinob39a1d62018-05-30 17:33:431181 builder.info(&format!(
1182 "Check compiletest suite={} mode={} ({} -> {})",
1183 suite, mode, &compiler.host, target
1184 ));
Mark Simulacrumbe1e7892018-04-14 23:27:571185 let _time = util::timeit(&builder);
1186 try_run(builder, &mut cmd);
Felix S. Klock II55895502018-04-11 15:15:591187
1188 if let Some(compare_mode) = compare_mode {
1189 cmd.arg("--compare-mode").arg(compare_mode);
1190 let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode));
Santiago Pastorinob39a1d62018-05-30 17:33:431191 builder.info(&format!(
1192 "Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
1193 suite, mode, compare_mode, &compiler.host, target
1194 ));
Felix S. Klock II55895502018-04-11 15:15:591195 let _time = util::timeit(&builder);
1196 try_run(builder, &mut cmd);
1197 }
Alex Crichton126e09e2016-04-14 22:51:031198 }
Alex Crichtonb325baf2016-04-05 18:34:231199}
Alex Crichtonede89442016-04-15 01:00:351200
Mark Simulacrum528646e2017-07-14 00:48:441201#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
kennytm0d300d42018-02-21 19:13:341202struct DocTest {
Mark Simulacrum528646e2017-07-14 00:48:441203 compiler: Compiler,
kennytm0d300d42018-02-21 19:13:341204 path: &'static str,
1205 name: &'static str,
1206 is_ext_doc: bool,
Mark Simulacruma5ab2ce2017-07-12 15:15:001207}
1208
kennytm0d300d42018-02-21 19:13:341209impl Step for DocTest {
Mark Simulacruma5ab2ce2017-07-12 15:15:001210 type Output = ();
Mark Simulacruma5ab2ce2017-07-12 15:15:001211 const ONLY_HOSTS: bool = true;
Alex Crichtonede89442016-04-15 01:00:351212
Mark Simulacrum56128fb2017-07-19 00:03:381213 fn should_run(run: ShouldRun) -> ShouldRun {
kennytm0d300d42018-02-21 19:13:341214 run.never()
Mark Simulacruma5ab2ce2017-07-12 15:15:001215 }
1216
1217 /// Run `rustdoc --test` for all documentation in `src/doc`.
1218 ///
1219 /// This will run all tests in our markdown documentation (e.g. the book)
1220 /// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
1221 /// `compiler`.
1222 fn run(self, builder: &Builder) {
Mark Simulacruma5ab2ce2017-07-12 15:15:001223 let compiler = self.compiler;
Mark Simulacrumceecd622017-07-12 16:12:471224
Santiago Pastorinob39a1d62018-05-30 17:33:431225 builder.ensure(compile::Test {
1226 compiler,
1227 target: compiler.host,
1228 });
Mark Simulacrumceecd622017-07-12 16:12:471229
Mark Simulacruma5ab2ce2017-07-12 15:15:001230 // Do a breadth-first traversal of the `src/doc` directory and just run
1231 // tests for all files that end in `*.md`
Mark Simulacrumbe1e7892018-04-14 23:27:571232 let mut stack = vec![builder.src.join(self.path)];
1233 let _time = util::timeit(&builder);
1234 let _folder = builder.fold_output(|| format!("test_{}", self.name));
Mark Simulacruma5ab2ce2017-07-12 15:15:001235
Mark Simulacruma7274472018-03-27 14:06:471236 let mut files = Vec::new();
Mark Simulacruma5ab2ce2017-07-12 15:15:001237 while let Some(p) = stack.pop() {
1238 if p.is_dir() {
1239 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
Santiago Pastorinob39a1d62018-05-30 17:33:431240 continue;
Mark Simulacruma5ab2ce2017-07-12 15:15:001241 }
1242
1243 if p.extension().and_then(|s| s.to_str()) != Some("md") {
1244 continue;
1245 }
1246
1247 // The nostarch directory in the book is for no starch, and so isn't
Mark Simulacrumbe1e7892018-04-14 23:27:571248 // guaranteed to builder. We don't care if it doesn't build, so skip it.
Mark Simulacruma5ab2ce2017-07-12 15:15:001249 if p.to_str().map_or(false, |p| p.contains("nostarch")) {
1250 continue;
1251 }
1252
Mark Simulacruma7274472018-03-27 14:06:471253 files.push(p);
1254 }
1255
1256 files.sort();
1257
1258 for file in files {
1259 let test_result = markdown_test(builder, compiler, &file);
kennytma9f940e2018-02-21 19:25:231260 if self.is_ext_doc {
1261 let toolstate = if test_result {
1262 ToolState::TestPass
1263 } else {
1264 ToolState::TestFail
1265 };
Mark Simulacrumbe1e7892018-04-14 23:27:571266 builder.save_toolstate(self.name, toolstate);
kennytma9f940e2018-02-21 19:25:231267 }
Alex Crichtonede89442016-04-15 01:00:351268 }
Alex Crichtonede89442016-04-15 01:00:351269 }
1270}
1271
kennytm0d300d42018-02-21 19:13:341272macro_rules! test_book {
1273 ($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => {
1274 $(
1275 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1276 pub struct $name {
1277 compiler: Compiler,
1278 }
1279
1280 impl Step for $name {
1281 type Output = ();
1282 const DEFAULT: bool = $default;
1283 const ONLY_HOSTS: bool = true;
1284
1285 fn should_run(run: ShouldRun) -> ShouldRun {
1286 run.path($path)
1287 }
1288
1289 fn make_run(run: RunConfig) {
1290 run.builder.ensure($name {
1291 compiler: run.builder.compiler(run.builder.top_stage, run.host),
1292 });
1293 }
1294
1295 fn run(self, builder: &Builder) {
1296 builder.ensure(DocTest {
1297 compiler: self.compiler,
1298 path: $path,
1299 name: $book_name,
1300 is_ext_doc: !$default,
1301 });
1302 }
1303 }
1304 )+
1305 }
1306}
1307
1308test_book!(
1309 Nomicon, "src/doc/nomicon", "nomicon", default=false;
1310 Reference, "src/doc/reference", "reference", default=false;
1311 RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
steveklabnikb99418d2018-04-05 18:41:481312 RustcBook, "src/doc/rustc", "rustc", default=true;
kennytm0d300d42018-02-21 19:13:341313 RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
1314 TheBook, "src/doc/book", "book", default=false;
1315 UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
1316);
1317
Mark Simulacrum528646e2017-07-14 00:48:441318#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1319pub struct ErrorIndex {
1320 compiler: Compiler,
Mark Simulacrum001e9f32017-07-05 01:41:431321}
Alex Crichton0e272de2016-11-16 20:31:191322
Mark Simulacrum528646e2017-07-14 00:48:441323impl Step for ErrorIndex {
Mark Simulacrum001e9f32017-07-05 01:41:431324 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271325 const DEFAULT: bool = true;
1326 const ONLY_HOSTS: bool = true;
1327
Mark Simulacrum56128fb2017-07-19 00:03:381328 fn should_run(run: ShouldRun) -> ShouldRun {
1329 run.path("src/tools/error_index_generator")
Mark Simulacrum6b3413d2017-07-05 12:41:271330 }
1331
Mark Simulacrum6a67a052017-07-20 23:51:071332 fn make_run(run: RunConfig) {
1333 run.builder.ensure(ErrorIndex {
1334 compiler: run.builder.compiler(run.builder.top_stage, run.host),
Mark Simulacrum6b3413d2017-07-05 12:41:271335 });
1336 }
Alex Crichtonede89442016-04-15 01:00:351337
Mark Simulacrum001e9f32017-07-05 01:41:431338 /// Run the error index generator tool to execute the tests located in the error
1339 /// index.
1340 ///
1341 /// The `error_index_generator` tool lives in `src/tools` and is used to
1342 /// generate a markdown file from the error indexes of the code base which is
1343 /// then passed to `rustdoc --test`.
1344 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:431345 let compiler = self.compiler;
1346
Santiago Pastorinob39a1d62018-05-30 17:33:431347 builder.ensure(compile::Std {
1348 compiler,
1349 target: compiler.host,
1350 });
Mark Simulacrum6b3413d2017-07-05 12:41:271351
Mark Simulacrumbe1e7892018-04-14 23:27:571352 let dir = testdir(builder, compiler.host);
Mark Simulacrum001e9f32017-07-05 01:41:431353 t!(fs::create_dir_all(&dir));
1354 let output = dir.join("error-index.md");
1355
Alex Crichton6fd4d672018-03-16 15:35:031356 let mut tool = builder.tool_cmd(Tool::ErrorIndex);
1357 tool.arg("markdown")
1358 .arg(&output)
Mark Simulacrumbe1e7892018-04-14 23:27:571359 .env("CFG_BUILD", &builder.config.build)
1360 .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
Mark Simulacrum001e9f32017-07-05 01:41:431361
Mark Simulacrumbe1e7892018-04-14 23:27:571362 let _folder = builder.fold_output(|| "test_error_index");
1363 builder.info(&format!("Testing error-index stage{}", compiler.stage));
1364 let _time = util::timeit(&builder);
1365 builder.run(&mut tool);
Mark Simulacrumc114fe52017-07-05 17:21:331366 markdown_test(builder, compiler, &output);
Mark Simulacrum001e9f32017-07-05 01:41:431367 }
Alex Crichtonede89442016-04-15 01:00:351368}
1369
kennytma9f940e2018-02-21 19:25:231370fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool {
Mark Simulacrum0ce5cf02018-04-01 01:21:141371 match File::open(markdown) {
1372 Ok(mut file) => {
1373 let mut contents = String::new();
1374 t!(file.read_to_string(&mut contents));
1375 if !contents.contains("```") {
1376 return true;
1377 }
1378 }
Santiago Pastorinob39a1d62018-05-30 17:33:431379 Err(_) => {}
Mark Simulacrumdd1d75e2017-06-04 23:55:501380 }
1381
Mark Simulacrumbe1e7892018-04-14 23:27:571382 builder.info(&format!("doc tests for: {}", markdown.display()));
Mark Simulacrumfacf5a92017-08-04 22:13:011383 let mut cmd = builder.rustdoc_cmd(compiler.host);
Mark Simulacrumbe1e7892018-04-14 23:27:571384 builder.add_rust_test_threads(&mut cmd);
Alex Crichtonede89442016-04-15 01:00:351385 cmd.arg("--test");
1386 cmd.arg(markdown);
Alex Crichton6f62fae2016-12-12 17:03:351387 cmd.env("RUSTC_BOOTSTRAP", "1");
Corey Farwellc8c6d2c2016-10-30 01:58:521388
Mark Simulacrumbe1e7892018-04-14 23:27:571389 let test_args = builder.config.cmd.test_args().join(" ");
Corey Farwellc8c6d2c2016-10-30 01:58:521390 cmd.arg("--test-args").arg(test_args);
1391
Mark Simulacrumbe1e7892018-04-14 23:27:571392 if builder.config.quiet_tests {
1393 try_run_quiet(builder, &mut cmd)
kennytm6ac07872017-05-21 20:27:471394 } else {
Mark Simulacrumbe1e7892018-04-14 23:27:571395 try_run(builder, &mut cmd)
kennytm6ac07872017-05-21 20:27:471396 }
Alex Crichtonede89442016-04-15 01:00:351397}
Alex Crichtonbb9062a2016-04-29 21:23:151398
Mark Simulacrum528646e2017-07-14 00:48:441399#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum981afa52017-07-18 21:28:531400pub struct CrateLibrustc {
Mark Simulacrum528646e2017-07-14 00:48:441401 compiler: Compiler,
1402 target: Interned<String>,
Mark Simulacrum6b3413d2017-07-05 12:41:271403 test_kind: TestKind,
Mark Simulacrumf104b122018-02-11 16:51:581404 krate: Interned<String>,
Mark Simulacrum6b3413d2017-07-05 12:41:271405}
1406
Mark Simulacrum981afa52017-07-18 21:28:531407impl Step for CrateLibrustc {
Mark Simulacrum6b3413d2017-07-05 12:41:271408 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271409 const DEFAULT: bool = true;
1410 const ONLY_HOSTS: bool = true;
1411
Mark Simulacrum56128fb2017-07-19 00:03:381412 fn should_run(run: ShouldRun) -> ShouldRun {
1413 run.krate("rustc-main")
Mark Simulacrum6b3413d2017-07-05 12:41:271414 }
1415
Mark Simulacrum6a67a052017-07-20 23:51:071416 fn make_run(run: RunConfig) {
1417 let builder = run.builder;
1418 let compiler = builder.compiler(builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:271419
Mark Simulacrumf104b122018-02-11 16:51:581420 for krate in builder.in_tree_crates("rustc-main") {
1421 if run.path.ends_with(&krate.path) {
Oliver Schneider37dee692018-05-16 15:18:191422 let test_kind = builder.kind.into();
Mark Simulacrum6b3413d2017-07-05 12:41:271423
Mark Simulacrumf104b122018-02-11 16:51:581424 builder.ensure(CrateLibrustc {
1425 compiler,
1426 target: run.target,
1427 test_kind,
1428 krate: krate.name,
1429 });
Mark Simulacrum6b3413d2017-07-05 12:41:271430 }
Mark Simulacrum6b3413d2017-07-05 12:41:271431 }
1432 }
1433
Mark Simulacrum6b3413d2017-07-05 12:41:271434 fn run(self, builder: &Builder) {
Mark Simulacrum981afa52017-07-18 21:28:531435 builder.ensure(Crate {
Mark Simulacrum6b3413d2017-07-05 12:41:271436 compiler: self.compiler,
1437 target: self.target,
1438 mode: Mode::Librustc,
1439 test_kind: self.test_kind,
1440 krate: self.krate,
1441 });
1442 }
1443}
1444
Mark Simulacrum528646e2017-07-14 00:48:441445#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrumf104b122018-02-11 16:51:581446pub struct CrateNotDefault {
Mark Simulacrum528646e2017-07-14 00:48:441447 compiler: Compiler,
1448 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431449 test_kind: TestKind,
Mark Simulacrumf104b122018-02-11 16:51:581450 krate: &'static str,
Mark Simulacrum001e9f32017-07-05 01:41:431451}
Alex Crichtonbb9062a2016-04-29 21:23:151452
Mark Simulacrumf104b122018-02-11 16:51:581453impl Step for CrateNotDefault {
Mark Simulacrum001e9f32017-07-05 01:41:431454 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271455
Mark Simulacrum56128fb2017-07-19 00:03:381456 fn should_run(run: ShouldRun) -> ShouldRun {
Mark Simulacrumf104b122018-02-11 16:51:581457 run.path("src/liballoc_jemalloc")
1458 .path("src/librustc_asan")
1459 .path("src/librustc_lsan")
1460 .path("src/librustc_msan")
1461 .path("src/librustc_tsan")
Mark Simulacrum6b3413d2017-07-05 12:41:271462 }
1463
Mark Simulacrum6a67a052017-07-20 23:51:071464 fn make_run(run: RunConfig) {
1465 let builder = run.builder;
1466 let compiler = builder.compiler(builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:271467
Oliver Schneider37dee692018-05-16 15:18:191468 let test_kind = builder.kind.into();
Mark Simulacrumf104b122018-02-11 16:51:581469
1470 builder.ensure(CrateNotDefault {
1471 compiler,
1472 target: run.target,
1473 test_kind,
1474 krate: match run.path {
1475 _ if run.path.ends_with("src/liballoc_jemalloc") => "alloc_jemalloc",
1476 _ if run.path.ends_with("src/librustc_asan") => "rustc_asan",
1477 _ if run.path.ends_with("src/librustc_lsan") => "rustc_lsan",
1478 _ if run.path.ends_with("src/librustc_msan") => "rustc_msan",
1479 _ if run.path.ends_with("src/librustc_tsan") => "rustc_tsan",
1480 _ => panic!("unexpected path {:?}", run.path),
1481 },
1482 });
1483 }
1484
1485 fn run(self, builder: &Builder) {
1486 builder.ensure(Crate {
1487 compiler: self.compiler,
1488 target: self.target,
1489 mode: Mode::Libstd,
1490 test_kind: self.test_kind,
1491 krate: INTERNER.intern_str(self.krate),
1492 });
1493 }
1494}
1495
kennytmbe9d6692018-05-05 18:33:011496#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Mark Simulacrumf104b122018-02-11 16:51:581497pub struct Crate {
kennytmbe9d6692018-05-05 18:33:011498 pub compiler: Compiler,
1499 pub target: Interned<String>,
1500 pub mode: Mode,
1501 pub test_kind: TestKind,
1502 pub krate: Interned<String>,
Mark Simulacrumf104b122018-02-11 16:51:581503}
1504
1505impl Step for Crate {
1506 type Output = ();
1507 const DEFAULT: bool = true;
1508
1509 fn should_run(mut run: ShouldRun) -> ShouldRun {
1510 let builder = run.builder;
1511 run = run.krate("test");
1512 for krate in run.builder.in_tree_crates("std") {
Santiago Pastorinob39a1d62018-05-30 17:33:431513 if krate.is_local(&run.builder)
1514 && !krate.name.contains("jemalloc")
1515 && !(krate.name.starts_with("rustc_") && krate.name.ends_with("san"))
1516 && krate.name != "dlmalloc"
1517 {
Mark Simulacrumf104b122018-02-11 16:51:581518 run = run.path(krate.local_path(&builder).to_str().unwrap());
1519 }
1520 }
1521 run
1522 }
1523
1524 fn make_run(run: RunConfig) {
1525 let builder = run.builder;
1526 let compiler = builder.compiler(builder.top_stage, run.host);
1527
1528 let make = |mode: Mode, krate: &CargoCrate| {
Oliver Schneider37dee692018-05-16 15:18:191529 let test_kind = builder.kind.into();
Mark Simulacrum6b3413d2017-07-05 12:41:271530
Mark Simulacrum981afa52017-07-18 21:28:531531 builder.ensure(Crate {
Mark Simulacrum6a67a052017-07-20 23:51:071532 compiler,
1533 target: run.target,
Zack M. Davis1b6c9602017-08-07 05:54:091534 mode,
1535 test_kind,
Mark Simulacrumf104b122018-02-11 16:51:581536 krate: krate.name,
Mark Simulacrum6b3413d2017-07-05 12:41:271537 });
1538 };
1539
Mark Simulacrumf104b122018-02-11 16:51:581540 for krate in builder.in_tree_crates("std") {
1541 if run.path.ends_with(&krate.local_path(&builder)) {
1542 make(Mode::Libstd, krate);
Mark Simulacrum6b3413d2017-07-05 12:41:271543 }
Mark Simulacrumf104b122018-02-11 16:51:581544 }
1545 for krate in builder.in_tree_crates("test") {
1546 if run.path.ends_with(&krate.local_path(&builder)) {
1547 make(Mode::Libtest, krate);
Mark Simulacrum6b3413d2017-07-05 12:41:271548 }
Mark Simulacrum6b3413d2017-07-05 12:41:271549 }
1550 }
Alex Crichton7046fea2016-12-25 23:20:331551
Mark Simulacrumf104b122018-02-11 16:51:581552 /// Run all unit tests plus documentation tests for a given crate defined
1553 /// by a `Cargo.toml` (single manifest)
Mark Simulacrum001e9f32017-07-05 01:41:431554 ///
1555 /// This is what runs tests for crates like the standard library, compiler, etc.
1556 /// It essentially is the driver for running `cargo test`.
1557 ///
1558 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
1559 /// arguments, and those arguments are discovered from `cargo metadata`.
1560 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:431561 let compiler = self.compiler;
1562 let target = self.target;
1563 let mode = self.mode;
1564 let test_kind = self.test_kind;
1565 let krate = self.krate;
Alex Crichtonbb9062a2016-04-29 21:23:151566
Mark Simulacrum6b3413d2017-07-05 12:41:271567 builder.ensure(compile::Test { compiler, target });
1568 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431569
1570 // If we're not doing a full bootstrap but we're testing a stage2 version of
1571 // libstd, then what we're actually testing is the libstd produced in
1572 // stage1. Reflect that here by updating the compiler that we're working
1573 // with automatically.
Mark Simulacrumbe1e7892018-04-14 23:27:571574 let compiler = if builder.force_use_stage1(compiler, target) {
Mark Simulacrum6b3413d2017-07-05 12:41:271575 builder.compiler(1, compiler.host)
Mark Simulacrum001e9f32017-07-05 01:41:431576 } else {
1577 compiler.clone()
1578 };
1579
Alex Crichton90105672017-07-17 16:32:081580 let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
Mark Simulacrumf104b122018-02-11 16:51:581581 match mode {
Alex Crichton90105672017-07-17 16:32:081582 Mode::Libstd => {
Alex Crichtonbe902e72018-03-05 17:47:541583 compile::std_cargo(builder, &compiler, target, &mut cargo);
Alex Crichton90105672017-07-17 16:32:081584 }
1585 Mode::Libtest => {
Mark Simulacrumbe1e7892018-04-14 23:27:571586 compile::test_cargo(builder, &compiler, target, &mut cargo);
Alex Crichton90105672017-07-17 16:32:081587 }
1588 Mode::Librustc => {
1589 builder.ensure(compile::Rustc { compiler, target });
Mark Simulacrumbe1e7892018-04-14 23:27:571590 compile::rustc_cargo(builder, &mut cargo);
Alex Crichton90105672017-07-17 16:32:081591 }
1592 _ => panic!("can only test libraries"),
1593 };
Alex Crichton90105672017-07-17 16:32:081594
Mark Simulacrum001e9f32017-07-05 01:41:431595 // Build up the base `cargo test` command.
1596 //
1597 // Pass in some standard flags then iterate over the graph we've discovered
1598 // in `cargo metadata` with the maps above and figure out what `-p`
1599 // arguments need to get passed.
Mark Simulacrumbe1e7892018-04-14 23:27:571600 if test_kind.subcommand() == "test" && !builder.fail_fast {
Mark Simulacrum001e9f32017-07-05 01:41:431601 cargo.arg("--no-fail-fast");
Alex Crichtonbb9062a2016-04-29 21:23:151602 }
kennytm1733f5e2018-05-05 16:04:061603 match builder.doc_tests {
kennytm05af55b2018-05-05 19:30:421604 DocTests::Only => {
kennytm1733f5e2018-05-05 16:04:061605 cargo.arg("--doc");
1606 }
kennytm05af55b2018-05-05 19:30:421607 DocTests::No => {
kennytm1733f5e2018-05-05 16:04:061608 cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
1609 }
kennytm05af55b2018-05-05 19:30:421610 DocTests::Yes => {}
Guillaume Gomez8e469272018-02-17 14:45:391611 }
Mark Simulacrum001e9f32017-07-05 01:41:431612
Mark Simulacrumf104b122018-02-11 16:51:581613 cargo.arg("-p").arg(krate);
Alex Crichtonbb9062a2016-04-29 21:23:151614
Mark Simulacrum001e9f32017-07-05 01:41:431615 // The tests are going to run with the *target* libraries, so we need to
1616 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
1617 //
1618 // Note that to run the compiler we need to run with the *host* libraries,
1619 // but our wrapper scripts arrange for that to be the case anyway.
1620 let mut dylib_path = dylib_path();
Mark Simulacrum528646e2017-07-14 00:48:441621 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
Mark Simulacrum001e9f32017-07-05 01:41:431622 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
Alex Crichtonbb9062a2016-04-29 21:23:151623
Mark Simulacrum001e9f32017-07-05 01:41:431624 cargo.arg("--");
Mark Simulacrumbe1e7892018-04-14 23:27:571625 cargo.args(&builder.config.cmd.test_args());
Alex Crichton0e272de2016-11-16 20:31:191626
Mark Simulacrumbe1e7892018-04-14 23:27:571627 if builder.config.quiet_tests {
Mark Simulacrum001e9f32017-07-05 01:41:431628 cargo.arg("--quiet");
1629 }
Corey Farwellc8c6d2c2016-10-30 01:58:521630
Mark Simulacrum001e9f32017-07-05 01:41:431631 if target.contains("emscripten") {
Santiago Pastorinob39a1d62018-05-30 17:33:431632 cargo.env(
1633 format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1634 builder
1635 .config
1636 .nodejs
1637 .as_ref()
1638 .expect("nodejs not configured"),
1639 );
Oliver Schneideracdf83f2017-12-06 08:25:291640 } else if target.starts_with("wasm32") {
Diggory Blake0e6601f2018-01-11 17:51:491641 // Warn about running tests without the `wasm_syscall` feature enabled.
1642 // The javascript shim implements the syscall interface so that test
1643 // output can be correctly reported.
Mark Simulacrumbe1e7892018-04-14 23:27:571644 if !builder.config.wasm_syscall {
Santiago Pastorinob39a1d62018-05-30 17:33:431645 builder.info(&format!(
1646 "Libstd was built without `wasm_syscall` feature enabled: \
1647 test output may not be visible."
1648 ));
Diggory Blake0e6601f2018-01-11 17:51:491649 }
1650
Oliver Schneideracdf83f2017-12-06 08:25:291651 // On the wasm32-unknown-unknown target we're using LTO which is
1652 // incompatible with `-C prefer-dynamic`, so disable that here
1653 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
1654
Santiago Pastorinob39a1d62018-05-30 17:33:431655 let node = builder
1656 .config
1657 .nodejs
1658 .as_ref()
Oliver Schneideracdf83f2017-12-06 08:25:291659 .expect("nodejs not configured");
Santiago Pastorinob39a1d62018-05-30 17:33:431660 let runner = format!(
1661 "{} {}/src/etc/wasm32-shim.js",
1662 node.display(),
1663 builder.src.display()
1664 );
Oliver Schneideracdf83f2017-12-06 08:25:291665 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner);
Mark Simulacrumbe1e7892018-04-14 23:27:571666 } else if builder.remote_tested(target) {
Santiago Pastorinob39a1d62018-05-30 17:33:431667 cargo.env(
1668 format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1669 format!("{} run", builder.tool_exe(Tool::RemoteTestClient).display()),
1670 );
Mark Simulacrum001e9f32017-07-05 01:41:431671 }
Alex Crichton6fd4d672018-03-16 15:35:031672
Mark Simulacrumbe1e7892018-04-14 23:27:571673 let _folder = builder.fold_output(|| {
Santiago Pastorinob39a1d62018-05-30 17:33:431674 format!(
1675 "{}_stage{}-{}",
1676 test_kind.subcommand(),
1677 compiler.stage,
1678 krate
1679 )
Alex Crichton6fd4d672018-03-16 15:35:031680 });
Santiago Pastorinob39a1d62018-05-30 17:33:431681 builder.info(&format!(
1682 "{} {} stage{} ({} -> {})",
1683 test_kind, krate, compiler.stage, &compiler.host, target
1684 ));
Mark Simulacrumbe1e7892018-04-14 23:27:571685 let _time = util::timeit(&builder);
1686 try_run(builder, &mut cargo);
Alex Crichton39a5d3f2016-06-28 20:31:301687 }
1688}
1689
Mark Simulacrumf87696b2017-09-02 14:02:321690#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrumf104b122018-02-11 16:51:581691pub struct CrateRustdoc {
Mark Simulacrumf87696b2017-09-02 14:02:321692 host: Interned<String>,
1693 test_kind: TestKind,
1694}
1695
Mark Simulacrumf104b122018-02-11 16:51:581696impl Step for CrateRustdoc {
Mark Simulacrumf87696b2017-09-02 14:02:321697 type Output = ();
1698 const DEFAULT: bool = true;
1699 const ONLY_HOSTS: bool = true;
1700
1701 fn should_run(run: ShouldRun) -> ShouldRun {
Mark Simulacrumf104b122018-02-11 16:51:581702 run.paths(&["src/librustdoc", "src/tools/rustdoc"])
Mark Simulacrumf87696b2017-09-02 14:02:321703 }
1704
1705 fn make_run(run: RunConfig) {
1706 let builder = run.builder;
1707
Oliver Schneider37dee692018-05-16 15:18:191708 let test_kind = builder.kind.into();
Mark Simulacrumf87696b2017-09-02 14:02:321709
Mark Simulacrumf104b122018-02-11 16:51:581710 builder.ensure(CrateRustdoc {
Mark Simulacrumf87696b2017-09-02 14:02:321711 host: run.host,
1712 test_kind,
1713 });
1714 }
1715
1716 fn run(self, builder: &Builder) {
Mark Simulacrumf87696b2017-09-02 14:02:321717 let test_kind = self.test_kind;
1718
1719 let compiler = builder.compiler(builder.top_stage, self.host);
1720 let target = compiler.host;
1721
Santiago Pastorinob39a1d62018-05-30 17:33:431722 let mut cargo = tool::prepare_tool_cargo(
1723 builder,
1724 compiler,
1725 target,
1726 test_kind.subcommand(),
1727 "src/tools/rustdoc",
1728 );
Mark Simulacrumbe1e7892018-04-14 23:27:571729 if test_kind.subcommand() == "test" && !builder.fail_fast {
Mark Simulacrumf87696b2017-09-02 14:02:321730 cargo.arg("--no-fail-fast");
1731 }
1732
1733 cargo.arg("-p").arg("rustdoc:0.0.0");
1734
1735 cargo.arg("--");
Mark Simulacrumbe1e7892018-04-14 23:27:571736 cargo.args(&builder.config.cmd.test_args());
Mark Simulacrumf87696b2017-09-02 14:02:321737
Mark Simulacrumbe1e7892018-04-14 23:27:571738 if builder.config.quiet_tests {
Mark Simulacrumf87696b2017-09-02 14:02:321739 cargo.arg("--quiet");
1740 }
1741
Santiago Pastorinob39a1d62018-05-30 17:33:431742 let _folder = builder
1743 .fold_output(|| format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage));
1744 builder.info(&format!(
1745 "{} rustdoc stage{} ({} -> {})",
1746 test_kind, compiler.stage, &compiler.host, target
1747 ));
Mark Simulacrumbe1e7892018-04-14 23:27:571748 let _time = util::timeit(&builder);
Mark Simulacrumf87696b2017-09-02 14:02:321749
Mark Simulacrumbe1e7892018-04-14 23:27:571750 try_run(builder, &mut cargo);
Mark Simulacrumf87696b2017-09-02 14:02:321751 }
1752}
1753
Alex Crichton8e7849e2017-07-29 00:52:441754fn envify(s: &str) -> String {
Santiago Pastorinob39a1d62018-05-30 17:33:431755 s.chars()
1756 .map(|c| match c {
Alex Crichton8e7849e2017-07-29 00:52:441757 '-' => '_',
1758 c => c,
Santiago Pastorinob39a1d62018-05-30 17:33:431759 })
1760 .flat_map(|c| c.to_uppercase())
1761 .collect()
Alex Crichton39a5d3f2016-06-28 20:31:301762}
1763
Mark Simulacrumceecd622017-07-12 16:12:471764/// Some test suites are run inside emulators or on remote devices, and most
1765/// of our test binaries are linked dynamically which means we need to ship
1766/// the standard library and such to the emulator ahead of time. This step
1767/// represents this and is a dependency of all test suites.
1768///
1769/// Most of the time this is a noop. For some steps such as shipping data to
1770/// QEMU we have to build our own tools so we've got conditional dependencies
1771/// on those programs as well. Note that the remote test client is built for
1772/// the build target (us) and the server is built for the target.
Mark Simulacrum528646e2017-07-14 00:48:441773#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1774pub struct RemoteCopyLibs {
1775 compiler: Compiler,
1776 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431777}
Alex Crichton1747ce22017-01-28 21:38:061778
Mark Simulacrum528646e2017-07-14 00:48:441779impl Step for RemoteCopyLibs {
Mark Simulacrum001e9f32017-07-05 01:41:431780 type Output = ();
Alex Crichton1747ce22017-01-28 21:38:061781
Mark Simulacrum56128fb2017-07-19 00:03:381782 fn should_run(run: ShouldRun) -> ShouldRun {
1783 run.never()
Mark Simulacrum681b1232017-07-14 12:30:161784 }
1785
Mark Simulacrum001e9f32017-07-05 01:41:431786 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:431787 let compiler = self.compiler;
1788 let target = self.target;
Mark Simulacrumbe1e7892018-04-14 23:27:571789 if !builder.remote_tested(target) {
Santiago Pastorinob39a1d62018-05-30 17:33:431790 return;
Mark Simulacrum001e9f32017-07-05 01:41:431791 }
Alex Crichton1747ce22017-01-28 21:38:061792
Mark Simulacrum6b3413d2017-07-05 12:41:271793 builder.ensure(compile::Test { compiler, target });
1794
Mark Simulacrumbe1e7892018-04-14 23:27:571795 builder.info(&format!("REMOTE copy libs to emulator ({})", target));
1796 t!(fs::create_dir_all(builder.out.join("tmp")));
Mark Simulacrum001e9f32017-07-05 01:41:431797
Mark Simulacrumfe0eca02017-07-23 01:29:081798 let server = builder.ensure(tool::RemoteTestServer { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431799
1800 // Spawn the emulator and wait for it to come online
Mark Simulacrum6b3413d2017-07-05 12:41:271801 let tool = builder.tool_exe(Tool::RemoteTestClient);
Mark Simulacrum001e9f32017-07-05 01:41:431802 let mut cmd = Command::new(&tool);
1803 cmd.arg("spawn-emulator")
Santiago Pastorinob39a1d62018-05-30 17:33:431804 .arg(target)
1805 .arg(&server)
1806 .arg(builder.out.join("tmp"));
Mark Simulacrumbe1e7892018-04-14 23:27:571807 if let Some(rootfs) = builder.qemu_rootfs(target) {
Mark Simulacrum001e9f32017-07-05 01:41:431808 cmd.arg(rootfs);
1809 }
Mark Simulacrumbe1e7892018-04-14 23:27:571810 builder.run(&mut cmd);
Mark Simulacrum001e9f32017-07-05 01:41:431811
1812 // Push all our dylibs to the emulator
Mark Simulacrum60388302017-07-05 16:46:411813 for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
Mark Simulacrum001e9f32017-07-05 01:41:431814 let f = t!(f);
1815 let name = f.file_name().into_string().unwrap();
1816 if util::is_dylib(&name) {
Santiago Pastorinob39a1d62018-05-30 17:33:431817 builder.run(Command::new(&tool).arg("push").arg(f.path()));
Mark Simulacrum001e9f32017-07-05 01:41:431818 }
Alex Crichton1747ce22017-01-28 21:38:061819 }
1820 }
1821}
1822
Mark Simulacrum528646e2017-07-14 00:48:441823#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431824pub struct Distcheck;
1825
Mark Simulacrum528646e2017-07-14 00:48:441826impl Step for Distcheck {
Mark Simulacrum001e9f32017-07-05 01:41:431827 type Output = ();
1828
Mark Simulacrum56128fb2017-07-19 00:03:381829 fn should_run(run: ShouldRun) -> ShouldRun {
1830 run.path("distcheck")
Mark Simulacrum681b1232017-07-14 12:30:161831 }
1832
Mark Simulacrum8f2e5762017-07-22 13:35:421833 fn make_run(run: RunConfig) {
1834 run.builder.ensure(Distcheck);
1835 }
1836
Mark Simulacrum001e9f32017-07-05 01:41:431837 /// Run "distcheck", a 'make check' from a tarball
1838 fn run(self, builder: &Builder) {
Mark Simulacrumbe1e7892018-04-14 23:27:571839 builder.info(&format!("Distcheck"));
1840 let dir = builder.out.join("tmp").join("distcheck");
Mark Simulacrum001e9f32017-07-05 01:41:431841 let _ = fs::remove_dir_all(&dir);
1842 t!(fs::create_dir_all(&dir));
1843
Mark Simulacrum1c118232017-07-22 16:48:291844 // Guarantee that these are built before we begin running.
1845 builder.ensure(dist::PlainSourceTarball);
1846 builder.ensure(dist::Src);
1847
Mark Simulacrum001e9f32017-07-05 01:41:431848 let mut cmd = Command::new("tar");
1849 cmd.arg("-xzf")
Santiago Pastorinob39a1d62018-05-30 17:33:431850 .arg(builder.ensure(dist::PlainSourceTarball))
1851 .arg("--strip-components=1")
1852 .current_dir(&dir);
Mark Simulacrumbe1e7892018-04-14 23:27:571853 builder.run(&mut cmd);
Santiago Pastorinob39a1d62018-05-30 17:33:431854 builder.run(
1855 Command::new("./configure")
1856 .args(&builder.config.configure_args)
1857 .arg("--enable-vendor")
1858 .current_dir(&dir),
1859 );
1860 builder.run(
1861 Command::new(build_helper::make(&builder.config.build))
1862 .arg("check")
1863 .current_dir(&dir),
1864 );
Mark Simulacrum001e9f32017-07-05 01:41:431865
1866 // Now make sure that rust-src has all of libstd's dependencies
Mark Simulacrumbe1e7892018-04-14 23:27:571867 builder.info(&format!("Distcheck rust-src"));
1868 let dir = builder.out.join("tmp").join("distcheck-src");
Mark Simulacrum001e9f32017-07-05 01:41:431869 let _ = fs::remove_dir_all(&dir);
1870 t!(fs::create_dir_all(&dir));
1871
1872 let mut cmd = Command::new("tar");
1873 cmd.arg("-xzf")
Santiago Pastorinob39a1d62018-05-30 17:33:431874 .arg(builder.ensure(dist::Src))
1875 .arg("--strip-components=1")
1876 .current_dir(&dir);
Mark Simulacrumbe1e7892018-04-14 23:27:571877 builder.run(&mut cmd);
Mark Simulacrum001e9f32017-07-05 01:41:431878
1879 let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
Santiago Pastorinob39a1d62018-05-30 17:33:431880 builder.run(
1881 Command::new(&builder.initial_cargo)
1882 .arg("generate-lockfile")
1883 .arg("--manifest-path")
1884 .arg(&toml)
1885 .current_dir(&dir),
1886 );
Alex Crichtond38db822016-12-09 01:13:551887 }
Alex Crichtond38db822016-12-09 01:13:551888}
Alex Crichton1a040b32016-12-31 03:50:571889
Mark Simulacrum528646e2017-07-14 00:48:441890#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431891pub struct Bootstrap;
1892
Mark Simulacrum528646e2017-07-14 00:48:441893impl Step for Bootstrap {
Mark Simulacrum001e9f32017-07-05 01:41:431894 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271895 const DEFAULT: bool = true;
1896 const ONLY_HOSTS: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:431897
1898 /// Test the build system itself
1899 fn run(self, builder: &Builder) {
Mark Simulacrumbe1e7892018-04-14 23:27:571900 let mut cmd = Command::new(&builder.initial_cargo);
Mark Simulacrum001e9f32017-07-05 01:41:431901 cmd.arg("test")
Santiago Pastorinob39a1d62018-05-30 17:33:431902 .current_dir(builder.src.join("src/bootstrap"))
1903 .env("RUSTFLAGS", "-Cdebuginfo=2")
1904 .env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
1905 .env("RUSTC_BOOTSTRAP", "1")
1906 .env("RUSTC", &builder.initial_rustc);
Simon Sapine993e622018-03-23 18:55:411907 if let Some(flags) = option_env!("RUSTFLAGS") {
1908 // Use the same rustc flags for testing as for "normal" compilation,
1909 // so that Cargo doesn’t recompile the entire dependency graph every time:
1910 // https://github.com/rust-lang/rust/issues/49215
1911 cmd.env("RUSTFLAGS", flags);
1912 }
Mark Simulacrumbe1e7892018-04-14 23:27:571913 if !builder.fail_fast {
Mark Simulacrum001e9f32017-07-05 01:41:431914 cmd.arg("--no-fail-fast");
1915 }
Mark Simulacrumbe1e7892018-04-14 23:27:571916 cmd.arg("--").args(&builder.config.cmd.test_args());
1917 try_run(builder, &mut cmd);
Josh Stone617aea42017-06-02 16:27:441918 }
Mark Simulacrum6b3413d2017-07-05 12:41:271919
Mark Simulacrum56128fb2017-07-19 00:03:381920 fn should_run(run: ShouldRun) -> ShouldRun {
1921 run.path("src/bootstrap")
Mark Simulacrum6b3413d2017-07-05 12:41:271922 }
1923
Mark Simulacrum6a67a052017-07-20 23:51:071924 fn make_run(run: RunConfig) {
1925 run.builder.ensure(Bootstrap);
Mark Simulacrum6b3413d2017-07-05 12:41:271926 }
Alex Crichton1a040b32016-12-31 03:50:571927}