blob: efb92be60e66bc21c7b3de38aa1766f3c8524355 [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;
Mark Simulacrum5b44cbc2017-06-26 16:23:5018use std::iter;
Ulrik Sverdrupb1566ba2016-11-25 21:13:5919use std::fmt;
Mark Simulacrumdd1d75e2017-06-04 23:55:5020use std::fs::{self, File};
Alex Crichtonede89442016-04-15 01:00:3521use std::path::{PathBuf, Path};
22use std::process::Command;
Mark Simulacrumdd1d75e2017-06-04 23:55:5023use std::io::Read;
Alex Crichton73c2d2a2016-04-14 21:27:5124
kennytm2566fa22017-12-06 21:06:4825use build_helper::{self, output};
Alex Crichton126e09e2016-04-14 22:51:0326
Mark Simulacrum6a67a052017-07-20 23:51:0727use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step};
Mark Simulacrumf104b122018-02-11 16:51:5828use Crate as CargoCrate;
Mark Simulacrum528646e2017-07-14 00:48:4429use cache::{INTERNER, Interned};
Alex Crichton90105672017-07-17 16:32:0830use compile;
31use dist;
32use native;
33use tool::{self, Tool};
34use util::{self, dylib_path, dylib_path_var};
Mark Simulacrumbe1e7892018-04-14 23:27:5735use Mode;
Oliver Schneiderab018c72017-08-30 16:59:2636use toolstate::ToolState;
Collins Abitekaniza41ee6fe2018-04-12 11:49:3137use flags::Subcommand;
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.
Mark Simulacrum528646e2017-07-14 00:48:4442#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)]
Ulrik Sverdrupb1566ba2016-11-25 21:13:5943pub enum TestKind {
44 /// Run `cargo test`
45 Test,
46 /// Run `cargo bench`
47 Bench,
48}
49
50impl 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
60impl fmt::Display for TestKind {
61 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
62 f.write_str(match *self {
63 TestKind::Test => "Testing",
64 TestKind::Bench => "Benchmarking",
65 })
66 }
67}
68
Mark Simulacrumbe1e7892018-04-14 23:27:5769fn try_run(builder: &Builder, cmd: &mut Command) -> bool {
70 if !builder.fail_fast {
71 if !builder.try_run(cmd) {
72 let mut failures = builder.delayed_failures.borrow_mut();
Ximin Luo8f254972017-09-18 19:21:2473 failures.push(format!("{:?}", cmd));
Oliver Schneideracdf83f2017-12-06 08:25:2974 return false;
Josh Stone617aea42017-06-02 16:27:4475 }
76 } else {
Mark Simulacrumbe1e7892018-04-14 23:27:5777 builder.run(cmd);
Josh Stone617aea42017-06-02 16:27:4478 }
Oliver Schneideracdf83f2017-12-06 08:25:2979 true
Josh Stone617aea42017-06-02 16:27:4480}
81
Mark Simulacrumbe1e7892018-04-14 23:27:5782fn try_run_quiet(builder: &Builder, cmd: &mut Command) -> bool {
83 if !builder.fail_fast {
84 if !builder.try_run_quiet(cmd) {
85 let mut failures = builder.delayed_failures.borrow_mut();
Ximin Luo8f254972017-09-18 19:21:2486 failures.push(format!("{:?}", cmd));
kennytma9f940e2018-02-21 19:25:2387 return false;
Josh Stone617aea42017-06-02 16:27:4488 }
89 } else {
Mark Simulacrumbe1e7892018-04-14 23:27:5790 builder.run_quiet(cmd);
Josh Stone617aea42017-06-02 16:27:4491 }
kennytma9f940e2018-02-21 19:25:2392 true
Josh Stone617aea42017-06-02 16:27:4493}
94
Mark Simulacrum528646e2017-07-14 00:48:4495#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
96pub struct Linkcheck {
97 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:4398}
99
Mark Simulacrum528646e2017-07-14 00:48:44100impl Step for Linkcheck {
Mark Simulacrum001e9f32017-07-05 01:41:43101 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27102 const ONLY_HOSTS: bool = true;
103 const DEFAULT: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43104
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.
109 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:43110 let host = self.host;
111
Mark Simulacrumbe1e7892018-04-14 23:27:57112 builder.info(&format!("Linkcheck ({})", host));
Mark Simulacrum6b3413d2017-07-05 12:41:27113
114 builder.default_doc(None);
Mark Simulacrum001e9f32017-07-05 01:41:43115
Mark Simulacrumbe1e7892018-04-14 23:27:57116 let _time = util::timeit(&builder);
117 try_run(builder, builder.tool_cmd(Tool::Linkchecker)
118 .arg(builder.out.join(host).join("doc")));
Mark Simulacrum001e9f32017-07-05 01:41:43119 }
Mark Simulacrum6b3413d2017-07-05 12:41:27120
Mark Simulacrum56128fb2017-07-19 00:03:38121 fn should_run(run: ShouldRun) -> ShouldRun {
Mark Simulacrumb05af492017-07-20 23:24:11122 let builder = run.builder;
Mark Simulacrumbe1e7892018-04-14 23:27:57123 run.path("src/tools/linkchecker").default_condition(builder.config.docs)
Mark Simulacrum6b3413d2017-07-05 12:41:27124 }
125
Mark Simulacrum6a67a052017-07-20 23:51:07126 fn make_run(run: RunConfig) {
Mark Simulacrum9ee877b2017-07-27 12:50:43127 run.builder.ensure(Linkcheck { host: run.target });
Mark Simulacrum6b3413d2017-07-05 12:41:27128 }
Alex Crichtondefd1b32016-03-08 07:15:55129}
Brian Anderson3a790ac2016-03-18 20:54:31130
Mark Simulacrum528646e2017-07-14 00:48:44131#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
132pub struct Cargotest {
Mark Simulacrum001e9f32017-07-05 01:41:43133 stage: u32,
Mark Simulacrum528646e2017-07-14 00:48:44134 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43135}
Alex Crichton73c2d2a2016-04-14 21:27:51136
Mark Simulacrum528646e2017-07-14 00:48:44137impl Step for Cargotest {
Mark Simulacrum001e9f32017-07-05 01:41:43138 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27139 const ONLY_HOSTS: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43140
Mark Simulacrum56128fb2017-07-19 00:03:38141 fn should_run(run: ShouldRun) -> ShouldRun {
142 run.path("src/tools/cargotest")
Mark Simulacrumceecd622017-07-12 16:12:47143 }
144
Mark Simulacrum6a67a052017-07-20 23:51:07145 fn make_run(run: RunConfig) {
146 run.builder.ensure(Cargotest {
147 stage: run.builder.top_stage,
Mark Simulacrum9ee877b2017-07-27 12:50:43148 host: run.target,
Mark Simulacrumceecd622017-07-12 16:12:47149 });
150 }
151
Mark Simulacrum001e9f32017-07-05 01:41:43152 /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
153 ///
154 /// This tool in `src/tools` will check out a few Rust projects and run `cargo
155 /// test` to ensure that we don't regress the test suites there.
156 fn run(self, builder: &Builder) {
Mark Simulacrum60388302017-07-05 16:46:41157 let compiler = builder.compiler(self.stage, self.host);
Mark Simulacrum6b3413d2017-07-05 12:41:27158 builder.ensure(compile::Rustc { compiler, target: compiler.host });
Mark Simulacrum001e9f32017-07-05 01:41:43159
160 // Note that this is a short, cryptic, and not scoped directory name. This
161 // is currently to minimize the length of path on Windows where we otherwise
162 // quickly run into path name limit constraints.
Mark Simulacrumbe1e7892018-04-14 23:27:57163 let out_dir = builder.out.join("ct");
Mark Simulacrum001e9f32017-07-05 01:41:43164 t!(fs::create_dir_all(&out_dir));
165
Mark Simulacrumbe1e7892018-04-14 23:27:57166 let _time = util::timeit(&builder);
Mark Simulacrum6b3413d2017-07-05 12:41:27167 let mut cmd = builder.tool_cmd(Tool::CargoTest);
Mark Simulacrumbe1e7892018-04-14 23:27:57168 try_run(builder, cmd.arg(&builder.initial_cargo)
Mark Simulacrum001e9f32017-07-05 01:41:43169 .arg(&out_dir)
Mark Simulacrumc114fe52017-07-05 17:21:33170 .env("RUSTC", builder.rustc(compiler))
Mark Simulacrumfacf5a92017-08-04 22:13:01171 .env("RUSTDOC", builder.rustdoc(compiler.host)));
Mark Simulacrum001e9f32017-07-05 01:41:43172 }
Alex Crichton009f45f2017-04-18 00:24:05173}
174
Mark Simulacrum528646e2017-07-14 00:48:44175#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
176pub struct Cargo {
Mark Simulacrum001e9f32017-07-05 01:41:43177 stage: u32,
Mark Simulacrum528646e2017-07-14 00:48:44178 host: Interned<String>,
Nick Cameron04415dc2017-06-30 18:58:54179}
180
Mark Simulacrum528646e2017-07-14 00:48:44181impl Step for Cargo {
Mark Simulacrum001e9f32017-07-05 01:41:43182 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27183 const ONLY_HOSTS: bool = true;
184
Mark Simulacrum56128fb2017-07-19 00:03:38185 fn should_run(run: ShouldRun) -> ShouldRun {
186 run.path("src/tools/cargo")
Mark Simulacrum6b3413d2017-07-05 12:41:27187 }
188
Mark Simulacrum6a67a052017-07-20 23:51:07189 fn make_run(run: RunConfig) {
190 run.builder.ensure(Cargo {
191 stage: run.builder.top_stage,
192 host: run.target,
Mark Simulacrum6b3413d2017-07-05 12:41:27193 });
194 }
Nick Cameron04415dc2017-06-30 18:58:54195
Mark Simulacrum001e9f32017-07-05 01:41:43196 /// Runs `cargo test` for `cargo` packaged with Rust.
197 fn run(self, builder: &Builder) {
Mark Simulacrum6b3413d2017-07-05 12:41:27198 let compiler = builder.compiler(self.stage, self.host);
Nick Cameron04415dc2017-06-30 18:58:54199
Mark Simulacrumfe0eca02017-07-23 01:29:08200 builder.ensure(tool::Cargo { compiler, target: self.host });
Mark Simulacrumc114fe52017-07-05 17:21:33201 let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
Mark Simulacrumbe1e7892018-04-14 23:27:57202 cargo.arg("--manifest-path").arg(builder.src.join("src/tools/cargo/Cargo.toml"));
203 if !builder.fail_fast {
Mark Simulacrum001e9f32017-07-05 01:41:43204 cargo.arg("--no-fail-fast");
205 }
Nick Cameron04415dc2017-06-30 18:58:54206
Mark Simulacrum001e9f32017-07-05 01:41:43207 // Don't build tests dynamically, just a pain to work with
208 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
209
210 // Don't run cross-compile tests, we may not have cross-compiled libstd libs
211 // available.
212 cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
213
Mark Simulacrumbe1e7892018-04-14 23:27:57214 try_run(builder, cargo.env("PATH", &path_for_cargo(builder, compiler)));
Mark Simulacrum001e9f32017-07-05 01:41:43215 }
216}
217
Mark Simulacrumdec44b02017-07-17 15:52:05218#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
219pub struct Rls {
Mark Simulacrum001e9f32017-07-05 01:41:43220 stage: u32,
Mark Simulacrumdec44b02017-07-17 15:52:05221 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43222}
223
Mark Simulacrumdec44b02017-07-17 15:52:05224impl Step for Rls {
Mark Simulacrum001e9f32017-07-05 01:41:43225 type Output = ();
Mark Simulacrumdec44b02017-07-17 15:52:05226 const ONLY_HOSTS: bool = true;
227
Mark Simulacrum56128fb2017-07-19 00:03:38228 fn should_run(run: ShouldRun) -> ShouldRun {
229 run.path("src/tools/rls")
Mark Simulacrumdec44b02017-07-17 15:52:05230 }
231
Mark Simulacrum6a67a052017-07-20 23:51:07232 fn make_run(run: RunConfig) {
233 run.builder.ensure(Rls {
234 stage: run.builder.top_stage,
235 host: run.target,
Mark Simulacrumdec44b02017-07-17 15:52:05236 });
237 }
Mark Simulacrum001e9f32017-07-05 01:41:43238
239 /// Runs `cargo test` for the rls.
240 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:43241 let stage = self.stage;
242 let host = self.host;
Mark Simulacrumdec44b02017-07-17 15:52:05243 let compiler = builder.compiler(stage, host);
Mark Simulacrum001e9f32017-07-05 01:41:43244
kennytm27d96912018-04-20 16:53:36245 let build_result = builder.ensure(tool::Rls {
246 compiler,
247 target: self.host,
248 extra_features: Vec::new(),
249 });
250 if build_result.is_none() {
251 eprintln!("failed to test rls: could not build");
252 return;
253 }
254
Oliver Schneideracdf83f2017-12-06 08:25:29255 let mut cargo = tool::prepare_tool_cargo(builder,
256 compiler,
257 host,
258 "test",
259 "src/tools/rls");
Mark Simulacrum001e9f32017-07-05 01:41:43260
261 // Don't build tests dynamically, just a pain to work with
262 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
263
Mark Simulacrumdec44b02017-07-17 15:52:05264 builder.add_rustc_lib_path(compiler, &mut cargo);
Mark Simulacrum001e9f32017-07-05 01:41:43265
Mark Simulacrumbe1e7892018-04-14 23:27:57266 if try_run(builder, &mut cargo) {
267 builder.save_toolstate("rls", ToolState::TestPass);
Oliver Schneideracdf83f2017-12-06 08:25:29268 }
Mark Simulacrum001e9f32017-07-05 01:41:43269 }
Nick Cameron04415dc2017-06-30 18:58:54270}
271
Nick Camerond0070e82017-09-01 06:43:00272#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
273pub struct Rustfmt {
274 stage: u32,
275 host: Interned<String>,
276}
277
278impl Step for Rustfmt {
279 type Output = ();
280 const ONLY_HOSTS: bool = true;
281
282 fn should_run(run: ShouldRun) -> ShouldRun {
283 run.path("src/tools/rustfmt")
284 }
285
286 fn make_run(run: RunConfig) {
287 run.builder.ensure(Rustfmt {
288 stage: run.builder.top_stage,
289 host: run.target,
290 });
291 }
292
293 /// Runs `cargo test` for rustfmt.
294 fn run(self, builder: &Builder) {
Nick Camerond0070e82017-09-01 06:43:00295 let stage = self.stage;
296 let host = self.host;
297 let compiler = builder.compiler(stage, host);
298
kennytm27d96912018-04-20 16:53:36299 let build_result = builder.ensure(tool::Rustfmt {
300 compiler,
301 target: self.host,
302 extra_features: Vec::new(),
303 });
304 if build_result.is_none() {
305 eprintln!("failed to test rustfmt: could not build");
306 return;
307 }
308
Oliver Schneideracdf83f2017-12-06 08:25:29309 let mut cargo = tool::prepare_tool_cargo(builder,
310 compiler,
311 host,
312 "test",
313 "src/tools/rustfmt");
Nick Camerond0070e82017-09-01 06:43:00314
315 // Don't build tests dynamically, just a pain to work with
316 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
317
318 builder.add_rustc_lib_path(compiler, &mut cargo);
319
Mark Simulacrumbe1e7892018-04-14 23:27:57320 if try_run(builder, &mut cargo) {
321 builder.save_toolstate("rustfmt", ToolState::TestPass);
Oliver Schneideracdf83f2017-12-06 08:25:29322 }
Nick Camerond0070e82017-09-01 06:43:00323 }
324}
Oliver Schneider01555b12017-09-17 19:45:54325
326#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Oliver Schneiderf3817442017-08-28 14:54:50327pub struct Miri {
Oliver Schneideracdf83f2017-12-06 08:25:29328 stage: u32,
Oliver Schneiderf3817442017-08-28 14:54:50329 host: Interned<String>,
330}
331
332impl Step for Miri {
333 type Output = ();
334 const ONLY_HOSTS: bool = true;
335 const DEFAULT: bool = true;
336
337 fn should_run(run: ShouldRun) -> ShouldRun {
Mark Simulacrumbe1e7892018-04-14 23:27:57338 let test_miri = run.builder.config.test_miri;
Oliver Schneiderf3817442017-08-28 14:54:50339 run.path("src/tools/miri").default_condition(test_miri)
340 }
341
342 fn make_run(run: RunConfig) {
343 run.builder.ensure(Miri {
Oliver Schneideracdf83f2017-12-06 08:25:29344 stage: run.builder.top_stage,
Oliver Schneiderf3817442017-08-28 14:54:50345 host: run.target,
346 });
347 }
348
349 /// Runs `cargo test` for miri.
350 fn run(self, builder: &Builder) {
Oliver Schneideracdf83f2017-12-06 08:25:29351 let stage = self.stage;
Oliver Schneiderf3817442017-08-28 14:54:50352 let host = self.host;
Oliver Schneideracdf83f2017-12-06 08:25:29353 let compiler = builder.compiler(stage, host);
Oliver Schneiderf3817442017-08-28 14:54:50354
Oliver Schneider02ac15c2018-02-09 17:53:41355 let miri = builder.ensure(tool::Miri {
356 compiler,
357 target: self.host,
358 extra_features: Vec::new(),
359 });
360 if let Some(miri) = miri {
Oliver Schneideracdf83f2017-12-06 08:25:29361 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
Mark Simulacrumbe1e7892018-04-14 23:27:57362 cargo.arg("--manifest-path").arg(builder.src.join("src/tools/miri/Cargo.toml"));
Oliver Schneiderf3817442017-08-28 14:54:50363
Oliver Schneideracdf83f2017-12-06 08:25:29364 // Don't build tests dynamically, just a pain to work with
365 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
366 // miri tests need to know about the stage sysroot
367 cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
368 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
369 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
370 cargo.env("MIRI_PATH", miri);
Oliver Schneiderf3817442017-08-28 14:54:50371
Oliver Schneideracdf83f2017-12-06 08:25:29372 builder.add_rustc_lib_path(compiler, &mut cargo);
Oliver Schneiderf3817442017-08-28 14:54:50373
Mark Simulacrumbe1e7892018-04-14 23:27:57374 if try_run(builder, &mut cargo) {
375 builder.save_toolstate("miri", ToolState::TestPass);
Oliver Schneideracdf83f2017-12-06 08:25:29376 }
377 } else {
378 eprintln!("failed to test miri: could not build");
379 }
Oliver Schneiderf3817442017-08-28 14:54:50380 }
381}
382
Oliver Schneiderd64a0672017-09-18 11:13:57383#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
384pub struct Clippy {
Oliver Schneideracdf83f2017-12-06 08:25:29385 stage: u32,
Oliver Schneiderd64a0672017-09-18 11:13:57386 host: Interned<String>,
387}
388
389impl Step for Clippy {
390 type Output = ();
391 const ONLY_HOSTS: bool = true;
392 const DEFAULT: bool = false;
393
394 fn should_run(run: ShouldRun) -> ShouldRun {
395 run.path("src/tools/clippy")
396 }
397
398 fn make_run(run: RunConfig) {
399 run.builder.ensure(Clippy {
Oliver Schneideracdf83f2017-12-06 08:25:29400 stage: run.builder.top_stage,
Oliver Schneiderd64a0672017-09-18 11:13:57401 host: run.target,
402 });
403 }
404
405 /// Runs `cargo test` for clippy.
406 fn run(self, builder: &Builder) {
Oliver Schneideracdf83f2017-12-06 08:25:29407 let stage = self.stage;
Oliver Schneiderd64a0672017-09-18 11:13:57408 let host = self.host;
Oliver Schneideracdf83f2017-12-06 08:25:29409 let compiler = builder.compiler(stage, host);
Oliver Schneiderd64a0672017-09-18 11:13:57410
Oliver Schneider02ac15c2018-02-09 17:53:41411 let clippy = builder.ensure(tool::Clippy {
412 compiler,
413 target: self.host,
414 extra_features: Vec::new(),
415 });
416 if let Some(clippy) = clippy {
Oliver Schneideracdf83f2017-12-06 08:25:29417 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
Mark Simulacrumbe1e7892018-04-14 23:27:57418 cargo.arg("--manifest-path").arg(builder.src.join("src/tools/clippy/Cargo.toml"));
Oliver Schneiderd64a0672017-09-18 11:13:57419
Oliver Schneideracdf83f2017-12-06 08:25:29420 // Don't build tests dynamically, just a pain to work with
421 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
422 // clippy tests need to know about the stage sysroot
423 cargo.env("SYSROOT", builder.sysroot(compiler));
424 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
425 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
426 let host_libs = builder.stage_out(compiler, Mode::Tool).join(builder.cargo_dir());
427 cargo.env("HOST_LIBS", host_libs);
428 // clippy tests need to find the driver
429 cargo.env("CLIPPY_DRIVER_PATH", clippy);
Oliver Schneiderd64a0672017-09-18 11:13:57430
Oliver Schneideracdf83f2017-12-06 08:25:29431 builder.add_rustc_lib_path(compiler, &mut cargo);
Oliver Schneiderd64a0672017-09-18 11:13:57432
Mark Simulacrumbe1e7892018-04-14 23:27:57433 if try_run(builder, &mut cargo) {
434 builder.save_toolstate("clippy-driver", ToolState::TestPass);
Oliver Schneideracdf83f2017-12-06 08:25:29435 }
436 } else {
437 eprintln!("failed to test clippy: could not build");
438 }
Oliver Schneiderd64a0672017-09-18 11:13:57439 }
440}
Nick Camerond0070e82017-09-01 06:43:00441
Mark Simulacrumdec44b02017-07-17 15:52:05442fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
Nick Cameron04415dc2017-06-30 18:58:54443 // Configure PATH to find the right rustc. NB. we have to use PATH
444 // and not RUSTC because the Cargo test suite has tests that will
445 // fail if rustc is not spelled `rustc`.
Mark Simulacrumdec44b02017-07-17 15:52:05446 let path = builder.sysroot(compiler).join("bin");
Nick Cameron04415dc2017-06-30 18:58:54447 let old_path = env::var_os("PATH").unwrap_or_default();
448 env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
Brian Anderson3a790ac2016-03-18 20:54:31449}
Alex Crichton9dd3c542016-03-29 20:14:52450
Guillaume Gomezf18c52b2017-12-12 22:53:24451#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
Guillaume Gomez51580d42018-01-25 23:44:52452pub struct RustdocTheme {
453 pub compiler: Compiler,
Guillaume Gomez51580d42018-01-25 23:44:52454}
455
456impl Step for RustdocTheme {
457 type Output = ();
458 const DEFAULT: bool = true;
459 const ONLY_HOSTS: bool = true;
460
461 fn should_run(run: ShouldRun) -> ShouldRun {
462 run.path("src/tools/rustdoc-themes")
463 }
464
465 fn make_run(run: RunConfig) {
466 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
467
468 run.builder.ensure(RustdocTheme {
469 compiler: compiler,
Guillaume Gomez51580d42018-01-25 23:44:52470 });
471 }
472
473 fn run(self, builder: &Builder) {
Chris Coulson6f101462018-04-12 14:01:49474 let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
Guillaume Gomezdec9fab2018-02-05 22:43:53475 let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
476 cmd.arg(rustdoc.to_str().unwrap())
477 .arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap())
478 .env("RUSTC_STAGE", self.compiler.stage.to_string())
Guillaume Gomez51580d42018-01-25 23:44:52479 .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
480 .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
Mark Simulacrumbe1e7892018-04-14 23:27:57481 .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
Guillaume Gomezdec9fab2018-02-05 22:43:53482 .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
Mark Simulacrumbe1e7892018-04-14 23:27:57483 .env("RUSTDOC_CRATE_VERSION", builder.rust_version())
Guillaume Gomez51580d42018-01-25 23:44:52484 .env("RUSTC_BOOTSTRAP", "1");
Mark Simulacrumbe1e7892018-04-14 23:27:57485 if let Some(linker) = builder.linker(self.compiler.host) {
Guillaume Gomez51580d42018-01-25 23:44:52486 cmd.env("RUSTC_TARGET_LINKER", linker);
487 }
Mark Simulacrumbe1e7892018-04-14 23:27:57488 try_run(builder, &mut cmd);
Guillaume Gomez51580d42018-01-25 23:44:52489 }
490}
491
492#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
Guillaume Gomezf18c52b2017-12-12 22:53:24493pub struct RustdocJS {
494 pub host: Interned<String>,
Guillaume Gomez69521992018-01-12 22:40:00495 pub target: Interned<String>,
Guillaume Gomezf18c52b2017-12-12 22:53:24496}
497
498impl Step for RustdocJS {
Guillaume Gomez50bb6ba2018-01-08 22:43:20499 type Output = ();
Guillaume Gomezf18c52b2017-12-12 22:53:24500 const DEFAULT: bool = true;
501 const ONLY_HOSTS: bool = true;
502
503 fn should_run(run: ShouldRun) -> ShouldRun {
Guillaume Gomez69521992018-01-12 22:40:00504 run.path("src/test/rustdoc-js")
Guillaume Gomezf18c52b2017-12-12 22:53:24505 }
506
507 fn make_run(run: RunConfig) {
508 run.builder.ensure(RustdocJS {
509 host: run.host,
Guillaume Gomez69521992018-01-12 22:40:00510 target: run.target,
Guillaume Gomezf18c52b2017-12-12 22:53:24511 });
512 }
513
Guillaume Gomez50bb6ba2018-01-08 22:43:20514 fn run(self, builder: &Builder) {
Guillaume Gomez026c7492018-01-13 21:35:41515 if let Some(ref nodejs) = builder.config.nodejs {
516 let mut command = Command::new(nodejs);
517 command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]);
518 builder.ensure(::doc::Std {
519 target: self.target,
520 stage: builder.top_stage,
521 });
522 builder.run(&mut command);
523 } else {
Mark Simulacrum545b92f2018-03-28 15:25:09524 builder.info(&format!("No nodejs found, skipping \"src/test/rustdoc-js\" tests"));
Guillaume Gomez026c7492018-01-13 21:35:41525 }
Guillaume Gomezf18c52b2017-12-12 22:53:24526 }
527}
528
Guillaume Gomez035ec5b2018-03-31 12:49:56529#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
530pub struct RustdocUi {
531 pub host: Interned<String>,
532 pub target: Interned<String>,
533 pub compiler: Compiler,
534}
535
536impl Step for RustdocUi {
537 type Output = ();
538 const DEFAULT: bool = true;
539 const ONLY_HOSTS: bool = true;
540
541 fn should_run(run: ShouldRun) -> ShouldRun {
542 run.path("src/test/rustdoc-ui")
543 }
544
545 fn make_run(run: RunConfig) {
546 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
547 run.builder.ensure(RustdocUi {
548 host: run.host,
549 target: run.target,
550 compiler,
551 });
552 }
553
554 fn run(self, builder: &Builder) {
555 builder.ensure(Compiletest {
556 compiler: self.compiler,
557 target: self.target,
558 mode: "ui",
559 suite: "rustdoc-ui",
Collins Abitekaniza41ee6fe2018-04-12 11:49:31560 path: None,
Felix S. Klock II55895502018-04-11 15:15:59561 compare_mode: None,
Guillaume Gomez035ec5b2018-03-31 12:49:56562 })
563 }
564}
565
Mark Simulacrum528646e2017-07-14 00:48:44566#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum1c8f3b02018-02-11 22:41:06567pub struct Tidy;
Mark Simulacrum001e9f32017-07-05 01:41:43568
Mark Simulacrum528646e2017-07-14 00:48:44569impl Step for Tidy {
Mark Simulacrum001e9f32017-07-05 01:41:43570 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27571 const DEFAULT: bool = true;
572 const ONLY_HOSTS: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43573
Mark Simulacrum1c8f3b02018-02-11 22:41:06574 /// Runs the `tidy` tool.
Mark Simulacrum001e9f32017-07-05 01:41:43575 ///
576 /// This tool in `src/tools` checks up on various bits and pieces of style and
577 /// otherwise just implements a few lint-like checks that are specific to the
578 /// compiler itself.
579 fn run(self, builder: &Builder) {
Mark Simulacrum60388302017-07-05 16:46:41580 let mut cmd = builder.tool_cmd(Tool::Tidy);
Mark Simulacrumbe1e7892018-04-14 23:27:57581 cmd.arg(builder.src.join("src"));
582 cmd.arg(&builder.initial_cargo);
583 if !builder.config.vendor {
Mark Simulacrum001e9f32017-07-05 01:41:43584 cmd.arg("--no-vendor");
585 }
Mark Simulacrumbe1e7892018-04-14 23:27:57586 if builder.config.quiet_tests {
Mark Simulacrum001e9f32017-07-05 01:41:43587 cmd.arg("--quiet");
588 }
Alex Crichton6fd4d672018-03-16 15:35:03589
Mark Simulacrumbe1e7892018-04-14 23:27:57590 let _folder = builder.fold_output(|| "tidy");
Mark Simulacrum545b92f2018-03-28 15:25:09591 builder.info(&format!("tidy check"));
Mark Simulacrumbe1e7892018-04-14 23:27:57592 try_run(builder, &mut cmd);
Eduard-Mihai Burtescud29f0bc2017-02-10 20:59:40593 }
Mark Simulacrum6b3413d2017-07-05 12:41:27594
Mark Simulacrum56128fb2017-07-19 00:03:38595 fn should_run(run: ShouldRun) -> ShouldRun {
596 run.path("src/tools/tidy")
Mark Simulacrum6b3413d2017-07-05 12:41:27597 }
598
Mark Simulacrum6a67a052017-07-20 23:51:07599 fn make_run(run: RunConfig) {
Mark Simulacrum1c8f3b02018-02-11 22:41:06600 run.builder.ensure(Tidy);
Mark Simulacrum6b3413d2017-07-05 12:41:27601 }
Alex Crichton9dd3c542016-03-29 20:14:52602}
Alex Crichtonb325baf2016-04-05 18:34:23603
Mark Simulacrumbe1e7892018-04-14 23:27:57604fn testdir(builder: &Builder, host: Interned<String>) -> PathBuf {
605 builder.out.join(host).join("test")
Alex Crichtonb325baf2016-04-05 18:34:23606}
607
Mark Simulacrumf104b122018-02-11 16:51:58608macro_rules! default_test {
609 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
610 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: false });
611 }
Mark Simulacrum1ab89302017-07-07 17:51:57612}
613
Felix S. Klock II55895502018-04-11 15:15:59614macro_rules! default_test_with_compare_mode {
615 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr,
616 compare_mode: $compare_mode:expr }) => {
617 test_with_compare_mode!($name { path: $path, mode: $mode, suite: $suite, default: true,
618 host: false, compare_mode: $compare_mode });
619 }
620}
621
Mark Simulacrumf104b122018-02-11 16:51:58622macro_rules! host_test {
623 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
624 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: true });
625 }
626}
Mark Simulacrum6b3413d2017-07-05 12:41:27627
Mark Simulacrumf104b122018-02-11 16:51:58628macro_rules! test {
Felix S. Klock II55895502018-04-11 15:15:59629 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
630 host: $host:expr }) => {
631 test_definitions!($name { path: $path, mode: $mode, suite: $suite, default: $default,
632 host: $host, compare_mode: None });
633 }
634}
635
636macro_rules! test_with_compare_mode {
637 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
638 host: $host:expr, compare_mode: $compare_mode:expr }) => {
639 test_definitions!($name { path: $path, mode: $mode, suite: $suite, default: $default,
640 host: $host, compare_mode: Some($compare_mode) });
641 }
642}
643
644macro_rules! test_definitions {
Mark Simulacrumf104b122018-02-11 16:51:58645 ($name:ident {
646 path: $path:expr,
647 mode: $mode:expr,
648 suite: $suite:expr,
649 default: $default:expr,
Felix S. Klock II55895502018-04-11 15:15:59650 host: $host:expr,
651 compare_mode: $compare_mode:expr
Mark Simulacrumf104b122018-02-11 16:51:58652 }) => {
653 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
654 pub struct $name {
655 pub compiler: Compiler,
656 pub target: Interned<String>,
657 }
658
659 impl Step for $name {
660 type Output = ();
661 const DEFAULT: bool = $default;
662 const ONLY_HOSTS: bool = $host;
663
664 fn should_run(run: ShouldRun) -> ShouldRun {
Collins Abitekaniza41ee6fe2018-04-12 11:49:31665 run.suite_path($path)
Mark Simulacrumf104b122018-02-11 16:51:58666 }
667
668 fn make_run(run: RunConfig) {
669 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
670
671 run.builder.ensure($name {
672 compiler,
673 target: run.target,
674 });
675 }
676
677 fn run(self, builder: &Builder) {
678 builder.ensure(Compiletest {
679 compiler: self.compiler,
680 target: self.target,
681 mode: $mode,
682 suite: $suite,
Collins Abitekaniza41ee6fe2018-04-12 11:49:31683 path: Some($path),
Felix S. Klock II55895502018-04-11 15:15:59684 compare_mode: $compare_mode,
Mark Simulacrumf104b122018-02-11 16:51:58685 })
686 }
687 }
688 }
689}
690
Felix S. Klock II55895502018-04-11 15:15:59691default_test_with_compare_mode!(Ui {
Mark Simulacrumf104b122018-02-11 16:51:58692 path: "src/test/ui",
693 mode: "ui",
Felix S. Klock II55895502018-04-11 15:15:59694 suite: "ui",
695 compare_mode: "nll"
Mark Simulacrumf104b122018-02-11 16:51:58696});
697
698default_test!(RunPass {
699 path: "src/test/run-pass",
700 mode: "run-pass",
701 suite: "run-pass"
702});
703
704default_test!(CompileFail {
705 path: "src/test/compile-fail",
706 mode: "compile-fail",
707 suite: "compile-fail"
708});
709
710default_test!(ParseFail {
711 path: "src/test/parse-fail",
712 mode: "parse-fail",
713 suite: "parse-fail"
714});
715
716default_test!(RunFail {
717 path: "src/test/run-fail",
718 mode: "run-fail",
719 suite: "run-fail"
720});
721
722default_test!(RunPassValgrind {
723 path: "src/test/run-pass-valgrind",
724 mode: "run-pass-valgrind",
725 suite: "run-pass-valgrind"
726});
727
728default_test!(MirOpt {
729 path: "src/test/mir-opt",
730 mode: "mir-opt",
731 suite: "mir-opt"
732});
733
734default_test!(Codegen {
735 path: "src/test/codegen",
736 mode: "codegen",
737 suite: "codegen"
738});
739
740default_test!(CodegenUnits {
741 path: "src/test/codegen-units",
742 mode: "codegen-units",
743 suite: "codegen-units"
744});
745
746default_test!(Incremental {
747 path: "src/test/incremental",
748 mode: "incremental",
749 suite: "incremental"
750});
751
752default_test!(Debuginfo {
753 path: "src/test/debuginfo",
Mark Simulacrumaa8b93b2017-07-07 18:31:29754 // What this runs varies depending on the native platform being apple
Mark Simulacrumf104b122018-02-11 16:51:58755 mode: "debuginfo-XXX",
756 suite: "debuginfo"
757});
Mark Simulacrum6b3413d2017-07-05 12:41:27758
Mark Simulacrumf104b122018-02-11 16:51:58759host_test!(UiFullDeps {
760 path: "src/test/ui-fulldeps",
761 mode: "ui",
762 suite: "ui-fulldeps"
763});
Mark Simulacrumf1d04a32017-07-20 15:42:18764
Mark Simulacrumf104b122018-02-11 16:51:58765host_test!(RunPassFullDeps {
766 path: "src/test/run-pass-fulldeps",
767 mode: "run-pass",
768 suite: "run-pass-fulldeps"
769});
Mark Simulacrumf1d04a32017-07-20 15:42:18770
Mark Simulacrumf104b122018-02-11 16:51:58771host_test!(RunFailFullDeps {
772 path: "src/test/run-fail-fulldeps",
773 mode: "run-fail",
774 suite: "run-fail-fulldeps"
775});
Mark Simulacrumf1d04a32017-07-20 15:42:18776
Mark Simulacrumf104b122018-02-11 16:51:58777host_test!(CompileFailFullDeps {
778 path: "src/test/compile-fail-fulldeps",
779 mode: "compile-fail",
780 suite: "compile-fail-fulldeps"
781});
Mark Simulacrumf1d04a32017-07-20 15:42:18782
Mark Simulacrumf104b122018-02-11 16:51:58783host_test!(IncrementalFullDeps {
784 path: "src/test/incremental-fulldeps",
785 mode: "incremental",
786 suite: "incremental-fulldeps"
787});
Mark Simulacrumf1d04a32017-07-20 15:42:18788
Mark Simulacrumf104b122018-02-11 16:51:58789host_test!(Rustdoc {
790 path: "src/test/rustdoc",
791 mode: "rustdoc",
792 suite: "rustdoc"
793});
Mark Simulacrumf1d04a32017-07-20 15:42:18794
Mark Simulacrumf104b122018-02-11 16:51:58795test!(Pretty {
796 path: "src/test/pretty",
797 mode: "pretty",
798 suite: "pretty",
799 default: false,
800 host: true
801});
802test!(RunPassPretty {
803 path: "src/test/run-pass/pretty",
804 mode: "pretty",
805 suite: "run-pass",
806 default: false,
807 host: true
808});
809test!(RunFailPretty {
810 path: "src/test/run-fail/pretty",
811 mode: "pretty",
812 suite: "run-fail",
813 default: false,
814 host: true
815});
816test!(RunPassValgrindPretty {
817 path: "src/test/run-pass-valgrind/pretty",
818 mode: "pretty",
819 suite: "run-pass-valgrind",
820 default: false,
821 host: true
822});
823test!(RunPassFullDepsPretty {
824 path: "src/test/run-pass-fulldeps/pretty",
825 mode: "pretty",
826 suite: "run-pass-fulldeps",
827 default: false,
828 host: true
829});
830test!(RunFailFullDepsPretty {
831 path: "src/test/run-fail-fulldeps/pretty",
832 mode: "pretty",
833 suite: "run-fail-fulldeps",
834 default: false,
835 host: true
836});
Mark Simulacrumf1d04a32017-07-20 15:42:18837
Alex Crichton7df6f412018-03-09 17:26:15838default_test!(RunMake {
Mark Simulacrumf104b122018-02-11 16:51:58839 path: "src/test/run-make",
840 mode: "run-make",
841 suite: "run-make"
842});
Mark Simulacrumf1d04a32017-07-20 15:42:18843
Alex Crichton7df6f412018-03-09 17:26:15844host_test!(RunMakeFullDeps {
845 path: "src/test/run-make-fulldeps",
846 mode: "run-make",
847 suite: "run-make-fulldeps"
848});
849
Mark Simulacrumf1d04a32017-07-20 15:42:18850#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
851struct Compiletest {
852 compiler: Compiler,
853 target: Interned<String>,
854 mode: &'static str,
855 suite: &'static str,
Collins Abitekaniza41ee6fe2018-04-12 11:49:31856 path: Option<&'static str>,
Felix S. Klock II55895502018-04-11 15:15:59857 compare_mode: Option<&'static str>,
Mark Simulacrumf1d04a32017-07-20 15:42:18858}
859
860impl Step for Compiletest {
861 type Output = ();
862
863 fn should_run(run: ShouldRun) -> ShouldRun {
864 run.never()
865 }
866
Mark Simulacrum001e9f32017-07-05 01:41:43867 /// Executes the `compiletest` tool to run a suite of tests.
868 ///
869 /// Compiles all tests with `compiler` for `target` with the specified
870 /// compiletest `mode` and `suite` arguments. For example `mode` can be
871 /// "run-pass" or `suite` can be something like `debuginfo`.
872 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:43873 let compiler = self.compiler;
874 let target = self.target;
875 let mode = self.mode;
876 let suite = self.suite;
Felix S. Klock II55895502018-04-11 15:15:59877 let compare_mode = self.compare_mode;
Mark Simulacrum6b3413d2017-07-05 12:41:27878
Collins Abitekaniza41ee6fe2018-04-12 11:49:31879 // Path for test suite
880 let suite_path = self.path.unwrap_or("");
881
Mark Simulacrum6b3413d2017-07-05 12:41:27882 // Skip codegen tests if they aren't enabled in configuration.
Mark Simulacrumbe1e7892018-04-14 23:27:57883 if !builder.config.codegen_tests && suite == "codegen" {
Mark Simulacrum6b3413d2017-07-05 12:41:27884 return;
885 }
886
887 if suite == "debuginfo" {
Mark Simulacrum951616c2017-07-20 17:23:29888 // Skip debuginfo tests on MSVC
Mark Simulacrumbe1e7892018-04-14 23:27:57889 if builder.config.build.contains("msvc") {
Mark Simulacrum951616c2017-07-20 17:23:29890 return;
891 }
892
Mark Simulacrum6b3413d2017-07-05 12:41:27893 if mode == "debuginfo-XXX" {
Mark Simulacrumbe1e7892018-04-14 23:27:57894 return if builder.config.build.contains("apple") {
Mark Simulacrum6b3413d2017-07-05 12:41:27895 builder.ensure(Compiletest {
896 mode: "debuginfo-lldb",
897 ..self
Mark Simulacrum528646e2017-07-14 00:48:44898 });
Mark Simulacrum6b3413d2017-07-05 12:41:27899 } else {
900 builder.ensure(Compiletest {
901 mode: "debuginfo-gdb",
902 ..self
Mark Simulacrum528646e2017-07-14 00:48:44903 });
Mark Simulacrum6b3413d2017-07-05 12:41:27904 };
905 }
906
Mark Simulacrum6b3413d2017-07-05 12:41:27907 builder.ensure(dist::DebuggerScripts {
Mark Simulacrum528646e2017-07-14 00:48:44908 sysroot: builder.sysroot(compiler),
Mark Simulacrumfef9b482017-07-23 16:03:40909 host: target
Mark Simulacrum6b3413d2017-07-05 12:41:27910 });
911 }
912
913 if suite.ends_with("fulldeps") ||
914 // FIXME: Does pretty need librustc compiled? Note that there are
915 // fulldeps test suites with mode = pretty as well.
916 mode == "pretty" ||
Alex Crichton7df6f412018-03-09 17:26:15917 mode == "rustdoc" {
Mark Simulacrum6b3413d2017-07-05 12:41:27918 builder.ensure(compile::Rustc { compiler, target });
919 }
920
921 builder.ensure(compile::Test { compiler, target });
922 builder.ensure(native::TestHelpers { target });
Mark Simulacrumaa8b93b2017-07-07 18:31:29923 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum6b3413d2017-07-05 12:41:27924
Mark Simulacrum6b3413d2017-07-05 12:41:27925 let mut cmd = builder.tool_cmd(Tool::Compiletest);
Alex Crichtonb325baf2016-04-05 18:34:23926
Mark Simulacrum001e9f32017-07-05 01:41:43927 // compiletest currently has... a lot of arguments, so let's just pass all
928 // of them!
Brian Anderson8401e372016-09-15 19:42:26929
Mark Simulacrumc114fe52017-07-05 17:21:33930 cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
Mark Simulacrum60388302017-07-05 16:46:41931 cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
Mark Simulacrumc114fe52017-07-05 17:21:33932 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
Mark Simulacrum4e5333c2017-07-25 22:54:33933
Guillaume Gomezb2192ae2018-04-01 19:06:35934 let is_rustdoc_ui = suite.ends_with("rustdoc-ui");
935
Mark Simulacrum4e5333c2017-07-25 22:54:33936 // Avoid depending on rustdoc when we don't need it.
Guillaume Gomezb2192ae2018-04-01 19:06:35937 if mode == "rustdoc" ||
938 (mode == "run-make" && suite.ends_with("fulldeps")) ||
939 (mode == "ui" && is_rustdoc_ui) {
Mark Simulacrumfacf5a92017-08-04 22:13:01940 cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
Mark Simulacrum4e5333c2017-07-25 22:54:33941 }
942
Mark Simulacrumbe1e7892018-04-14 23:27:57943 cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite));
944 cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
Mark Simulacrum001e9f32017-07-05 01:41:43945 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
946 cmd.arg("--mode").arg(mode);
947 cmd.arg("--target").arg(target);
Mark Simulacrum528646e2017-07-14 00:48:44948 cmd.arg("--host").arg(&*compiler.host);
Mark Simulacrumbe1e7892018-04-14 23:27:57949 cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build));
Alex Crichtonf4e4ec72016-05-13 22:26:41950
Mark Simulacrumbe1e7892018-04-14 23:27:57951 if let Some(ref nodejs) = builder.config.nodejs {
Mark Simulacrum001e9f32017-07-05 01:41:43952 cmd.arg("--nodejs").arg(nodejs);
953 }
Alex Crichtonf4e4ec72016-05-13 22:26:41954
Guillaume Gomezb2192ae2018-04-01 19:06:35955 let mut flags = if is_rustdoc_ui {
956 Vec::new()
957 } else {
958 vec!["-Crpath".to_string()]
959 };
960 if !is_rustdoc_ui {
Mark Simulacrumbe1e7892018-04-14 23:27:57961 if builder.config.rust_optimize_tests {
Guillaume Gomezb2192ae2018-04-01 19:06:35962 flags.push("-O".to_string());
963 }
Mark Simulacrumbe1e7892018-04-14 23:27:57964 if builder.config.rust_debuginfo_tests {
Guillaume Gomezb2192ae2018-04-01 19:06:35965 flags.push("-g".to_string());
966 }
Mark Simulacrum001e9f32017-07-05 01:41:43967 }
Guillaume Gomeza3ed2ab2018-04-15 11:05:14968 flags.push("-Zunstable-options".to_string());
Mark Simulacrumbe1e7892018-04-14 23:27:57969 flags.push(builder.config.cmd.rustc_args().join(" "));
Alex Crichtoncbe62922016-04-19 16:44:19970
Mark Simulacrumbe1e7892018-04-14 23:27:57971 if let Some(linker) = builder.linker(target) {
Oliver Schneideracdf83f2017-12-06 08:25:29972 cmd.arg("--linker").arg(linker);
973 }
974
975 let hostflags = flags.clone();
Mark Simulacrum001e9f32017-07-05 01:41:43976 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
Alex Crichtoncbe62922016-04-19 16:44:19977
Oliver Schneideracdf83f2017-12-06 08:25:29978 let mut targetflags = flags.clone();
Mark Simulacrum001e9f32017-07-05 01:41:43979 targetflags.push(format!("-Lnative={}",
Mark Simulacrumbe1e7892018-04-14 23:27:57980 builder.test_helpers_out(target).display()));
Mark Simulacrum001e9f32017-07-05 01:41:43981 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
Alex Crichtonb325baf2016-04-05 18:34:23982
Mark Simulacrumbe1e7892018-04-14 23:27:57983 cmd.arg("--docck-python").arg(builder.python());
Alex Crichtonb325baf2016-04-05 18:34:23984
Mark Simulacrumbe1e7892018-04-14 23:27:57985 if builder.config.build.ends_with("apple-darwin") {
Mark Simulacrum001e9f32017-07-05 01:41:43986 // Force /usr/bin/python on macOS for LLDB tests because we're loading the
987 // LLDB plugin's compiled module which only works with the system python
988 // (namely not Homebrew-installed python)
989 cmd.arg("--lldb-python").arg("/usr/bin/python");
990 } else {
Mark Simulacrumbe1e7892018-04-14 23:27:57991 cmd.arg("--lldb-python").arg(builder.python());
Mark Simulacrum001e9f32017-07-05 01:41:43992 }
Alex Crichtonb325baf2016-04-05 18:34:23993
Mark Simulacrumbe1e7892018-04-14 23:27:57994 if let Some(ref gdb) = builder.config.gdb {
Mark Simulacrum001e9f32017-07-05 01:41:43995 cmd.arg("--gdb").arg(gdb);
996 }
Mark Simulacrumbe1e7892018-04-14 23:27:57997 if let Some(ref vers) = builder.lldb_version {
Mark Simulacrum001e9f32017-07-05 01:41:43998 cmd.arg("--lldb-version").arg(vers);
999 }
Mark Simulacrumbe1e7892018-04-14 23:27:571000 if let Some(ref dir) = builder.lldb_python_dir {
Mark Simulacrum001e9f32017-07-05 01:41:431001 cmd.arg("--lldb-python-dir").arg(dir);
1002 }
Alex Crichtonb325baf2016-04-05 18:34:231003
Collins Abitekaniza41ee6fe2018-04-12 11:49:311004 // Get paths from cmd args
1005 let paths = match &builder.config.cmd {
1006 Subcommand::Test { ref paths, ..} => &paths[..],
1007 _ => &[]
1008 };
1009
1010 // Get test-args by striping suite path
1011 let assert_file = |p: &PathBuf| {
1012 assert!(p.is_file(), "Expected {:?} to be a path to a test file", p);
1013 return true
1014 };
1015 let mut test_args: Vec<&str> = paths.iter().filter(|p| p.starts_with(suite_path) &&
1016 assert_file(p)).map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap()).collect();
1017
1018 test_args.append(&mut builder.config.cmd.test_args());
1019
1020 cmd.args(&test_args);
Corey Farwellc8c6d2c2016-10-30 01:58:521021
Mark Simulacrumbe1e7892018-04-14 23:27:571022 if builder.is_verbose() {
Mark Simulacrum001e9f32017-07-05 01:41:431023 cmd.arg("--verbose");
1024 }
Alex Crichton126e09e2016-04-14 22:51:031025
Mark Simulacrumbe1e7892018-04-14 23:27:571026 if builder.config.quiet_tests {
Mark Simulacrum001e9f32017-07-05 01:41:431027 cmd.arg("--quiet");
1028 }
Alex Crichton1747ce22017-01-28 21:38:061029
Mark Simulacrumbe1e7892018-04-14 23:27:571030 if builder.config.llvm_enabled {
Alex Crichtonbe902e72018-03-05 17:47:541031 let llvm_config = builder.ensure(native::Llvm {
Mark Simulacrumbe1e7892018-04-14 23:27:571032 target: builder.config.build,
Alex Crichtonbe902e72018-03-05 17:47:541033 emscripten: false,
1034 });
Mark Simulacrumbe1e7892018-04-14 23:27:571035 if !builder.config.dry_run {
Mark Simulacrum0ce5cf02018-04-01 01:21:141036 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
1037 cmd.arg("--llvm-version").arg(llvm_version);
1038 }
Mark Simulacrumbe1e7892018-04-14 23:27:571039 if !builder.is_rust_llvm(target) {
bjorn30c97bbf2017-08-13 10:30:541040 cmd.arg("--system-llvm");
1041 }
1042
1043 // Only pass correct values for these flags for the `run-make` suite as it
1044 // requires that a C++ compiler was configured which isn't always the case.
Mark Simulacrumbe1e7892018-04-14 23:27:571045 if !builder.config.dry_run && suite == "run-make-fulldeps" {
bjorn30c97bbf2017-08-13 10:30:541046 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
1047 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
Mark Simulacrumbe1e7892018-04-14 23:27:571048 cmd.arg("--cc").arg(builder.cc(target))
1049 .arg("--cxx").arg(builder.cxx(target).unwrap())
1050 .arg("--cflags").arg(builder.cflags(target).join(" "))
bjorn30c97bbf2017-08-13 10:30:541051 .arg("--llvm-components").arg(llvm_components.trim())
1052 .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
Mark Simulacrumbe1e7892018-04-14 23:27:571053 if let Some(ar) = builder.ar(target) {
Oliver Schneideracdf83f2017-12-06 08:25:291054 cmd.arg("--ar").arg(ar);
1055 }
bjorn30c97bbf2017-08-13 10:30:541056 }
1057 }
Mark Simulacrumbe1e7892018-04-14 23:27:571058 if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
Mark Simulacrum545b92f2018-03-28 15:25:091059 builder.info(
1060 &format!("Ignoring run-make test suite as they generally don't work without LLVM"));
bjorn30c97bbf2017-08-13 10:30:541061 return;
1062 }
1063
Alex Crichton7df6f412018-03-09 17:26:151064 if suite != "run-make-fulldeps" {
Mark Simulacrum001e9f32017-07-05 01:41:431065 cmd.arg("--cc").arg("")
1066 .arg("--cxx").arg("")
1067 .arg("--cflags").arg("")
1068 .arg("--llvm-components").arg("")
1069 .arg("--llvm-cxxflags").arg("");
1070 }
1071
Mark Simulacrumbe1e7892018-04-14 23:27:571072 if builder.remote_tested(target) {
Mark Simulacrum6b3413d2017-07-05 12:41:271073 cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
Mark Simulacrum001e9f32017-07-05 01:41:431074 }
1075
1076 // Running a C compiler on MSVC requires a few env vars to be set, to be
1077 // sure to set them here.
1078 //
1079 // Note that if we encounter `PATH` we make sure to append to our own `PATH`
1080 // rather than stomp over it.
1081 if target.contains("msvc") {
Mark Simulacrumbe1e7892018-04-14 23:27:571082 for &(ref k, ref v) in builder.cc[&target].env() {
Mark Simulacrum001e9f32017-07-05 01:41:431083 if k != "PATH" {
1084 cmd.env(k, v);
1085 }
Alex Crichton126e09e2016-04-14 22:51:031086 }
1087 }
Mark Simulacrum001e9f32017-07-05 01:41:431088 cmd.env("RUSTC_BOOTSTRAP", "1");
Mark Simulacrumbe1e7892018-04-14 23:27:571089 builder.add_rust_test_threads(&mut cmd);
Mark Simulacrum001e9f32017-07-05 01:41:431090
Mark Simulacrumbe1e7892018-04-14 23:27:571091 if builder.config.sanitizers {
Mark Simulacrum001e9f32017-07-05 01:41:431092 cmd.env("SANITIZER_SUPPORT", "1");
1093 }
1094
Mark Simulacrumbe1e7892018-04-14 23:27:571095 if builder.config.profiler {
Mark Simulacrum001e9f32017-07-05 01:41:431096 cmd.env("PROFILER_SUPPORT", "1");
1097 }
1098
Mark Simulacrumbe1e7892018-04-14 23:27:571099 cmd.env("RUST_TEST_TMPDIR", builder.out.join("tmp"));
Alex Crichton884715c2018-01-22 15:29:241100
Mark Simulacrum001e9f32017-07-05 01:41:431101 cmd.arg("--adb-path").arg("adb");
1102 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
1103 if target.contains("android") {
1104 // Assume that cc for this target comes from the android sysroot
1105 cmd.arg("--android-cross-path")
Mark Simulacrumbe1e7892018-04-14 23:27:571106 .arg(builder.cc(target).parent().unwrap().parent().unwrap());
Mark Simulacrum001e9f32017-07-05 01:41:431107 } else {
1108 cmd.arg("--android-cross-path").arg("");
1109 }
1110
Mark Simulacrumbe1e7892018-04-14 23:27:571111 builder.ci_env.force_coloring_in_ci(&mut cmd);
Mark Simulacrum001e9f32017-07-05 01:41:431112
Mark Simulacrumbe1e7892018-04-14 23:27:571113 let _folder = builder.fold_output(|| format!("test_{}", suite));
Mark Simulacrum545b92f2018-03-28 15:25:091114 builder.info(&format!("Check compiletest suite={} mode={} ({} -> {})",
1115 suite, mode, &compiler.host, target));
Mark Simulacrumbe1e7892018-04-14 23:27:571116 let _time = util::timeit(&builder);
1117 try_run(builder, &mut cmd);
Felix S. Klock II55895502018-04-11 15:15:591118
1119 if let Some(compare_mode) = compare_mode {
1120 cmd.arg("--compare-mode").arg(compare_mode);
1121 let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode));
1122 builder.info(&format!("Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
1123 suite, mode, compare_mode, &compiler.host, target));
1124 let _time = util::timeit(&builder);
1125 try_run(builder, &mut cmd);
1126 }
Alex Crichton126e09e2016-04-14 22:51:031127 }
Alex Crichtonb325baf2016-04-05 18:34:231128}
Alex Crichtonede89442016-04-15 01:00:351129
Mark Simulacrum528646e2017-07-14 00:48:441130#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
kennytm0d300d42018-02-21 19:13:341131struct DocTest {
Mark Simulacrum528646e2017-07-14 00:48:441132 compiler: Compiler,
kennytm0d300d42018-02-21 19:13:341133 path: &'static str,
1134 name: &'static str,
1135 is_ext_doc: bool,
Mark Simulacruma5ab2ce2017-07-12 15:15:001136}
1137
kennytm0d300d42018-02-21 19:13:341138impl Step for DocTest {
Mark Simulacruma5ab2ce2017-07-12 15:15:001139 type Output = ();
Mark Simulacruma5ab2ce2017-07-12 15:15:001140 const ONLY_HOSTS: bool = true;
Alex Crichtonede89442016-04-15 01:00:351141
Mark Simulacrum56128fb2017-07-19 00:03:381142 fn should_run(run: ShouldRun) -> ShouldRun {
kennytm0d300d42018-02-21 19:13:341143 run.never()
Mark Simulacruma5ab2ce2017-07-12 15:15:001144 }
1145
1146 /// Run `rustdoc --test` for all documentation in `src/doc`.
1147 ///
1148 /// This will run all tests in our markdown documentation (e.g. the book)
1149 /// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
1150 /// `compiler`.
1151 fn run(self, builder: &Builder) {
Mark Simulacruma5ab2ce2017-07-12 15:15:001152 let compiler = self.compiler;
Mark Simulacrumceecd622017-07-12 16:12:471153
1154 builder.ensure(compile::Test { compiler, target: compiler.host });
1155
Mark Simulacruma5ab2ce2017-07-12 15:15:001156 // Do a breadth-first traversal of the `src/doc` directory and just run
1157 // tests for all files that end in `*.md`
Mark Simulacrumbe1e7892018-04-14 23:27:571158 let mut stack = vec![builder.src.join(self.path)];
1159 let _time = util::timeit(&builder);
1160 let _folder = builder.fold_output(|| format!("test_{}", self.name));
Mark Simulacruma5ab2ce2017-07-12 15:15:001161
Mark Simulacruma7274472018-03-27 14:06:471162 let mut files = Vec::new();
Mark Simulacruma5ab2ce2017-07-12 15:15:001163 while let Some(p) = stack.pop() {
1164 if p.is_dir() {
1165 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
1166 continue
1167 }
1168
1169 if p.extension().and_then(|s| s.to_str()) != Some("md") {
1170 continue;
1171 }
1172
1173 // The nostarch directory in the book is for no starch, and so isn't
Mark Simulacrumbe1e7892018-04-14 23:27:571174 // guaranteed to builder. We don't care if it doesn't build, so skip it.
Mark Simulacruma5ab2ce2017-07-12 15:15:001175 if p.to_str().map_or(false, |p| p.contains("nostarch")) {
1176 continue;
1177 }
1178
Mark Simulacruma7274472018-03-27 14:06:471179 files.push(p);
1180 }
1181
1182 files.sort();
1183
1184 for file in files {
1185 let test_result = markdown_test(builder, compiler, &file);
kennytma9f940e2018-02-21 19:25:231186 if self.is_ext_doc {
1187 let toolstate = if test_result {
1188 ToolState::TestPass
1189 } else {
1190 ToolState::TestFail
1191 };
Mark Simulacrumbe1e7892018-04-14 23:27:571192 builder.save_toolstate(self.name, toolstate);
kennytma9f940e2018-02-21 19:25:231193 }
Alex Crichtonede89442016-04-15 01:00:351194 }
Alex Crichtonede89442016-04-15 01:00:351195 }
1196}
1197
kennytm0d300d42018-02-21 19:13:341198macro_rules! test_book {
1199 ($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => {
1200 $(
1201 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1202 pub struct $name {
1203 compiler: Compiler,
1204 }
1205
1206 impl Step for $name {
1207 type Output = ();
1208 const DEFAULT: bool = $default;
1209 const ONLY_HOSTS: bool = true;
1210
1211 fn should_run(run: ShouldRun) -> ShouldRun {
1212 run.path($path)
1213 }
1214
1215 fn make_run(run: RunConfig) {
1216 run.builder.ensure($name {
1217 compiler: run.builder.compiler(run.builder.top_stage, run.host),
1218 });
1219 }
1220
1221 fn run(self, builder: &Builder) {
1222 builder.ensure(DocTest {
1223 compiler: self.compiler,
1224 path: $path,
1225 name: $book_name,
1226 is_ext_doc: !$default,
1227 });
1228 }
1229 }
1230 )+
1231 }
1232}
1233
1234test_book!(
1235 Nomicon, "src/doc/nomicon", "nomicon", default=false;
1236 Reference, "src/doc/reference", "reference", default=false;
1237 RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
1238 RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
1239 TheBook, "src/doc/book", "book", default=false;
1240 UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
1241);
1242
Mark Simulacrum528646e2017-07-14 00:48:441243#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1244pub struct ErrorIndex {
1245 compiler: Compiler,
Mark Simulacrum001e9f32017-07-05 01:41:431246}
Alex Crichton0e272de2016-11-16 20:31:191247
Mark Simulacrum528646e2017-07-14 00:48:441248impl Step for ErrorIndex {
Mark Simulacrum001e9f32017-07-05 01:41:431249 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271250 const DEFAULT: bool = true;
1251 const ONLY_HOSTS: bool = true;
1252
Mark Simulacrum56128fb2017-07-19 00:03:381253 fn should_run(run: ShouldRun) -> ShouldRun {
1254 run.path("src/tools/error_index_generator")
Mark Simulacrum6b3413d2017-07-05 12:41:271255 }
1256
Mark Simulacrum6a67a052017-07-20 23:51:071257 fn make_run(run: RunConfig) {
1258 run.builder.ensure(ErrorIndex {
1259 compiler: run.builder.compiler(run.builder.top_stage, run.host),
Mark Simulacrum6b3413d2017-07-05 12:41:271260 });
1261 }
Alex Crichtonede89442016-04-15 01:00:351262
Mark Simulacrum001e9f32017-07-05 01:41:431263 /// Run the error index generator tool to execute the tests located in the error
1264 /// index.
1265 ///
1266 /// The `error_index_generator` tool lives in `src/tools` and is used to
1267 /// generate a markdown file from the error indexes of the code base which is
1268 /// then passed to `rustdoc --test`.
1269 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:431270 let compiler = self.compiler;
1271
Mark Simulacrum6b3413d2017-07-05 12:41:271272 builder.ensure(compile::Std { compiler, target: compiler.host });
1273
Mark Simulacrumbe1e7892018-04-14 23:27:571274 let dir = testdir(builder, compiler.host);
Mark Simulacrum001e9f32017-07-05 01:41:431275 t!(fs::create_dir_all(&dir));
1276 let output = dir.join("error-index.md");
1277
Alex Crichton6fd4d672018-03-16 15:35:031278 let mut tool = builder.tool_cmd(Tool::ErrorIndex);
1279 tool.arg("markdown")
1280 .arg(&output)
Mark Simulacrumbe1e7892018-04-14 23:27:571281 .env("CFG_BUILD", &builder.config.build)
1282 .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
Mark Simulacrum001e9f32017-07-05 01:41:431283
Alex Crichton6fd4d672018-03-16 15:35:031284
Mark Simulacrumbe1e7892018-04-14 23:27:571285 let _folder = builder.fold_output(|| "test_error_index");
1286 builder.info(&format!("Testing error-index stage{}", compiler.stage));
1287 let _time = util::timeit(&builder);
1288 builder.run(&mut tool);
Mark Simulacrumc114fe52017-07-05 17:21:331289 markdown_test(builder, compiler, &output);
Mark Simulacrum001e9f32017-07-05 01:41:431290 }
Alex Crichtonede89442016-04-15 01:00:351291}
1292
kennytma9f940e2018-02-21 19:25:231293fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool {
Mark Simulacrum0ce5cf02018-04-01 01:21:141294 match File::open(markdown) {
1295 Ok(mut file) => {
1296 let mut contents = String::new();
1297 t!(file.read_to_string(&mut contents));
1298 if !contents.contains("```") {
1299 return true;
1300 }
1301 }
1302 Err(_) => {},
Mark Simulacrumdd1d75e2017-06-04 23:55:501303 }
1304
Mark Simulacrumbe1e7892018-04-14 23:27:571305 builder.info(&format!("doc tests for: {}", markdown.display()));
Mark Simulacrumfacf5a92017-08-04 22:13:011306 let mut cmd = builder.rustdoc_cmd(compiler.host);
Mark Simulacrumbe1e7892018-04-14 23:27:571307 builder.add_rust_test_threads(&mut cmd);
Alex Crichtonede89442016-04-15 01:00:351308 cmd.arg("--test");
1309 cmd.arg(markdown);
Alex Crichton6f62fae2016-12-12 17:03:351310 cmd.env("RUSTC_BOOTSTRAP", "1");
Corey Farwellc8c6d2c2016-10-30 01:58:521311
Mark Simulacrumbe1e7892018-04-14 23:27:571312 let test_args = builder.config.cmd.test_args().join(" ");
Corey Farwellc8c6d2c2016-10-30 01:58:521313 cmd.arg("--test-args").arg(test_args);
1314
Mark Simulacrumbe1e7892018-04-14 23:27:571315 if builder.config.quiet_tests {
1316 try_run_quiet(builder, &mut cmd)
kennytm6ac07872017-05-21 20:27:471317 } else {
Mark Simulacrumbe1e7892018-04-14 23:27:571318 try_run(builder, &mut cmd)
kennytm6ac07872017-05-21 20:27:471319 }
Alex Crichtonede89442016-04-15 01:00:351320}
Alex Crichtonbb9062a2016-04-29 21:23:151321
Mark Simulacrum528646e2017-07-14 00:48:441322#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum981afa52017-07-18 21:28:531323pub struct CrateLibrustc {
Mark Simulacrum528646e2017-07-14 00:48:441324 compiler: Compiler,
1325 target: Interned<String>,
Mark Simulacrum6b3413d2017-07-05 12:41:271326 test_kind: TestKind,
Mark Simulacrumf104b122018-02-11 16:51:581327 krate: Interned<String>,
Mark Simulacrum6b3413d2017-07-05 12:41:271328}
1329
Mark Simulacrum981afa52017-07-18 21:28:531330impl Step for CrateLibrustc {
Mark Simulacrum6b3413d2017-07-05 12:41:271331 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271332 const DEFAULT: bool = true;
1333 const ONLY_HOSTS: bool = true;
1334
Mark Simulacrum56128fb2017-07-19 00:03:381335 fn should_run(run: ShouldRun) -> ShouldRun {
1336 run.krate("rustc-main")
Mark Simulacrum6b3413d2017-07-05 12:41:271337 }
1338
Mark Simulacrum6a67a052017-07-20 23:51:071339 fn make_run(run: RunConfig) {
1340 let builder = run.builder;
1341 let compiler = builder.compiler(builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:271342
Mark Simulacrumf104b122018-02-11 16:51:581343 for krate in builder.in_tree_crates("rustc-main") {
1344 if run.path.ends_with(&krate.path) {
1345 let test_kind = if builder.kind == Kind::Test {
1346 TestKind::Test
1347 } else if builder.kind == Kind::Bench {
1348 TestKind::Bench
1349 } else {
1350 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
1351 };
Mark Simulacrum6b3413d2017-07-05 12:41:271352
Mark Simulacrumf104b122018-02-11 16:51:581353 builder.ensure(CrateLibrustc {
1354 compiler,
1355 target: run.target,
1356 test_kind,
1357 krate: krate.name,
1358 });
Mark Simulacrum6b3413d2017-07-05 12:41:271359 }
Mark Simulacrum6b3413d2017-07-05 12:41:271360 }
1361 }
1362
Mark Simulacrum6b3413d2017-07-05 12:41:271363 fn run(self, builder: &Builder) {
Mark Simulacrum981afa52017-07-18 21:28:531364 builder.ensure(Crate {
Mark Simulacrum6b3413d2017-07-05 12:41:271365 compiler: self.compiler,
1366 target: self.target,
1367 mode: Mode::Librustc,
1368 test_kind: self.test_kind,
1369 krate: self.krate,
1370 });
1371 }
1372}
1373
Mark Simulacrum528646e2017-07-14 00:48:441374#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrumf104b122018-02-11 16:51:581375pub struct CrateNotDefault {
Mark Simulacrum528646e2017-07-14 00:48:441376 compiler: Compiler,
1377 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431378 test_kind: TestKind,
Mark Simulacrumf104b122018-02-11 16:51:581379 krate: &'static str,
Mark Simulacrum001e9f32017-07-05 01:41:431380}
Alex Crichtonbb9062a2016-04-29 21:23:151381
Mark Simulacrumf104b122018-02-11 16:51:581382impl Step for CrateNotDefault {
Mark Simulacrum001e9f32017-07-05 01:41:431383 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271384
Mark Simulacrum56128fb2017-07-19 00:03:381385 fn should_run(run: ShouldRun) -> ShouldRun {
Mark Simulacrumf104b122018-02-11 16:51:581386 run.path("src/liballoc_jemalloc")
1387 .path("src/librustc_asan")
1388 .path("src/librustc_lsan")
1389 .path("src/librustc_msan")
1390 .path("src/librustc_tsan")
Mark Simulacrum6b3413d2017-07-05 12:41:271391 }
1392
Mark Simulacrum6a67a052017-07-20 23:51:071393 fn make_run(run: RunConfig) {
1394 let builder = run.builder;
1395 let compiler = builder.compiler(builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:271396
Mark Simulacrumf104b122018-02-11 16:51:581397 let test_kind = if builder.kind == Kind::Test {
1398 TestKind::Test
1399 } else if builder.kind == Kind::Bench {
1400 TestKind::Bench
1401 } else {
1402 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
1403 };
1404
1405 builder.ensure(CrateNotDefault {
1406 compiler,
1407 target: run.target,
1408 test_kind,
1409 krate: match run.path {
1410 _ if run.path.ends_with("src/liballoc_jemalloc") => "alloc_jemalloc",
1411 _ if run.path.ends_with("src/librustc_asan") => "rustc_asan",
1412 _ if run.path.ends_with("src/librustc_lsan") => "rustc_lsan",
1413 _ if run.path.ends_with("src/librustc_msan") => "rustc_msan",
1414 _ if run.path.ends_with("src/librustc_tsan") => "rustc_tsan",
1415 _ => panic!("unexpected path {:?}", run.path),
1416 },
1417 });
1418 }
1419
1420 fn run(self, builder: &Builder) {
1421 builder.ensure(Crate {
1422 compiler: self.compiler,
1423 target: self.target,
1424 mode: Mode::Libstd,
1425 test_kind: self.test_kind,
1426 krate: INTERNER.intern_str(self.krate),
1427 });
1428 }
1429}
1430
1431
1432#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1433pub struct Crate {
1434 compiler: Compiler,
1435 target: Interned<String>,
1436 mode: Mode,
1437 test_kind: TestKind,
1438 krate: Interned<String>,
1439}
1440
1441impl Step for Crate {
1442 type Output = ();
1443 const DEFAULT: bool = true;
1444
1445 fn should_run(mut run: ShouldRun) -> ShouldRun {
1446 let builder = run.builder;
1447 run = run.krate("test");
1448 for krate in run.builder.in_tree_crates("std") {
1449 if krate.is_local(&run.builder) &&
1450 !krate.name.contains("jemalloc") &&
1451 !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) &&
1452 krate.name != "dlmalloc" {
1453 run = run.path(krate.local_path(&builder).to_str().unwrap());
1454 }
1455 }
1456 run
1457 }
1458
1459 fn make_run(run: RunConfig) {
1460 let builder = run.builder;
1461 let compiler = builder.compiler(builder.top_stage, run.host);
1462
1463 let make = |mode: Mode, krate: &CargoCrate| {
Mark Simulacrum6b3413d2017-07-05 12:41:271464 let test_kind = if builder.kind == Kind::Test {
1465 TestKind::Test
1466 } else if builder.kind == Kind::Bench {
1467 TestKind::Bench
1468 } else {
Mark Simulacrum981afa52017-07-18 21:28:531469 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
Mark Simulacrum6b3413d2017-07-05 12:41:271470 };
1471
Mark Simulacrum981afa52017-07-18 21:28:531472 builder.ensure(Crate {
Mark Simulacrum6a67a052017-07-20 23:51:071473 compiler,
1474 target: run.target,
Zack M. Davis1b6c9602017-08-07 05:54:091475 mode,
1476 test_kind,
Mark Simulacrumf104b122018-02-11 16:51:581477 krate: krate.name,
Mark Simulacrum6b3413d2017-07-05 12:41:271478 });
1479 };
1480
Mark Simulacrumf104b122018-02-11 16:51:581481 for krate in builder.in_tree_crates("std") {
1482 if run.path.ends_with(&krate.local_path(&builder)) {
1483 make(Mode::Libstd, krate);
Mark Simulacrum6b3413d2017-07-05 12:41:271484 }
Mark Simulacrumf104b122018-02-11 16:51:581485 }
1486 for krate in builder.in_tree_crates("test") {
1487 if run.path.ends_with(&krate.local_path(&builder)) {
1488 make(Mode::Libtest, krate);
Mark Simulacrum6b3413d2017-07-05 12:41:271489 }
Mark Simulacrum6b3413d2017-07-05 12:41:271490 }
1491 }
Alex Crichton7046fea2016-12-25 23:20:331492
Mark Simulacrumf104b122018-02-11 16:51:581493 /// Run all unit tests plus documentation tests for a given crate defined
1494 /// by a `Cargo.toml` (single manifest)
Mark Simulacrum001e9f32017-07-05 01:41:431495 ///
1496 /// This is what runs tests for crates like the standard library, compiler, etc.
1497 /// It essentially is the driver for running `cargo test`.
1498 ///
1499 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
1500 /// arguments, and those arguments are discovered from `cargo metadata`.
1501 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:431502 let compiler = self.compiler;
1503 let target = self.target;
1504 let mode = self.mode;
1505 let test_kind = self.test_kind;
1506 let krate = self.krate;
Alex Crichtonbb9062a2016-04-29 21:23:151507
Mark Simulacrum6b3413d2017-07-05 12:41:271508 builder.ensure(compile::Test { compiler, target });
1509 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431510
1511 // If we're not doing a full bootstrap but we're testing a stage2 version of
1512 // libstd, then what we're actually testing is the libstd produced in
1513 // stage1. Reflect that here by updating the compiler that we're working
1514 // with automatically.
Mark Simulacrumbe1e7892018-04-14 23:27:571515 let compiler = if builder.force_use_stage1(compiler, target) {
Mark Simulacrum6b3413d2017-07-05 12:41:271516 builder.compiler(1, compiler.host)
Mark Simulacrum001e9f32017-07-05 01:41:431517 } else {
1518 compiler.clone()
1519 };
1520
Alex Crichton90105672017-07-17 16:32:081521 let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
Mark Simulacrumf104b122018-02-11 16:51:581522 match mode {
Alex Crichton90105672017-07-17 16:32:081523 Mode::Libstd => {
Alex Crichtonbe902e72018-03-05 17:47:541524 compile::std_cargo(builder, &compiler, target, &mut cargo);
Alex Crichton90105672017-07-17 16:32:081525 }
1526 Mode::Libtest => {
Mark Simulacrumbe1e7892018-04-14 23:27:571527 compile::test_cargo(builder, &compiler, target, &mut cargo);
Alex Crichton90105672017-07-17 16:32:081528 }
1529 Mode::Librustc => {
1530 builder.ensure(compile::Rustc { compiler, target });
Mark Simulacrumbe1e7892018-04-14 23:27:571531 compile::rustc_cargo(builder, &mut cargo);
Alex Crichton90105672017-07-17 16:32:081532 }
1533 _ => panic!("can only test libraries"),
1534 };
Alex Crichton90105672017-07-17 16:32:081535
Mark Simulacrum001e9f32017-07-05 01:41:431536 // Build up the base `cargo test` command.
1537 //
1538 // Pass in some standard flags then iterate over the graph we've discovered
1539 // in `cargo metadata` with the maps above and figure out what `-p`
1540 // arguments need to get passed.
Mark Simulacrumbe1e7892018-04-14 23:27:571541 if test_kind.subcommand() == "test" && !builder.fail_fast {
Mark Simulacrum001e9f32017-07-05 01:41:431542 cargo.arg("--no-fail-fast");
Alex Crichtonbb9062a2016-04-29 21:23:151543 }
Mark Simulacrumbe1e7892018-04-14 23:27:571544 if builder.doc_tests {
Guillaume Gomez8e469272018-02-17 14:45:391545 cargo.arg("--doc");
1546 }
Mark Simulacrum001e9f32017-07-05 01:41:431547
Mark Simulacrumf104b122018-02-11 16:51:581548 cargo.arg("-p").arg(krate);
Alex Crichtonbb9062a2016-04-29 21:23:151549
Mark Simulacrum001e9f32017-07-05 01:41:431550 // The tests are going to run with the *target* libraries, so we need to
1551 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
1552 //
1553 // Note that to run the compiler we need to run with the *host* libraries,
1554 // but our wrapper scripts arrange for that to be the case anyway.
1555 let mut dylib_path = dylib_path();
Mark Simulacrum528646e2017-07-14 00:48:441556 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
Mark Simulacrum001e9f32017-07-05 01:41:431557 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
Alex Crichtonbb9062a2016-04-29 21:23:151558
Mark Simulacrum001e9f32017-07-05 01:41:431559 cargo.arg("--");
Mark Simulacrumbe1e7892018-04-14 23:27:571560 cargo.args(&builder.config.cmd.test_args());
Alex Crichton0e272de2016-11-16 20:31:191561
Mark Simulacrumbe1e7892018-04-14 23:27:571562 if builder.config.quiet_tests {
Mark Simulacrum001e9f32017-07-05 01:41:431563 cargo.arg("--quiet");
1564 }
Corey Farwellc8c6d2c2016-10-30 01:58:521565
Mark Simulacrum001e9f32017-07-05 01:41:431566 if target.contains("emscripten") {
Alex Crichton8e7849e2017-07-29 00:52:441567 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
Mark Simulacrumbe1e7892018-04-14 23:27:571568 builder.config.nodejs.as_ref().expect("nodejs not configured"));
Oliver Schneideracdf83f2017-12-06 08:25:291569 } else if target.starts_with("wasm32") {
Diggory Blake0e6601f2018-01-11 17:51:491570 // Warn about running tests without the `wasm_syscall` feature enabled.
1571 // The javascript shim implements the syscall interface so that test
1572 // output can be correctly reported.
Mark Simulacrumbe1e7892018-04-14 23:27:571573 if !builder.config.wasm_syscall {
1574 builder.info(&format!("Libstd was built without `wasm_syscall` feature enabled: \
Mark Simulacrum545b92f2018-03-28 15:25:091575 test output may not be visible."));
Diggory Blake0e6601f2018-01-11 17:51:491576 }
1577
Oliver Schneideracdf83f2017-12-06 08:25:291578 // On the wasm32-unknown-unknown target we're using LTO which is
1579 // incompatible with `-C prefer-dynamic`, so disable that here
1580 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
1581
Mark Simulacrumbe1e7892018-04-14 23:27:571582 let node = builder.config.nodejs.as_ref()
Oliver Schneideracdf83f2017-12-06 08:25:291583 .expect("nodejs not configured");
1584 let runner = format!("{} {}/src/etc/wasm32-shim.js",
1585 node.display(),
Mark Simulacrumbe1e7892018-04-14 23:27:571586 builder.src.display());
Oliver Schneideracdf83f2017-12-06 08:25:291587 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner);
Mark Simulacrumbe1e7892018-04-14 23:27:571588 } else if builder.remote_tested(target) {
Alex Crichton8e7849e2017-07-29 00:52:441589 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1590 format!("{} run",
1591 builder.tool_exe(Tool::RemoteTestClient).display()));
Mark Simulacrum001e9f32017-07-05 01:41:431592 }
Alex Crichton6fd4d672018-03-16 15:35:031593
Mark Simulacrumbe1e7892018-04-14 23:27:571594 let _folder = builder.fold_output(|| {
Alex Crichton6fd4d672018-03-16 15:35:031595 format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate)
1596 });
Mark Simulacrumbe1e7892018-04-14 23:27:571597 builder.info(&format!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage,
Mark Simulacrum545b92f2018-03-28 15:25:091598 &compiler.host, target));
Mark Simulacrumbe1e7892018-04-14 23:27:571599 let _time = util::timeit(&builder);
1600 try_run(builder, &mut cargo);
Alex Crichton39a5d3f2016-06-28 20:31:301601 }
1602}
1603
Mark Simulacrumf87696b2017-09-02 14:02:321604#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrumf104b122018-02-11 16:51:581605pub struct CrateRustdoc {
Mark Simulacrumf87696b2017-09-02 14:02:321606 host: Interned<String>,
1607 test_kind: TestKind,
1608}
1609
Mark Simulacrumf104b122018-02-11 16:51:581610impl Step for CrateRustdoc {
Mark Simulacrumf87696b2017-09-02 14:02:321611 type Output = ();
1612 const DEFAULT: bool = true;
1613 const ONLY_HOSTS: bool = true;
1614
1615 fn should_run(run: ShouldRun) -> ShouldRun {
Mark Simulacrumf104b122018-02-11 16:51:581616 run.paths(&["src/librustdoc", "src/tools/rustdoc"])
Mark Simulacrumf87696b2017-09-02 14:02:321617 }
1618
1619 fn make_run(run: RunConfig) {
1620 let builder = run.builder;
1621
1622 let test_kind = if builder.kind == Kind::Test {
1623 TestKind::Test
1624 } else if builder.kind == Kind::Bench {
1625 TestKind::Bench
1626 } else {
1627 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
1628 };
1629
Mark Simulacrumf104b122018-02-11 16:51:581630 builder.ensure(CrateRustdoc {
Mark Simulacrumf87696b2017-09-02 14:02:321631 host: run.host,
1632 test_kind,
1633 });
1634 }
1635
1636 fn run(self, builder: &Builder) {
Mark Simulacrumf87696b2017-09-02 14:02:321637 let test_kind = self.test_kind;
1638
1639 let compiler = builder.compiler(builder.top_stage, self.host);
1640 let target = compiler.host;
1641
Alex Crichton3da54fb2017-09-15 22:28:591642 let mut cargo = tool::prepare_tool_cargo(builder,
1643 compiler,
1644 target,
1645 test_kind.subcommand(),
1646 "src/tools/rustdoc");
Mark Simulacrumbe1e7892018-04-14 23:27:571647 if test_kind.subcommand() == "test" && !builder.fail_fast {
Mark Simulacrumf87696b2017-09-02 14:02:321648 cargo.arg("--no-fail-fast");
1649 }
1650
1651 cargo.arg("-p").arg("rustdoc:0.0.0");
1652
1653 cargo.arg("--");
Mark Simulacrumbe1e7892018-04-14 23:27:571654 cargo.args(&builder.config.cmd.test_args());
Mark Simulacrumf87696b2017-09-02 14:02:321655
Mark Simulacrumbe1e7892018-04-14 23:27:571656 if builder.config.quiet_tests {
Mark Simulacrumf87696b2017-09-02 14:02:321657 cargo.arg("--quiet");
1658 }
1659
Mark Simulacrumbe1e7892018-04-14 23:27:571660 let _folder = builder.fold_output(|| {
Alex Crichton6fd4d672018-03-16 15:35:031661 format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
1662 });
Mark Simulacrumbe1e7892018-04-14 23:27:571663 builder.info(&format!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
Mark Simulacrum545b92f2018-03-28 15:25:091664 &compiler.host, target));
Mark Simulacrumbe1e7892018-04-14 23:27:571665 let _time = util::timeit(&builder);
Mark Simulacrumf87696b2017-09-02 14:02:321666
Mark Simulacrumbe1e7892018-04-14 23:27:571667 try_run(builder, &mut cargo);
Mark Simulacrumf87696b2017-09-02 14:02:321668 }
1669}
1670
Alex Crichton8e7849e2017-07-29 00:52:441671fn envify(s: &str) -> String {
1672 s.chars().map(|c| {
1673 match c {
1674 '-' => '_',
1675 c => c,
Alex Crichton1747ce22017-01-28 21:38:061676 }
Alex Crichton8e7849e2017-07-29 00:52:441677 }).flat_map(|c| c.to_uppercase()).collect()
Alex Crichton39a5d3f2016-06-28 20:31:301678}
1679
Mark Simulacrumceecd622017-07-12 16:12:471680/// Some test suites are run inside emulators or on remote devices, and most
1681/// of our test binaries are linked dynamically which means we need to ship
1682/// the standard library and such to the emulator ahead of time. This step
1683/// represents this and is a dependency of all test suites.
1684///
1685/// Most of the time this is a noop. For some steps such as shipping data to
1686/// QEMU we have to build our own tools so we've got conditional dependencies
1687/// on those programs as well. Note that the remote test client is built for
1688/// the build target (us) and the server is built for the target.
Mark Simulacrum528646e2017-07-14 00:48:441689#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1690pub struct RemoteCopyLibs {
1691 compiler: Compiler,
1692 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431693}
Alex Crichton1747ce22017-01-28 21:38:061694
Mark Simulacrum528646e2017-07-14 00:48:441695impl Step for RemoteCopyLibs {
Mark Simulacrum001e9f32017-07-05 01:41:431696 type Output = ();
Alex Crichton1747ce22017-01-28 21:38:061697
Mark Simulacrum56128fb2017-07-19 00:03:381698 fn should_run(run: ShouldRun) -> ShouldRun {
1699 run.never()
Mark Simulacrum681b1232017-07-14 12:30:161700 }
1701
Mark Simulacrum001e9f32017-07-05 01:41:431702 fn run(self, builder: &Builder) {
Mark Simulacrum001e9f32017-07-05 01:41:431703 let compiler = self.compiler;
1704 let target = self.target;
Mark Simulacrumbe1e7892018-04-14 23:27:571705 if !builder.remote_tested(target) {
Mark Simulacrum001e9f32017-07-05 01:41:431706 return
1707 }
Alex Crichton1747ce22017-01-28 21:38:061708
Mark Simulacrum6b3413d2017-07-05 12:41:271709 builder.ensure(compile::Test { compiler, target });
1710
Mark Simulacrumbe1e7892018-04-14 23:27:571711 builder.info(&format!("REMOTE copy libs to emulator ({})", target));
1712 t!(fs::create_dir_all(builder.out.join("tmp")));
Mark Simulacrum001e9f32017-07-05 01:41:431713
Mark Simulacrumfe0eca02017-07-23 01:29:081714 let server = builder.ensure(tool::RemoteTestServer { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431715
1716 // Spawn the emulator and wait for it to come online
Mark Simulacrum6b3413d2017-07-05 12:41:271717 let tool = builder.tool_exe(Tool::RemoteTestClient);
Mark Simulacrum001e9f32017-07-05 01:41:431718 let mut cmd = Command::new(&tool);
1719 cmd.arg("spawn-emulator")
1720 .arg(target)
1721 .arg(&server)
Mark Simulacrumbe1e7892018-04-14 23:27:571722 .arg(builder.out.join("tmp"));
1723 if let Some(rootfs) = builder.qemu_rootfs(target) {
Mark Simulacrum001e9f32017-07-05 01:41:431724 cmd.arg(rootfs);
1725 }
Mark Simulacrumbe1e7892018-04-14 23:27:571726 builder.run(&mut cmd);
Mark Simulacrum001e9f32017-07-05 01:41:431727
1728 // Push all our dylibs to the emulator
Mark Simulacrum60388302017-07-05 16:46:411729 for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
Mark Simulacrum001e9f32017-07-05 01:41:431730 let f = t!(f);
1731 let name = f.file_name().into_string().unwrap();
1732 if util::is_dylib(&name) {
Mark Simulacrumbe1e7892018-04-14 23:27:571733 builder.run(Command::new(&tool)
Mark Simulacrum001e9f32017-07-05 01:41:431734 .arg("push")
1735 .arg(f.path()));
1736 }
Alex Crichton1747ce22017-01-28 21:38:061737 }
1738 }
1739}
1740
Mark Simulacrum528646e2017-07-14 00:48:441741#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431742pub struct Distcheck;
1743
Mark Simulacrum528646e2017-07-14 00:48:441744impl Step for Distcheck {
Mark Simulacrum001e9f32017-07-05 01:41:431745 type Output = ();
1746
Mark Simulacrum56128fb2017-07-19 00:03:381747 fn should_run(run: ShouldRun) -> ShouldRun {
1748 run.path("distcheck")
Mark Simulacrum681b1232017-07-14 12:30:161749 }
1750
Mark Simulacrum8f2e5762017-07-22 13:35:421751 fn make_run(run: RunConfig) {
1752 run.builder.ensure(Distcheck);
1753 }
1754
Mark Simulacrum001e9f32017-07-05 01:41:431755 /// Run "distcheck", a 'make check' from a tarball
1756 fn run(self, builder: &Builder) {
Mark Simulacrumbe1e7892018-04-14 23:27:571757 builder.info(&format!("Distcheck"));
1758 let dir = builder.out.join("tmp").join("distcheck");
Mark Simulacrum001e9f32017-07-05 01:41:431759 let _ = fs::remove_dir_all(&dir);
1760 t!(fs::create_dir_all(&dir));
1761
Mark Simulacrum1c118232017-07-22 16:48:291762 // Guarantee that these are built before we begin running.
1763 builder.ensure(dist::PlainSourceTarball);
1764 builder.ensure(dist::Src);
1765
Mark Simulacrum001e9f32017-07-05 01:41:431766 let mut cmd = Command::new("tar");
1767 cmd.arg("-xzf")
Mark Simulacrum5984e702017-07-13 00:52:311768 .arg(builder.ensure(dist::PlainSourceTarball))
Mark Simulacrum001e9f32017-07-05 01:41:431769 .arg("--strip-components=1")
1770 .current_dir(&dir);
Mark Simulacrumbe1e7892018-04-14 23:27:571771 builder.run(&mut cmd);
1772 builder.run(Command::new("./configure")
1773 .args(&builder.config.configure_args)
Mark Simulacrum001e9f32017-07-05 01:41:431774 .arg("--enable-vendor")
1775 .current_dir(&dir));
Mark Simulacrumbe1e7892018-04-14 23:27:571776 builder.run(Command::new(build_helper::make(&builder.config.build))
Mark Simulacrum001e9f32017-07-05 01:41:431777 .arg("check")
1778 .current_dir(&dir));
1779
1780 // Now make sure that rust-src has all of libstd's dependencies
Mark Simulacrumbe1e7892018-04-14 23:27:571781 builder.info(&format!("Distcheck rust-src"));
1782 let dir = builder.out.join("tmp").join("distcheck-src");
Mark Simulacrum001e9f32017-07-05 01:41:431783 let _ = fs::remove_dir_all(&dir);
1784 t!(fs::create_dir_all(&dir));
1785
1786 let mut cmd = Command::new("tar");
1787 cmd.arg("-xzf")
Mark Simulacrum5984e702017-07-13 00:52:311788 .arg(builder.ensure(dist::Src))
Mark Simulacrum001e9f32017-07-05 01:41:431789 .arg("--strip-components=1")
1790 .current_dir(&dir);
Mark Simulacrumbe1e7892018-04-14 23:27:571791 builder.run(&mut cmd);
Mark Simulacrum001e9f32017-07-05 01:41:431792
1793 let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
Mark Simulacrumbe1e7892018-04-14 23:27:571794 builder.run(Command::new(&builder.initial_cargo)
Mark Simulacrum001e9f32017-07-05 01:41:431795 .arg("generate-lockfile")
1796 .arg("--manifest-path")
1797 .arg(&toml)
1798 .current_dir(&dir));
Alex Crichtond38db822016-12-09 01:13:551799 }
Alex Crichtond38db822016-12-09 01:13:551800}
Alex Crichton1a040b32016-12-31 03:50:571801
Mark Simulacrum528646e2017-07-14 00:48:441802#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431803pub struct Bootstrap;
1804
Mark Simulacrum528646e2017-07-14 00:48:441805impl Step for Bootstrap {
Mark Simulacrum001e9f32017-07-05 01:41:431806 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271807 const DEFAULT: bool = true;
1808 const ONLY_HOSTS: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:431809
1810 /// Test the build system itself
1811 fn run(self, builder: &Builder) {
Mark Simulacrumbe1e7892018-04-14 23:27:571812 let mut cmd = Command::new(&builder.initial_cargo);
Mark Simulacrum001e9f32017-07-05 01:41:431813 cmd.arg("test")
Mark Simulacrumbe1e7892018-04-14 23:27:571814 .current_dir(builder.src.join("src/bootstrap"))
Mark Simulacrum42fde212018-03-10 14:03:061815 .env("RUSTFLAGS", "-Cdebuginfo=2")
Mark Simulacrumbe1e7892018-04-14 23:27:571816 .env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
Mark Simulacrum001e9f32017-07-05 01:41:431817 .env("RUSTC_BOOTSTRAP", "1")
Mark Simulacrumbe1e7892018-04-14 23:27:571818 .env("RUSTC", &builder.initial_rustc);
Simon Sapine993e622018-03-23 18:55:411819 if let Some(flags) = option_env!("RUSTFLAGS") {
1820 // Use the same rustc flags for testing as for "normal" compilation,
1821 // so that Cargo doesn’t recompile the entire dependency graph every time:
1822 // https://github.com/rust-lang/rust/issues/49215
1823 cmd.env("RUSTFLAGS", flags);
1824 }
Mark Simulacrumbe1e7892018-04-14 23:27:571825 if !builder.fail_fast {
Mark Simulacrum001e9f32017-07-05 01:41:431826 cmd.arg("--no-fail-fast");
1827 }
Mark Simulacrumbe1e7892018-04-14 23:27:571828 cmd.arg("--").args(&builder.config.cmd.test_args());
1829 try_run(builder, &mut cmd);
Josh Stone617aea42017-06-02 16:27:441830 }
Mark Simulacrum6b3413d2017-07-05 12:41:271831
Mark Simulacrum56128fb2017-07-19 00:03:381832 fn should_run(run: ShouldRun) -> ShouldRun {
1833 run.path("src/bootstrap")
Mark Simulacrum6b3413d2017-07-05 12:41:271834 }
1835
Mark Simulacrum6a67a052017-07-20 23:51:071836 fn make_run(run: RunConfig) {
1837 run.builder.ensure(Bootstrap);
Mark Simulacrum6b3413d2017-07-05 12:41:271838 }
Alex Crichton1a040b32016-12-31 03:50:571839}