blob: 78ec2579c4aa7c4383d71af2dd3bc6aa0d8e80cd [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 Crichtona270b802016-10-21 20:18:0916use std::collections::HashSet;
Alex Crichtonbb9062a2016-04-29 21:23:1517use std::env;
Nick Cameron04415dc2017-06-30 18:58:5418use std::ffi::OsString;
Mark Simulacrum5b44cbc2017-06-26 16:23:5019use std::iter;
Ulrik Sverdrupb1566ba2016-11-25 21:13:5920use std::fmt;
Mark Simulacrumdd1d75e2017-06-04 23:55:5021use std::fs::{self, File};
Alex Crichtonede89442016-04-15 01:00:3522use std::path::{PathBuf, Path};
23use std::process::Command;
Mark Simulacrumdd1d75e2017-06-04 23:55:5024use std::io::Read;
Alex Crichton73c2d2a2016-04-14 21:27:5125
Oliver Schneiderab018c72017-08-30 16:59:2626use build_helper::{self, output, BuildExpectation};
Alex Crichton126e09e2016-04-14 22:51:0327
Mark Simulacrum6a67a052017-07-20 23:51:0728use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step};
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};
35use {Build, Mode};
Oliver Schneiderab018c72017-08-30 16:59:2636use toolstate::ToolState;
Alex Crichton39a5d3f2016-06-28 20:31:3037
Mark Simulacrum5b44cbc2017-06-26 16:23:5038const ADB_TEST_DIR: &str = "/data/tmp/work";
Alex Crichtondefd1b32016-03-08 07:15:5539
Ulrik Sverdrupb1566ba2016-11-25 21:13:5940/// The two modes of the test runner; tests or benchmarks.
Mark Simulacrum528646e2017-07-14 00:48:4441#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)]
Ulrik Sverdrupb1566ba2016-11-25 21:13:5942pub enum TestKind {
43 /// Run `cargo test`
44 Test,
45 /// Run `cargo bench`
46 Bench,
47}
48
49impl TestKind {
50 // Return the cargo subcommand for this test kind
51 fn subcommand(self) -> &'static str {
52 match self {
53 TestKind::Test => "test",
54 TestKind::Bench => "bench",
55 }
56 }
57}
58
59impl fmt::Display for TestKind {
60 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
61 f.write_str(match *self {
62 TestKind::Test => "Testing",
63 TestKind::Bench => "Benchmarking",
64 })
65 }
66}
67
Oliver Schneiderab018c72017-08-30 16:59:2668fn try_run_expecting(build: &Build, cmd: &mut Command, expect: BuildExpectation) {
Mark Simulacrum4dc8fe92017-06-27 19:37:2469 if !build.fail_fast {
Oliver Schneiderab018c72017-08-30 16:59:2670 if !build.try_run(cmd, expect) {
Josh Stone617aea42017-06-02 16:27:4471 let failures = build.delayed_failures.get();
72 build.delayed_failures.set(failures + 1);
73 }
74 } else {
Oliver Schneiderab018c72017-08-30 16:59:2675 build.run_expecting(cmd, expect);
Josh Stone617aea42017-06-02 16:27:4476 }
77}
78
Oliver Schneiderab018c72017-08-30 16:59:2679fn try_run(build: &Build, cmd: &mut Command) {
80 try_run_expecting(build, cmd, BuildExpectation::None)
81}
82
Josh Stone617aea42017-06-02 16:27:4483fn try_run_quiet(build: &Build, cmd: &mut Command) {
Mark Simulacrum4dc8fe92017-06-27 19:37:2484 if !build.fail_fast {
Josh Stone617aea42017-06-02 16:27:4485 if !build.try_run_quiet(cmd) {
86 let failures = build.delayed_failures.get();
87 build.delayed_failures.set(failures + 1);
88 }
89 } else {
90 build.run_quiet(cmd);
91 }
92}
93
Mark Simulacrum528646e2017-07-14 00:48:4494#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
95pub struct Linkcheck {
96 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:4397}
98
Mark Simulacrum528646e2017-07-14 00:48:4499impl Step for Linkcheck {
Mark Simulacrum001e9f32017-07-05 01:41:43100 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27101 const ONLY_HOSTS: bool = true;
102 const DEFAULT: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43103
104 /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
105 ///
106 /// This tool in `src/tools` will verify the validity of all our links in the
107 /// documentation to ensure we don't have a bunch of dead ones.
108 fn run(self, builder: &Builder) {
109 let build = builder.build;
110 let host = self.host;
111
112 println!("Linkcheck ({})", host);
Mark Simulacrum6b3413d2017-07-05 12:41:27113
114 builder.default_doc(None);
Mark Simulacrum001e9f32017-07-05 01:41:43115
116 let _time = util::timeit();
Mark Simulacrum6b3413d2017-07-05 12:41:27117 try_run(build, builder.tool_cmd(Tool::Linkchecker)
Mark Simulacrum001e9f32017-07-05 01:41:43118 .arg(build.out.join(host).join("doc")));
119 }
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;
123 run.path("src/tools/linkchecker").default_condition(builder.build.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) {
157 let build = builder.build;
Mark Simulacrum60388302017-07-05 16:46:41158 let compiler = builder.compiler(self.stage, self.host);
Mark Simulacrum6b3413d2017-07-05 12:41:27159 builder.ensure(compile::Rustc { compiler, target: compiler.host });
Mark Simulacrum001e9f32017-07-05 01:41:43160
161 // Note that this is a short, cryptic, and not scoped directory name. This
162 // is currently to minimize the length of path on Windows where we otherwise
163 // quickly run into path name limit constraints.
164 let out_dir = build.out.join("ct");
165 t!(fs::create_dir_all(&out_dir));
166
167 let _time = util::timeit();
Mark Simulacrum6b3413d2017-07-05 12:41:27168 let mut cmd = builder.tool_cmd(Tool::CargoTest);
Mark Simulacrum001e9f32017-07-05 01:41:43169 try_run(build, cmd.arg(&build.initial_cargo)
170 .arg(&out_dir)
Mark Simulacrumc114fe52017-07-05 17:21:33171 .env("RUSTC", builder.rustc(compiler))
Mark Simulacrumfacf5a92017-08-04 22:13:01172 .env("RUSTDOC", builder.rustdoc(compiler.host)));
Mark Simulacrum001e9f32017-07-05 01:41:43173 }
Alex Crichton009f45f2017-04-18 00:24:05174}
175
Mark Simulacrum528646e2017-07-14 00:48:44176#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
177pub struct Cargo {
Mark Simulacrum001e9f32017-07-05 01:41:43178 stage: u32,
Mark Simulacrum528646e2017-07-14 00:48:44179 host: Interned<String>,
Nick Cameron04415dc2017-06-30 18:58:54180}
181
Mark Simulacrum528646e2017-07-14 00:48:44182impl Step for Cargo {
Mark Simulacrum001e9f32017-07-05 01:41:43183 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27184 const ONLY_HOSTS: bool = true;
185
Mark Simulacrum56128fb2017-07-19 00:03:38186 fn should_run(run: ShouldRun) -> ShouldRun {
187 run.path("src/tools/cargo")
Mark Simulacrum6b3413d2017-07-05 12:41:27188 }
189
Mark Simulacrum6a67a052017-07-20 23:51:07190 fn make_run(run: RunConfig) {
191 run.builder.ensure(Cargo {
192 stage: run.builder.top_stage,
193 host: run.target,
Mark Simulacrum6b3413d2017-07-05 12:41:27194 });
195 }
Nick Cameron04415dc2017-06-30 18:58:54196
Mark Simulacrum001e9f32017-07-05 01:41:43197 /// Runs `cargo test` for `cargo` packaged with Rust.
198 fn run(self, builder: &Builder) {
199 let build = builder.build;
Mark Simulacrum6b3413d2017-07-05 12:41:27200 let compiler = builder.compiler(self.stage, self.host);
Nick Cameron04415dc2017-06-30 18:58:54201
Mark Simulacrumfe0eca02017-07-23 01:29:08202 builder.ensure(tool::Cargo { compiler, target: self.host });
Mark Simulacrumc114fe52017-07-05 17:21:33203 let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
Mark Simulacrum001e9f32017-07-05 01:41:43204 cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
205 if !build.fail_fast {
206 cargo.arg("--no-fail-fast");
207 }
Nick Cameron04415dc2017-06-30 18:58:54208
Mark Simulacrum001e9f32017-07-05 01:41:43209 // Don't build tests dynamically, just a pain to work with
210 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
211
212 // Don't run cross-compile tests, we may not have cross-compiled libstd libs
213 // available.
214 cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
215
Mark Simulacrumdec44b02017-07-17 15:52:05216 try_run(build, cargo.env("PATH", &path_for_cargo(builder, compiler)));
Mark Simulacrum001e9f32017-07-05 01:41:43217 }
218}
219
Mark Simulacrumdec44b02017-07-17 15:52:05220#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
221pub struct Rls {
Mark Simulacrum001e9f32017-07-05 01:41:43222 stage: u32,
Mark Simulacrumdec44b02017-07-17 15:52:05223 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43224}
225
Mark Simulacrumdec44b02017-07-17 15:52:05226impl Step for Rls {
Mark Simulacrum001e9f32017-07-05 01:41:43227 type Output = ();
Mark Simulacrumdec44b02017-07-17 15:52:05228 const ONLY_HOSTS: bool = true;
229
Mark Simulacrum56128fb2017-07-19 00:03:38230 fn should_run(run: ShouldRun) -> ShouldRun {
231 run.path("src/tools/rls")
Mark Simulacrumdec44b02017-07-17 15:52:05232 }
233
Mark Simulacrum6a67a052017-07-20 23:51:07234 fn make_run(run: RunConfig) {
235 run.builder.ensure(Rls {
236 stage: run.builder.top_stage,
237 host: run.target,
Mark Simulacrumdec44b02017-07-17 15:52:05238 });
239 }
Mark Simulacrum001e9f32017-07-05 01:41:43240
241 /// Runs `cargo test` for the rls.
242 fn run(self, builder: &Builder) {
243 let build = builder.build;
244 let stage = self.stage;
245 let host = self.host;
Mark Simulacrumdec44b02017-07-17 15:52:05246 let compiler = builder.compiler(stage, host);
Mark Simulacrum001e9f32017-07-05 01:41:43247
Mark Simulacrumfe0eca02017-07-23 01:29:08248 builder.ensure(tool::Rls { compiler, target: self.host });
Mark Simulacrumdec44b02017-07-17 15:52:05249 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
Mark Simulacrum001e9f32017-07-05 01:41:43250 cargo.arg("--manifest-path").arg(build.src.join("src/tools/rls/Cargo.toml"));
251
252 // Don't build tests dynamically, just a pain to work with
253 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
254
Mark Simulacrumdec44b02017-07-17 15:52:05255 builder.add_rustc_lib_path(compiler, &mut cargo);
Mark Simulacrum001e9f32017-07-05 01:41:43256
257 try_run(build, &mut cargo);
258 }
Nick Cameron04415dc2017-06-30 18:58:54259}
260
Nick Camerond0070e82017-09-01 06:43:00261#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
262pub struct Rustfmt {
263 stage: u32,
264 host: Interned<String>,
265}
266
267impl Step for Rustfmt {
268 type Output = ();
269 const ONLY_HOSTS: bool = true;
270
271 fn should_run(run: ShouldRun) -> ShouldRun {
272 run.path("src/tools/rustfmt")
273 }
274
275 fn make_run(run: RunConfig) {
276 run.builder.ensure(Rustfmt {
277 stage: run.builder.top_stage,
278 host: run.target,
279 });
280 }
281
282 /// Runs `cargo test` for rustfmt.
283 fn run(self, builder: &Builder) {
284 let build = builder.build;
285 let stage = self.stage;
286 let host = self.host;
287 let compiler = builder.compiler(stage, host);
288
289 builder.ensure(tool::Rustfmt { compiler, target: self.host });
290 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
291 cargo.arg("--manifest-path").arg(build.src.join("src/tools/rustfmt/Cargo.toml"));
292
293 // Don't build tests dynamically, just a pain to work with
294 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
295
296 builder.add_rustc_lib_path(compiler, &mut cargo);
297
298 try_run(build, &mut cargo);
299 }
300}
Oliver Schneiderf3817442017-08-28 14:54:50301pub struct Miri {
302 host: Interned<String>,
303}
304
305impl Step for Miri {
306 type Output = ();
307 const ONLY_HOSTS: bool = true;
308 const DEFAULT: bool = true;
309
310 fn should_run(run: ShouldRun) -> ShouldRun {
311 let test_miri = run.builder.build.config.test_miri;
312 run.path("src/tools/miri").default_condition(test_miri)
313 }
314
315 fn make_run(run: RunConfig) {
316 run.builder.ensure(Miri {
317 host: run.target,
318 });
319 }
320
321 /// Runs `cargo test` for miri.
322 fn run(self, builder: &Builder) {
323 let build = builder.build;
324 let host = self.host;
325 let compiler = builder.compiler(1, host);
326
327 let miri = builder.ensure(tool::Miri { compiler, target: self.host });
328 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
329 cargo.arg("--manifest-path").arg(build.src.join("src/tools/miri/Cargo.toml"));
330
331 // Don't build tests dynamically, just a pain to work with
332 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
333 // miri tests need to know about the stage sysroot
334 cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
335 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
336 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
337 cargo.env("MIRI_PATH", miri);
338
339 builder.add_rustc_lib_path(compiler, &mut cargo);
340
Oliver Schneiderab018c72017-08-30 16:59:26341 try_run_expecting(
342 build,
343 &mut cargo,
344 builder.build.config.toolstate.miri.passes(ToolState::Testing),
345 );
Oliver Schneiderf3817442017-08-28 14:54:50346 }
347}
348
Nick Camerond0070e82017-09-01 06:43:00349
Mark Simulacrumdec44b02017-07-17 15:52:05350fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
Nick Cameron04415dc2017-06-30 18:58:54351 // Configure PATH to find the right rustc. NB. we have to use PATH
352 // and not RUSTC because the Cargo test suite has tests that will
353 // fail if rustc is not spelled `rustc`.
Mark Simulacrumdec44b02017-07-17 15:52:05354 let path = builder.sysroot(compiler).join("bin");
Nick Cameron04415dc2017-06-30 18:58:54355 let old_path = env::var_os("PATH").unwrap_or_default();
356 env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
Brian Anderson3a790ac2016-03-18 20:54:31357}
Alex Crichton9dd3c542016-03-29 20:14:52358
Mark Simulacrum528646e2017-07-14 00:48:44359#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
360pub struct Tidy {
361 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43362}
363
Mark Simulacrum528646e2017-07-14 00:48:44364impl Step for Tidy {
Mark Simulacrum001e9f32017-07-05 01:41:43365 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27366 const DEFAULT: bool = true;
367 const ONLY_HOSTS: bool = true;
368 const ONLY_BUILD: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43369
370 /// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
371 ///
372 /// This tool in `src/tools` checks up on various bits and pieces of style and
373 /// otherwise just implements a few lint-like checks that are specific to the
374 /// compiler itself.
375 fn run(self, builder: &Builder) {
376 let build = builder.build;
377 let host = self.host;
378
379 let _folder = build.fold_output(|| "tidy");
380 println!("tidy check ({})", host);
Mark Simulacrum60388302017-07-05 16:46:41381 let mut cmd = builder.tool_cmd(Tool::Tidy);
Mark Simulacrum001e9f32017-07-05 01:41:43382 cmd.arg(build.src.join("src"));
383 if !build.config.vendor {
384 cmd.arg("--no-vendor");
385 }
386 if build.config.quiet_tests {
387 cmd.arg("--quiet");
388 }
389 try_run(build, &mut cmd);
Eduard-Mihai Burtescud29f0bc2017-02-10 20:59:40390 }
Mark Simulacrum6b3413d2017-07-05 12:41:27391
Mark Simulacrum56128fb2017-07-19 00:03:38392 fn should_run(run: ShouldRun) -> ShouldRun {
393 run.path("src/tools/tidy")
Mark Simulacrum6b3413d2017-07-05 12:41:27394 }
395
Mark Simulacrum6a67a052017-07-20 23:51:07396 fn make_run(run: RunConfig) {
397 run.builder.ensure(Tidy {
398 host: run.builder.build.build,
Mark Simulacrum6b3413d2017-07-05 12:41:27399 });
400 }
Alex Crichton9dd3c542016-03-29 20:14:52401}
Alex Crichtonb325baf2016-04-05 18:34:23402
Mark Simulacrum528646e2017-07-14 00:48:44403fn testdir(build: &Build, host: Interned<String>) -> PathBuf {
Alex Crichtonb325baf2016-04-05 18:34:23404 build.out.join(host).join("test")
405}
406
Mark Simulacrum528646e2017-07-14 00:48:44407#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum1ab89302017-07-07 17:51:57408struct Test {
Mark Simulacrum1ab89302017-07-07 17:51:57409 path: &'static str,
410 mode: &'static str,
411 suite: &'static str,
412}
413
Mark Simulacrumaa8b93b2017-07-07 18:31:29414static DEFAULT_COMPILETESTS: &[Test] = &[
415 Test { path: "src/test/ui", mode: "ui", suite: "ui" },
416 Test { path: "src/test/run-pass", mode: "run-pass", suite: "run-pass" },
417 Test { path: "src/test/compile-fail", mode: "compile-fail", suite: "compile-fail" },
418 Test { path: "src/test/parse-fail", mode: "parse-fail", suite: "parse-fail" },
419 Test { path: "src/test/run-fail", mode: "run-fail", suite: "run-fail" },
Mark Simulacrum1ab89302017-07-07 17:51:57420 Test {
Mark Simulacrum1ab89302017-07-07 17:51:57421 path: "src/test/run-pass-valgrind",
422 mode: "run-pass-valgrind",
423 suite: "run-pass-valgrind"
424 },
Mark Simulacrumaa8b93b2017-07-07 18:31:29425 Test { path: "src/test/mir-opt", mode: "mir-opt", suite: "mir-opt" },
426 Test { path: "src/test/codegen", mode: "codegen", suite: "codegen" },
427 Test { path: "src/test/codegen-units", mode: "codegen-units", suite: "codegen-units" },
428 Test { path: "src/test/incremental", mode: "incremental", suite: "incremental" },
Mark Simulacrum6b3413d2017-07-05 12:41:27429
Mark Simulacrumaa8b93b2017-07-07 18:31:29430 // What this runs varies depending on the native platform being apple
431 Test { path: "src/test/debuginfo", mode: "debuginfo-XXX", suite: "debuginfo" },
Mark Simulacrumaa8b93b2017-07-07 18:31:29432];
Mark Simulacrum6b3413d2017-07-05 12:41:27433
Mark Simulacrumf1d04a32017-07-20 15:42:18434#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
435pub struct DefaultCompiletest {
436 compiler: Compiler,
437 target: Interned<String>,
438 mode: &'static str,
439 suite: &'static str,
440}
441
442impl Step for DefaultCompiletest {
443 type Output = ();
444 const DEFAULT: bool = true;
445
446 fn should_run(mut run: ShouldRun) -> ShouldRun {
447 for test in DEFAULT_COMPILETESTS {
448 run = run.path(test.path);
449 }
450 run
451 }
452
Mark Simulacrum6a67a052017-07-20 23:51:07453 fn make_run(run: RunConfig) {
454 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
Mark Simulacrumf1d04a32017-07-20 15:42:18455
Mark Simulacrum6a67a052017-07-20 23:51:07456 let test = run.path.map(|path| {
Mark Simulacrumf1d04a32017-07-20 15:42:18457 DEFAULT_COMPILETESTS.iter().find(|&&test| {
458 path.ends_with(test.path)
459 }).unwrap_or_else(|| {
460 panic!("make_run in compile test to receive test path, received {:?}", path);
461 })
462 });
463
464 if let Some(test) = test {
Mark Simulacrum6a67a052017-07-20 23:51:07465 run.builder.ensure(DefaultCompiletest {
Mark Simulacrumf1d04a32017-07-20 15:42:18466 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07467 target: run.target,
Mark Simulacrumf1d04a32017-07-20 15:42:18468 mode: test.mode,
469 suite: test.suite,
470 });
471 } else {
472 for test in DEFAULT_COMPILETESTS {
Mark Simulacrum6a67a052017-07-20 23:51:07473 run.builder.ensure(DefaultCompiletest {
Mark Simulacrumf1d04a32017-07-20 15:42:18474 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07475 target: run.target,
Mark Simulacrumf1d04a32017-07-20 15:42:18476 mode: test.mode,
477 suite: test.suite
478 });
479 }
480 }
481 }
482
483 fn run(self, builder: &Builder) {
484 builder.ensure(Compiletest {
485 compiler: self.compiler,
486 target: self.target,
487 mode: self.mode,
488 suite: self.suite,
489 })
490 }
491}
492
Mark Simulacrumaa8b93b2017-07-07 18:31:29493// Also default, but host-only.
494static HOST_COMPILETESTS: &[Test] = &[
495 Test { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" },
496 Test { path: "src/test/run-pass-fulldeps", mode: "run-pass", suite: "run-pass-fulldeps" },
497 Test { path: "src/test/run-fail-fulldeps", mode: "run-fail", suite: "run-fail-fulldeps" },
Mark Simulacrum1ab89302017-07-07 17:51:57498 Test {
Mark Simulacrum1ab89302017-07-07 17:51:57499 path: "src/test/compile-fail-fulldeps",
500 mode: "compile-fail",
501 suite: "compile-fail-fulldeps",
502 },
Mark Simulacrumaa8b93b2017-07-07 18:31:29503 Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" },
504 Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" },
Mark Simulacrum6b3413d2017-07-05 12:41:27505
Mark Simulacrumaa8b93b2017-07-07 18:31:29506 Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" },
507 Test { path: "src/test/run-pass/pretty", mode: "pretty", suite: "run-pass" },
508 Test { path: "src/test/run-fail/pretty", mode: "pretty", suite: "run-fail" },
509 Test { path: "src/test/run-pass-valgrind/pretty", mode: "pretty", suite: "run-pass-valgrind" },
510 Test { path: "src/test/run-pass-fulldeps/pretty", mode: "pretty", suite: "run-pass-fulldeps" },
511 Test { path: "src/test/run-fail-fulldeps/pretty", mode: "pretty", suite: "run-fail-fulldeps" },
Mark Simulacrum6b3413d2017-07-05 12:41:27512];
513
Mark Simulacrumf1d04a32017-07-20 15:42:18514#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
515pub struct HostCompiletest {
516 compiler: Compiler,
517 target: Interned<String>,
518 mode: &'static str,
519 suite: &'static str,
520}
Mark Simulacrum6b3413d2017-07-05 12:41:27521
Mark Simulacrumf1d04a32017-07-20 15:42:18522impl Step for HostCompiletest {
Mark Simulacrum001e9f32017-07-05 01:41:43523 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27524 const DEFAULT: bool = true;
Mark Simulacrumf1d04a32017-07-20 15:42:18525 const ONLY_HOSTS: bool = true;
Mark Simulacrum6b3413d2017-07-05 12:41:27526
Mark Simulacrum56128fb2017-07-19 00:03:38527 fn should_run(mut run: ShouldRun) -> ShouldRun {
Mark Simulacrumf1d04a32017-07-20 15:42:18528 for test in HOST_COMPILETESTS {
Mark Simulacrum56128fb2017-07-19 00:03:38529 run = run.path(test.path);
530 }
531 run
Mark Simulacrum6b3413d2017-07-05 12:41:27532 }
533
Mark Simulacrum6a67a052017-07-20 23:51:07534 fn make_run(run: RunConfig) {
535 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:27536
Mark Simulacrum6a67a052017-07-20 23:51:07537 let test = run.path.map(|path| {
Mark Simulacrumf1d04a32017-07-20 15:42:18538 HOST_COMPILETESTS.iter().find(|&&test| {
Mark Simulacrum1ab89302017-07-07 17:51:57539 path.ends_with(test.path)
Mark Simulacrum6b3413d2017-07-05 12:41:27540 }).unwrap_or_else(|| {
541 panic!("make_run in compile test to receive test path, received {:?}", path);
542 })
543 });
544
Mark Simulacrumf1d04a32017-07-20 15:42:18545 if let Some(test) = test {
Mark Simulacrum6a67a052017-07-20 23:51:07546 run.builder.ensure(HostCompiletest {
Mark Simulacrumf1d04a32017-07-20 15:42:18547 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07548 target: run.target,
Mark Simulacrumf1d04a32017-07-20 15:42:18549 mode: test.mode,
550 suite: test.suite,
Mark Simulacrum6b3413d2017-07-05 12:41:27551 });
Mark Simulacrumf1d04a32017-07-20 15:42:18552 } else {
553 for test in HOST_COMPILETESTS {
Mark Simulacruma88a09c2017-07-23 13:22:12554 if test.mode == "pretty" {
555 continue;
556 }
Mark Simulacrum6a67a052017-07-20 23:51:07557 run.builder.ensure(HostCompiletest {
Mark Simulacrumaa8b93b2017-07-07 18:31:29558 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07559 target: run.target,
Mark Simulacrumaa8b93b2017-07-07 18:31:29560 mode: test.mode,
561 suite: test.suite
562 });
563 }
Mark Simulacrum6b3413d2017-07-05 12:41:27564 }
565 }
Alex Crichtonf72bfe62016-05-02 22:16:15566
Mark Simulacrumf1d04a32017-07-20 15:42:18567 fn run(self, builder: &Builder) {
568 builder.ensure(Compiletest {
569 compiler: self.compiler,
570 target: self.target,
571 mode: self.mode,
572 suite: self.suite,
573 })
574 }
575}
576
577#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
578struct Compiletest {
579 compiler: Compiler,
580 target: Interned<String>,
581 mode: &'static str,
582 suite: &'static str,
583}
584
585impl Step for Compiletest {
586 type Output = ();
587
588 fn should_run(run: ShouldRun) -> ShouldRun {
589 run.never()
590 }
591
Mark Simulacrum001e9f32017-07-05 01:41:43592 /// Executes the `compiletest` tool to run a suite of tests.
593 ///
594 /// Compiles all tests with `compiler` for `target` with the specified
595 /// compiletest `mode` and `suite` arguments. For example `mode` can be
596 /// "run-pass" or `suite` can be something like `debuginfo`.
597 fn run(self, builder: &Builder) {
598 let build = builder.build;
599 let compiler = self.compiler;
600 let target = self.target;
601 let mode = self.mode;
602 let suite = self.suite;
Mark Simulacrum6b3413d2017-07-05 12:41:27603
604 // Skip codegen tests if they aren't enabled in configuration.
605 if !build.config.codegen_tests && suite == "codegen" {
606 return;
607 }
608
609 if suite == "debuginfo" {
Mark Simulacrum951616c2017-07-20 17:23:29610 // Skip debuginfo tests on MSVC
611 if build.build.contains("msvc") {
612 return;
613 }
614
Mark Simulacrum6b3413d2017-07-05 12:41:27615 if mode == "debuginfo-XXX" {
616 return if build.build.contains("apple") {
617 builder.ensure(Compiletest {
618 mode: "debuginfo-lldb",
619 ..self
Mark Simulacrum528646e2017-07-14 00:48:44620 });
Mark Simulacrum6b3413d2017-07-05 12:41:27621 } else {
622 builder.ensure(Compiletest {
623 mode: "debuginfo-gdb",
624 ..self
Mark Simulacrum528646e2017-07-14 00:48:44625 });
Mark Simulacrum6b3413d2017-07-05 12:41:27626 };
627 }
628
Mark Simulacrum6b3413d2017-07-05 12:41:27629 builder.ensure(dist::DebuggerScripts {
Mark Simulacrum528646e2017-07-14 00:48:44630 sysroot: builder.sysroot(compiler),
Mark Simulacrumfef9b482017-07-23 16:03:40631 host: target
Mark Simulacrum6b3413d2017-07-05 12:41:27632 });
633 }
634
635 if suite.ends_with("fulldeps") ||
636 // FIXME: Does pretty need librustc compiled? Note that there are
637 // fulldeps test suites with mode = pretty as well.
638 mode == "pretty" ||
639 mode == "rustdoc" ||
640 mode == "run-make" {
641 builder.ensure(compile::Rustc { compiler, target });
642 }
643
644 builder.ensure(compile::Test { compiler, target });
645 builder.ensure(native::TestHelpers { target });
Mark Simulacrumaa8b93b2017-07-07 18:31:29646 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum6b3413d2017-07-05 12:41:27647
Mark Simulacrum001e9f32017-07-05 01:41:43648 let _folder = build.fold_output(|| format!("test_{}", suite));
649 println!("Check compiletest suite={} mode={} ({} -> {})",
Mark Simulacrum528646e2017-07-14 00:48:44650 suite, mode, &compiler.host, target);
Mark Simulacrum6b3413d2017-07-05 12:41:27651 let mut cmd = builder.tool_cmd(Tool::Compiletest);
Alex Crichtonb325baf2016-04-05 18:34:23652
Mark Simulacrum001e9f32017-07-05 01:41:43653 // compiletest currently has... a lot of arguments, so let's just pass all
654 // of them!
Brian Anderson8401e372016-09-15 19:42:26655
Mark Simulacrumc114fe52017-07-05 17:21:33656 cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
Mark Simulacrum60388302017-07-05 16:46:41657 cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
Mark Simulacrumc114fe52017-07-05 17:21:33658 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
Mark Simulacrum4e5333c2017-07-25 22:54:33659
660 // Avoid depending on rustdoc when we don't need it.
661 if mode == "rustdoc" || mode == "run-make" {
Mark Simulacrumfacf5a92017-08-04 22:13:01662 cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
Mark Simulacrum4e5333c2017-07-25 22:54:33663 }
664
Mark Simulacrum001e9f32017-07-05 01:41:43665 cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
666 cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
667 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
668 cmd.arg("--mode").arg(mode);
669 cmd.arg("--target").arg(target);
Mark Simulacrum528646e2017-07-14 00:48:44670 cmd.arg("--host").arg(&*compiler.host);
671 cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(build.build));
Alex Crichtonf4e4ec72016-05-13 22:26:41672
Mark Simulacrum001e9f32017-07-05 01:41:43673 if let Some(ref nodejs) = build.config.nodejs {
674 cmd.arg("--nodejs").arg(nodejs);
675 }
Alex Crichtonf4e4ec72016-05-13 22:26:41676
Mark Simulacrum001e9f32017-07-05 01:41:43677 let mut flags = vec!["-Crpath".to_string()];
678 if build.config.rust_optimize_tests {
679 flags.push("-O".to_string());
680 }
681 if build.config.rust_debuginfo_tests {
682 flags.push("-g".to_string());
683 }
Alex Crichtoncbe62922016-04-19 16:44:19684
Mark Simulacrum60388302017-07-05 16:46:41685 let mut hostflags = build.rustc_flags(compiler.host);
Mark Simulacrum001e9f32017-07-05 01:41:43686 hostflags.extend(flags.clone());
687 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
Alex Crichtoncbe62922016-04-19 16:44:19688
Mark Simulacrum528646e2017-07-14 00:48:44689 let mut targetflags = build.rustc_flags(target);
Mark Simulacrum001e9f32017-07-05 01:41:43690 targetflags.extend(flags);
691 targetflags.push(format!("-Lnative={}",
692 build.test_helpers_out(target).display()));
693 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
Alex Crichtonb325baf2016-04-05 18:34:23694
Mark Simulacrum001e9f32017-07-05 01:41:43695 cmd.arg("--docck-python").arg(build.python());
Alex Crichtonb325baf2016-04-05 18:34:23696
Mark Simulacrum001e9f32017-07-05 01:41:43697 if build.build.ends_with("apple-darwin") {
698 // Force /usr/bin/python on macOS for LLDB tests because we're loading the
699 // LLDB plugin's compiled module which only works with the system python
700 // (namely not Homebrew-installed python)
701 cmd.arg("--lldb-python").arg("/usr/bin/python");
702 } else {
703 cmd.arg("--lldb-python").arg(build.python());
704 }
Alex Crichtonb325baf2016-04-05 18:34:23705
Mark Simulacrum001e9f32017-07-05 01:41:43706 if let Some(ref gdb) = build.config.gdb {
707 cmd.arg("--gdb").arg(gdb);
708 }
709 if let Some(ref vers) = build.lldb_version {
710 cmd.arg("--lldb-version").arg(vers);
711 }
712 if let Some(ref dir) = build.lldb_python_dir {
713 cmd.arg("--lldb-python-dir").arg(dir);
714 }
Alex Crichtonb325baf2016-04-05 18:34:23715
Mark Simulacrum44ffb612017-07-30 04:12:53716 cmd.args(&build.config.cmd.test_args());
Corey Farwellc8c6d2c2016-10-30 01:58:52717
Mark Simulacrum001e9f32017-07-05 01:41:43718 if build.is_verbose() {
719 cmd.arg("--verbose");
720 }
Alex Crichton126e09e2016-04-14 22:51:03721
Mark Simulacrum001e9f32017-07-05 01:41:43722 if build.config.quiet_tests {
723 cmd.arg("--quiet");
724 }
Alex Crichton1747ce22017-01-28 21:38:06725
bjorn30c97bbf2017-08-13 10:30:54726 if build.config.llvm_enabled {
727 let llvm_config = build.llvm_config(target);
728 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
729 cmd.arg("--llvm-version").arg(llvm_version);
730 if !build.is_rust_llvm(target) {
731 cmd.arg("--system-llvm");
732 }
733
734 // Only pass correct values for these flags for the `run-make` suite as it
735 // requires that a C++ compiler was configured which isn't always the case.
736 if suite == "run-make" {
737 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
738 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
739 cmd.arg("--cc").arg(build.cc(target))
740 .arg("--cxx").arg(build.cxx(target).unwrap())
741 .arg("--cflags").arg(build.cflags(target).join(" "))
742 .arg("--llvm-components").arg(llvm_components.trim())
743 .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
744 }
745 }
746 if suite == "run-make" && !build.config.llvm_enabled {
bjorn31c28cf52017-08-13 14:49:09747 println!("Ignoring run-make test suite as they generally dont work without LLVM");
bjorn30c97bbf2017-08-13 10:30:54748 return;
749 }
750
751 if suite != "run-make" {
Mark Simulacrum001e9f32017-07-05 01:41:43752 cmd.arg("--cc").arg("")
753 .arg("--cxx").arg("")
754 .arg("--cflags").arg("")
755 .arg("--llvm-components").arg("")
756 .arg("--llvm-cxxflags").arg("");
757 }
758
759 if build.remote_tested(target) {
Mark Simulacrum6b3413d2017-07-05 12:41:27760 cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
Mark Simulacrum001e9f32017-07-05 01:41:43761 }
762
763 // Running a C compiler on MSVC requires a few env vars to be set, to be
764 // sure to set them here.
765 //
766 // Note that if we encounter `PATH` we make sure to append to our own `PATH`
767 // rather than stomp over it.
768 if target.contains("msvc") {
Mark Simulacrum528646e2017-07-14 00:48:44769 for &(ref k, ref v) in build.cc[&target].0.env() {
Mark Simulacrum001e9f32017-07-05 01:41:43770 if k != "PATH" {
771 cmd.env(k, v);
772 }
Alex Crichton126e09e2016-04-14 22:51:03773 }
774 }
Mark Simulacrum001e9f32017-07-05 01:41:43775 cmd.env("RUSTC_BOOTSTRAP", "1");
776 build.add_rust_test_threads(&mut cmd);
777
778 if build.config.sanitizers {
779 cmd.env("SANITIZER_SUPPORT", "1");
780 }
781
782 if build.config.profiler {
783 cmd.env("PROFILER_SUPPORT", "1");
784 }
785
786 cmd.arg("--adb-path").arg("adb");
787 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
788 if target.contains("android") {
789 // Assume that cc for this target comes from the android sysroot
790 cmd.arg("--android-cross-path")
791 .arg(build.cc(target).parent().unwrap().parent().unwrap());
792 } else {
793 cmd.arg("--android-cross-path").arg("");
794 }
795
796 build.ci_env.force_coloring_in_ci(&mut cmd);
797
798 let _time = util::timeit();
799 try_run(build, &mut cmd);
Alex Crichton126e09e2016-04-14 22:51:03800 }
Alex Crichtonb325baf2016-04-05 18:34:23801}
Alex Crichtonede89442016-04-15 01:00:35802
Mark Simulacrum528646e2017-07-14 00:48:44803#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
804pub struct Docs {
805 compiler: Compiler,
Mark Simulacruma5ab2ce2017-07-12 15:15:00806}
807
Mark Simulacrum528646e2017-07-14 00:48:44808impl Step for Docs {
Mark Simulacruma5ab2ce2017-07-12 15:15:00809 type Output = ();
810 const DEFAULT: bool = true;
811 const ONLY_HOSTS: bool = true;
Alex Crichtonede89442016-04-15 01:00:35812
Mark Simulacrum56128fb2017-07-19 00:03:38813 fn should_run(run: ShouldRun) -> ShouldRun {
814 run.path("src/doc")
Mark Simulacruma5ab2ce2017-07-12 15:15:00815 }
816
Mark Simulacrum6a67a052017-07-20 23:51:07817 fn make_run(run: RunConfig) {
818 run.builder.ensure(Docs {
819 compiler: run.builder.compiler(run.builder.top_stage, run.host),
Mark Simulacruma5ab2ce2017-07-12 15:15:00820 });
821 }
822
823 /// Run `rustdoc --test` for all documentation in `src/doc`.
824 ///
825 /// This will run all tests in our markdown documentation (e.g. the book)
826 /// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
827 /// `compiler`.
828 fn run(self, builder: &Builder) {
829 let build = builder.build;
830 let compiler = self.compiler;
Mark Simulacrumceecd622017-07-12 16:12:47831
832 builder.ensure(compile::Test { compiler, target: compiler.host });
833
Mark Simulacruma5ab2ce2017-07-12 15:15:00834 // Do a breadth-first traversal of the `src/doc` directory and just run
835 // tests for all files that end in `*.md`
836 let mut stack = vec![build.src.join("src/doc")];
837 let _time = util::timeit();
838 let _folder = build.fold_output(|| "test_docs");
839
840 while let Some(p) = stack.pop() {
841 if p.is_dir() {
842 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
843 continue
844 }
845
846 if p.extension().and_then(|s| s.to_str()) != Some("md") {
847 continue;
848 }
849
850 // The nostarch directory in the book is for no starch, and so isn't
851 // guaranteed to build. We don't care if it doesn't build, so skip it.
852 if p.to_str().map_or(false, |p| p.contains("nostarch")) {
853 continue;
854 }
855
856 markdown_test(builder, compiler, &p);
Alex Crichtonede89442016-04-15 01:00:35857 }
Alex Crichtonede89442016-04-15 01:00:35858 }
859}
860
Mark Simulacrum528646e2017-07-14 00:48:44861#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
862pub struct ErrorIndex {
863 compiler: Compiler,
Mark Simulacrum001e9f32017-07-05 01:41:43864}
Alex Crichton0e272de2016-11-16 20:31:19865
Mark Simulacrum528646e2017-07-14 00:48:44866impl Step for ErrorIndex {
Mark Simulacrum001e9f32017-07-05 01:41:43867 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27868 const DEFAULT: bool = true;
869 const ONLY_HOSTS: bool = true;
870
Mark Simulacrum56128fb2017-07-19 00:03:38871 fn should_run(run: ShouldRun) -> ShouldRun {
872 run.path("src/tools/error_index_generator")
Mark Simulacrum6b3413d2017-07-05 12:41:27873 }
874
Mark Simulacrum6a67a052017-07-20 23:51:07875 fn make_run(run: RunConfig) {
876 run.builder.ensure(ErrorIndex {
877 compiler: run.builder.compiler(run.builder.top_stage, run.host),
Mark Simulacrum6b3413d2017-07-05 12:41:27878 });
879 }
Alex Crichtonede89442016-04-15 01:00:35880
Mark Simulacrum001e9f32017-07-05 01:41:43881 /// Run the error index generator tool to execute the tests located in the error
882 /// index.
883 ///
884 /// The `error_index_generator` tool lives in `src/tools` and is used to
885 /// generate a markdown file from the error indexes of the code base which is
886 /// then passed to `rustdoc --test`.
887 fn run(self, builder: &Builder) {
888 let build = builder.build;
889 let compiler = self.compiler;
890
Mark Simulacrum6b3413d2017-07-05 12:41:27891 builder.ensure(compile::Std { compiler, target: compiler.host });
892
Mark Simulacrum001e9f32017-07-05 01:41:43893 let _folder = build.fold_output(|| "test_error_index");
894 println!("Testing error-index stage{}", compiler.stage);
895
896 let dir = testdir(build, compiler.host);
897 t!(fs::create_dir_all(&dir));
898 let output = dir.join("error-index.md");
899
900 let _time = util::timeit();
Mark Simulacrum60388302017-07-05 16:46:41901 build.run(builder.tool_cmd(Tool::ErrorIndex)
Mark Simulacrum001e9f32017-07-05 01:41:43902 .arg("markdown")
903 .arg(&output)
904 .env("CFG_BUILD", &build.build));
905
Mark Simulacrumc114fe52017-07-05 17:21:33906 markdown_test(builder, compiler, &output);
Mark Simulacrum001e9f32017-07-05 01:41:43907 }
Alex Crichtonede89442016-04-15 01:00:35908}
909
Mark Simulacrumc114fe52017-07-05 17:21:33910fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
911 let build = builder.build;
Mark Simulacrumdd1d75e2017-06-04 23:55:50912 let mut file = t!(File::open(markdown));
913 let mut contents = String::new();
914 t!(file.read_to_string(&mut contents));
915 if !contents.contains("```") {
916 return;
917 }
918
Mark Simulacrumbc8fabb2017-06-06 18:00:22919 println!("doc tests for: {}", markdown.display());
Mark Simulacrumfacf5a92017-08-04 22:13:01920 let mut cmd = builder.rustdoc_cmd(compiler.host);
Alex Crichton0e272de2016-11-16 20:31:19921 build.add_rust_test_threads(&mut cmd);
Alex Crichtonede89442016-04-15 01:00:35922 cmd.arg("--test");
923 cmd.arg(markdown);
Alex Crichton6f62fae2016-12-12 17:03:35924 cmd.env("RUSTC_BOOTSTRAP", "1");
Corey Farwellc8c6d2c2016-10-30 01:58:52925
Mark Simulacrum44ffb612017-07-30 04:12:53926 let test_args = build.config.cmd.test_args().join(" ");
Corey Farwellc8c6d2c2016-10-30 01:58:52927 cmd.arg("--test-args").arg(test_args);
928
kennytm6ac07872017-05-21 20:27:47929 if build.config.quiet_tests {
Josh Stone617aea42017-06-02 16:27:44930 try_run_quiet(build, &mut cmd);
kennytm6ac07872017-05-21 20:27:47931 } else {
Josh Stone617aea42017-06-02 16:27:44932 try_run(build, &mut cmd);
kennytm6ac07872017-05-21 20:27:47933 }
Alex Crichtonede89442016-04-15 01:00:35934}
Alex Crichtonbb9062a2016-04-29 21:23:15935
Mark Simulacrum528646e2017-07-14 00:48:44936#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum981afa52017-07-18 21:28:53937pub struct CrateLibrustc {
Mark Simulacrum528646e2017-07-14 00:48:44938 compiler: Compiler,
939 target: Interned<String>,
Mark Simulacrum6b3413d2017-07-05 12:41:27940 test_kind: TestKind,
Mark Simulacrum528646e2017-07-14 00:48:44941 krate: Option<Interned<String>>,
Mark Simulacrum6b3413d2017-07-05 12:41:27942}
943
Mark Simulacrum981afa52017-07-18 21:28:53944impl Step for CrateLibrustc {
Mark Simulacrum6b3413d2017-07-05 12:41:27945 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27946 const DEFAULT: bool = true;
947 const ONLY_HOSTS: bool = true;
948
Mark Simulacrum56128fb2017-07-19 00:03:38949 fn should_run(run: ShouldRun) -> ShouldRun {
950 run.krate("rustc-main")
Mark Simulacrum6b3413d2017-07-05 12:41:27951 }
952
Mark Simulacrum6a67a052017-07-20 23:51:07953 fn make_run(run: RunConfig) {
954 let builder = run.builder;
955 let compiler = builder.compiler(builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:27956
Mark Simulacrum6a67a052017-07-20 23:51:07957 let make = |name: Option<Interned<String>>| {
Mark Simulacrum6b3413d2017-07-05 12:41:27958 let test_kind = if builder.kind == Kind::Test {
959 TestKind::Test
960 } else if builder.kind == Kind::Bench {
961 TestKind::Bench
962 } else {
Mark Simulacrum981afa52017-07-18 21:28:53963 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
Mark Simulacrum6b3413d2017-07-05 12:41:27964 };
965
Mark Simulacrum981afa52017-07-18 21:28:53966 builder.ensure(CrateLibrustc {
Mark Simulacrum6b3413d2017-07-05 12:41:27967 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07968 target: run.target,
Zack M. Davis1b6c9602017-08-07 05:54:09969 test_kind,
Mark Simulacrum6b3413d2017-07-05 12:41:27970 krate: name,
971 });
972 };
973
Mark Simulacrum6a67a052017-07-20 23:51:07974 if let Some(path) = run.path {
Mark Simulacrum6b3413d2017-07-05 12:41:27975 for (name, krate_path) in builder.crates("rustc-main") {
976 if path.ends_with(krate_path) {
Mark Simulacrum6a67a052017-07-20 23:51:07977 make(Some(name));
Mark Simulacrum6b3413d2017-07-05 12:41:27978 }
979 }
980 } else {
Mark Simulacrum6a67a052017-07-20 23:51:07981 make(None);
Mark Simulacrum6b3413d2017-07-05 12:41:27982 }
983 }
984
985
986 fn run(self, builder: &Builder) {
Mark Simulacrum981afa52017-07-18 21:28:53987 builder.ensure(Crate {
Mark Simulacrum6b3413d2017-07-05 12:41:27988 compiler: self.compiler,
989 target: self.target,
990 mode: Mode::Librustc,
991 test_kind: self.test_kind,
992 krate: self.krate,
993 });
994 }
995}
996
Mark Simulacrum528646e2017-07-14 00:48:44997#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum981afa52017-07-18 21:28:53998pub struct Crate {
Mark Simulacrum528646e2017-07-14 00:48:44999 compiler: Compiler,
1000 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431001 mode: Mode,
1002 test_kind: TestKind,
Mark Simulacrum528646e2017-07-14 00:48:441003 krate: Option<Interned<String>>,
Mark Simulacrum001e9f32017-07-05 01:41:431004}
Alex Crichtonbb9062a2016-04-29 21:23:151005
Mark Simulacrum981afa52017-07-18 21:28:531006impl Step for Crate {
Mark Simulacrum001e9f32017-07-05 01:41:431007 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271008 const DEFAULT: bool = true;
1009
Mark Simulacrum56128fb2017-07-19 00:03:381010 fn should_run(run: ShouldRun) -> ShouldRun {
1011 run.krate("std").krate("test")
Mark Simulacrum6b3413d2017-07-05 12:41:271012 }
1013
Mark Simulacrum6a67a052017-07-20 23:51:071014 fn make_run(run: RunConfig) {
1015 let builder = run.builder;
1016 let compiler = builder.compiler(builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:271017
Mark Simulacrum6a67a052017-07-20 23:51:071018 let make = |mode: Mode, name: Option<Interned<String>>| {
Mark Simulacrum6b3413d2017-07-05 12:41:271019 let test_kind = if builder.kind == Kind::Test {
1020 TestKind::Test
1021 } else if builder.kind == Kind::Bench {
1022 TestKind::Bench
1023 } else {
Mark Simulacrum981afa52017-07-18 21:28:531024 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
Mark Simulacrum6b3413d2017-07-05 12:41:271025 };
1026
Mark Simulacrum981afa52017-07-18 21:28:531027 builder.ensure(Crate {
Mark Simulacrum6a67a052017-07-20 23:51:071028 compiler,
1029 target: run.target,
Zack M. Davis1b6c9602017-08-07 05:54:091030 mode,
1031 test_kind,
Mark Simulacrum6b3413d2017-07-05 12:41:271032 krate: name,
1033 });
1034 };
1035
Mark Simulacrum6a67a052017-07-20 23:51:071036 if let Some(path) = run.path {
Mark Simulacrum6b3413d2017-07-05 12:41:271037 for (name, krate_path) in builder.crates("std") {
1038 if path.ends_with(krate_path) {
Mark Simulacrum6a67a052017-07-20 23:51:071039 make(Mode::Libstd, Some(name));
Mark Simulacrum6b3413d2017-07-05 12:41:271040 }
1041 }
1042 for (name, krate_path) in builder.crates("test") {
1043 if path.ends_with(krate_path) {
Mark Simulacrum6a67a052017-07-20 23:51:071044 make(Mode::Libtest, Some(name));
Mark Simulacrum6b3413d2017-07-05 12:41:271045 }
1046 }
1047 } else {
Mark Simulacrum6a67a052017-07-20 23:51:071048 make(Mode::Libstd, None);
1049 make(Mode::Libtest, None);
Mark Simulacrum6b3413d2017-07-05 12:41:271050 }
1051 }
Alex Crichton7046fea2016-12-25 23:20:331052
Mark Simulacrum001e9f32017-07-05 01:41:431053 /// Run all unit tests plus documentation tests for an entire crate DAG defined
1054 /// by a `Cargo.toml`
1055 ///
1056 /// This is what runs tests for crates like the standard library, compiler, etc.
1057 /// It essentially is the driver for running `cargo test`.
1058 ///
1059 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
1060 /// arguments, and those arguments are discovered from `cargo metadata`.
1061 fn run(self, builder: &Builder) {
1062 let build = builder.build;
1063 let compiler = self.compiler;
1064 let target = self.target;
1065 let mode = self.mode;
1066 let test_kind = self.test_kind;
1067 let krate = self.krate;
Alex Crichtonbb9062a2016-04-29 21:23:151068
Mark Simulacrum6b3413d2017-07-05 12:41:271069 builder.ensure(compile::Test { compiler, target });
1070 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431071
1072 // If we're not doing a full bootstrap but we're testing a stage2 version of
1073 // libstd, then what we're actually testing is the libstd produced in
1074 // stage1. Reflect that here by updating the compiler that we're working
1075 // with automatically.
1076 let compiler = if build.force_use_stage1(compiler, target) {
Mark Simulacrum6b3413d2017-07-05 12:41:271077 builder.compiler(1, compiler.host)
Mark Simulacrum001e9f32017-07-05 01:41:431078 } else {
1079 compiler.clone()
1080 };
1081
Alex Crichton90105672017-07-17 16:32:081082 let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
1083 let (name, root) = match mode {
1084 Mode::Libstd => {
1085 compile::std_cargo(build, &compiler, target, &mut cargo);
1086 ("libstd", "std")
1087 }
1088 Mode::Libtest => {
1089 compile::test_cargo(build, &compiler, target, &mut cargo);
1090 ("libtest", "test")
1091 }
1092 Mode::Librustc => {
1093 builder.ensure(compile::Rustc { compiler, target });
1094 compile::rustc_cargo(build, &compiler, target, &mut cargo);
1095 ("librustc", "rustc-main")
1096 }
1097 _ => panic!("can only test libraries"),
1098 };
1099 let root = INTERNER.intern_string(String::from(root));
1100 let _folder = build.fold_output(|| {
1101 format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, name)
1102 });
1103 println!("{} {} stage{} ({} -> {})", test_kind, name, compiler.stage,
1104 &compiler.host, target);
1105
Mark Simulacrum001e9f32017-07-05 01:41:431106 // Build up the base `cargo test` command.
1107 //
1108 // Pass in some standard flags then iterate over the graph we've discovered
1109 // in `cargo metadata` with the maps above and figure out what `-p`
1110 // arguments need to get passed.
Mark Simulacrum001e9f32017-07-05 01:41:431111 if test_kind.subcommand() == "test" && !build.fail_fast {
1112 cargo.arg("--no-fail-fast");
Alex Crichtonbb9062a2016-04-29 21:23:151113 }
Mark Simulacrum001e9f32017-07-05 01:41:431114
1115 match krate {
1116 Some(krate) => {
1117 cargo.arg("-p").arg(krate);
1118 }
1119 None => {
1120 let mut visited = HashSet::new();
1121 let mut next = vec![root];
1122 while let Some(name) = next.pop() {
Alex Crichton90105672017-07-17 16:32:081123 // Right now jemalloc and the sanitizer crates are
1124 // target-specific crate in the sense that it's not present
1125 // on all platforms. Custom skip it here for now, but if we
1126 // add more this probably wants to get more generalized.
Mark Simulacrum001e9f32017-07-05 01:41:431127 //
Alex Crichton90105672017-07-17 16:32:081128 // Also skip `build_helper` as it's not compiled normally
1129 // for target during the bootstrap and it's just meant to be
1130 // a helper crate, not tested. If it leaks through then it
1131 // ends up messing with various mtime calculations and such.
1132 if !name.contains("jemalloc") &&
1133 *name != *"build_helper" &&
1134 !(name.starts_with("rustc_") && name.ends_with("san")) {
Mark Simulacrum001e9f32017-07-05 01:41:431135 cargo.arg("-p").arg(&format!("{}:0.0.0", name));
1136 }
Mark Simulacrum528646e2017-07-14 00:48:441137 for dep in build.crates[&name].deps.iter() {
Mark Simulacrum001e9f32017-07-05 01:41:431138 if visited.insert(dep) {
Mark Simulacrum528646e2017-07-14 00:48:441139 next.push(*dep);
Mark Simulacrum001e9f32017-07-05 01:41:431140 }
Alex Crichtona270b802016-10-21 20:18:091141 }
1142 }
Alex Crichtonbb9062a2016-04-29 21:23:151143 }
1144 }
Alex Crichtonbb9062a2016-04-29 21:23:151145
Mark Simulacrum001e9f32017-07-05 01:41:431146 // The tests are going to run with the *target* libraries, so we need to
1147 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
1148 //
1149 // Note that to run the compiler we need to run with the *host* libraries,
1150 // but our wrapper scripts arrange for that to be the case anyway.
1151 let mut dylib_path = dylib_path();
Mark Simulacrum528646e2017-07-14 00:48:441152 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
Mark Simulacrum001e9f32017-07-05 01:41:431153 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
Alex Crichtonbb9062a2016-04-29 21:23:151154
Mark Simulacrum001e9f32017-07-05 01:41:431155 cargo.arg("--");
Mark Simulacrum44ffb612017-07-30 04:12:531156 cargo.args(&build.config.cmd.test_args());
Alex Crichton0e272de2016-11-16 20:31:191157
Mark Simulacrum001e9f32017-07-05 01:41:431158 if build.config.quiet_tests {
1159 cargo.arg("--quiet");
1160 }
Corey Farwellc8c6d2c2016-10-30 01:58:521161
Mark Simulacrum001e9f32017-07-05 01:41:431162 let _time = util::timeit();
Alex Crichton0e272de2016-11-16 20:31:191163
Mark Simulacrum001e9f32017-07-05 01:41:431164 if target.contains("emscripten") {
Alex Crichton8e7849e2017-07-29 00:52:441165 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1166 build.config.nodejs.as_ref().expect("nodejs not configured"));
Mark Simulacrum001e9f32017-07-05 01:41:431167 } else if build.remote_tested(target) {
Alex Crichton8e7849e2017-07-29 00:52:441168 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1169 format!("{} run",
1170 builder.tool_exe(Tool::RemoteTestClient).display()));
Mark Simulacrum001e9f32017-07-05 01:41:431171 }
Alex Crichton8e7849e2017-07-29 00:52:441172 try_run(build, &mut cargo);
Alex Crichton39a5d3f2016-06-28 20:31:301173 }
1174}
1175
Mark Simulacrumf87696b2017-09-02 14:02:321176#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1177pub struct Rustdoc {
1178 host: Interned<String>,
1179 test_kind: TestKind,
1180}
1181
1182impl Step for Rustdoc {
1183 type Output = ();
1184 const DEFAULT: bool = true;
1185 const ONLY_HOSTS: bool = true;
1186
1187 fn should_run(run: ShouldRun) -> ShouldRun {
1188 run.path("src/librustdoc").path("src/tools/rustdoc")
1189 }
1190
1191 fn make_run(run: RunConfig) {
1192 let builder = run.builder;
1193
1194 let test_kind = if builder.kind == Kind::Test {
1195 TestKind::Test
1196 } else if builder.kind == Kind::Bench {
1197 TestKind::Bench
1198 } else {
1199 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
1200 };
1201
1202 builder.ensure(Rustdoc {
1203 host: run.host,
1204 test_kind,
1205 });
1206 }
1207
1208 fn run(self, builder: &Builder) {
1209 let build = builder.build;
1210 let test_kind = self.test_kind;
1211
1212 let compiler = builder.compiler(builder.top_stage, self.host);
1213 let target = compiler.host;
1214
Alex Crichton3da54fb2017-09-15 22:28:591215 let mut cargo = tool::prepare_tool_cargo(builder,
1216 compiler,
1217 target,
1218 test_kind.subcommand(),
1219 "src/tools/rustdoc");
Mark Simulacrumf87696b2017-09-02 14:02:321220 let _folder = build.fold_output(|| {
1221 format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
1222 });
1223 println!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
1224 &compiler.host, target);
1225
1226 if test_kind.subcommand() == "test" && !build.fail_fast {
1227 cargo.arg("--no-fail-fast");
1228 }
1229
1230 cargo.arg("-p").arg("rustdoc:0.0.0");
1231
1232 cargo.arg("--");
1233 cargo.args(&build.config.cmd.test_args());
1234
1235 if build.config.quiet_tests {
1236 cargo.arg("--quiet");
1237 }
1238
1239 let _time = util::timeit();
1240
1241 try_run(build, &mut cargo);
1242 }
1243}
1244
Alex Crichton8e7849e2017-07-29 00:52:441245fn envify(s: &str) -> String {
1246 s.chars().map(|c| {
1247 match c {
1248 '-' => '_',
1249 c => c,
Alex Crichton1747ce22017-01-28 21:38:061250 }
Alex Crichton8e7849e2017-07-29 00:52:441251 }).flat_map(|c| c.to_uppercase()).collect()
Alex Crichton39a5d3f2016-06-28 20:31:301252}
1253
Mark Simulacrumceecd622017-07-12 16:12:471254/// Some test suites are run inside emulators or on remote devices, and most
1255/// of our test binaries are linked dynamically which means we need to ship
1256/// the standard library and such to the emulator ahead of time. This step
1257/// represents this and is a dependency of all test suites.
1258///
1259/// Most of the time this is a noop. For some steps such as shipping data to
1260/// QEMU we have to build our own tools so we've got conditional dependencies
1261/// on those programs as well. Note that the remote test client is built for
1262/// the build target (us) and the server is built for the target.
Mark Simulacrum528646e2017-07-14 00:48:441263#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1264pub struct RemoteCopyLibs {
1265 compiler: Compiler,
1266 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431267}
Alex Crichton1747ce22017-01-28 21:38:061268
Mark Simulacrum528646e2017-07-14 00:48:441269impl Step for RemoteCopyLibs {
Mark Simulacrum001e9f32017-07-05 01:41:431270 type Output = ();
Alex Crichton1747ce22017-01-28 21:38:061271
Mark Simulacrum56128fb2017-07-19 00:03:381272 fn should_run(run: ShouldRun) -> ShouldRun {
1273 run.never()
Mark Simulacrum681b1232017-07-14 12:30:161274 }
1275
Mark Simulacrum001e9f32017-07-05 01:41:431276 fn run(self, builder: &Builder) {
1277 let build = builder.build;
1278 let compiler = self.compiler;
1279 let target = self.target;
1280 if !build.remote_tested(target) {
1281 return
1282 }
Alex Crichton1747ce22017-01-28 21:38:061283
Mark Simulacrum6b3413d2017-07-05 12:41:271284 builder.ensure(compile::Test { compiler, target });
1285
Mark Simulacrum001e9f32017-07-05 01:41:431286 println!("REMOTE copy libs to emulator ({})", target);
1287 t!(fs::create_dir_all(build.out.join("tmp")));
1288
Mark Simulacrumfe0eca02017-07-23 01:29:081289 let server = builder.ensure(tool::RemoteTestServer { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431290
1291 // Spawn the emulator and wait for it to come online
Mark Simulacrum6b3413d2017-07-05 12:41:271292 let tool = builder.tool_exe(Tool::RemoteTestClient);
Mark Simulacrum001e9f32017-07-05 01:41:431293 let mut cmd = Command::new(&tool);
1294 cmd.arg("spawn-emulator")
1295 .arg(target)
1296 .arg(&server)
1297 .arg(build.out.join("tmp"));
1298 if let Some(rootfs) = build.qemu_rootfs(target) {
1299 cmd.arg(rootfs);
1300 }
1301 build.run(&mut cmd);
1302
1303 // Push all our dylibs to the emulator
Mark Simulacrum60388302017-07-05 16:46:411304 for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
Mark Simulacrum001e9f32017-07-05 01:41:431305 let f = t!(f);
1306 let name = f.file_name().into_string().unwrap();
1307 if util::is_dylib(&name) {
1308 build.run(Command::new(&tool)
1309 .arg("push")
1310 .arg(f.path()));
1311 }
Alex Crichton1747ce22017-01-28 21:38:061312 }
1313 }
1314}
1315
Mark Simulacrum528646e2017-07-14 00:48:441316#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431317pub struct Distcheck;
1318
Mark Simulacrum528646e2017-07-14 00:48:441319impl Step for Distcheck {
Mark Simulacrum001e9f32017-07-05 01:41:431320 type Output = ();
Mark Simulacrum44ffb612017-07-30 04:12:531321 const ONLY_BUILD: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:431322
Mark Simulacrum56128fb2017-07-19 00:03:381323 fn should_run(run: ShouldRun) -> ShouldRun {
1324 run.path("distcheck")
Mark Simulacrum681b1232017-07-14 12:30:161325 }
1326
Mark Simulacrum8f2e5762017-07-22 13:35:421327 fn make_run(run: RunConfig) {
1328 run.builder.ensure(Distcheck);
1329 }
1330
Mark Simulacrum001e9f32017-07-05 01:41:431331 /// Run "distcheck", a 'make check' from a tarball
1332 fn run(self, builder: &Builder) {
1333 let build = builder.build;
1334
Mark Simulacrum001e9f32017-07-05 01:41:431335 println!("Distcheck");
1336 let dir = build.out.join("tmp").join("distcheck");
1337 let _ = fs::remove_dir_all(&dir);
1338 t!(fs::create_dir_all(&dir));
1339
Mark Simulacrum1c118232017-07-22 16:48:291340 // Guarantee that these are built before we begin running.
1341 builder.ensure(dist::PlainSourceTarball);
1342 builder.ensure(dist::Src);
1343
Mark Simulacrum001e9f32017-07-05 01:41:431344 let mut cmd = Command::new("tar");
1345 cmd.arg("-xzf")
Mark Simulacrum5984e702017-07-13 00:52:311346 .arg(builder.ensure(dist::PlainSourceTarball))
Mark Simulacrum001e9f32017-07-05 01:41:431347 .arg("--strip-components=1")
1348 .current_dir(&dir);
1349 build.run(&mut cmd);
1350 build.run(Command::new("./configure")
1351 .args(&build.config.configure_args)
1352 .arg("--enable-vendor")
1353 .current_dir(&dir));
1354 build.run(Command::new(build_helper::make(&build.build))
1355 .arg("check")
1356 .current_dir(&dir));
1357
1358 // Now make sure that rust-src has all of libstd's dependencies
1359 println!("Distcheck rust-src");
1360 let dir = build.out.join("tmp").join("distcheck-src");
1361 let _ = fs::remove_dir_all(&dir);
1362 t!(fs::create_dir_all(&dir));
1363
1364 let mut cmd = Command::new("tar");
1365 cmd.arg("-xzf")
Mark Simulacrum5984e702017-07-13 00:52:311366 .arg(builder.ensure(dist::Src))
Mark Simulacrum001e9f32017-07-05 01:41:431367 .arg("--strip-components=1")
1368 .current_dir(&dir);
1369 build.run(&mut cmd);
1370
1371 let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
1372 build.run(Command::new(&build.initial_cargo)
1373 .arg("generate-lockfile")
1374 .arg("--manifest-path")
1375 .arg(&toml)
1376 .current_dir(&dir));
Alex Crichtond38db822016-12-09 01:13:551377 }
Alex Crichtond38db822016-12-09 01:13:551378}
Alex Crichton1a040b32016-12-31 03:50:571379
Mark Simulacrum528646e2017-07-14 00:48:441380#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431381pub struct Bootstrap;
1382
Mark Simulacrum528646e2017-07-14 00:48:441383impl Step for Bootstrap {
Mark Simulacrum001e9f32017-07-05 01:41:431384 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271385 const DEFAULT: bool = true;
1386 const ONLY_HOSTS: bool = true;
1387 const ONLY_BUILD: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:431388
1389 /// Test the build system itself
1390 fn run(self, builder: &Builder) {
1391 let build = builder.build;
1392 let mut cmd = Command::new(&build.initial_cargo);
1393 cmd.arg("test")
1394 .current_dir(build.src.join("src/bootstrap"))
1395 .env("CARGO_TARGET_DIR", build.out.join("bootstrap"))
1396 .env("RUSTC_BOOTSTRAP", "1")
1397 .env("RUSTC", &build.initial_rustc);
1398 if !build.fail_fast {
1399 cmd.arg("--no-fail-fast");
1400 }
Mark Simulacrum44ffb612017-07-30 04:12:531401 cmd.arg("--").args(&build.config.cmd.test_args());
Mark Simulacrum001e9f32017-07-05 01:41:431402 try_run(build, &mut cmd);
Josh Stone617aea42017-06-02 16:27:441403 }
Mark Simulacrum6b3413d2017-07-05 12:41:271404
Mark Simulacrum56128fb2017-07-19 00:03:381405 fn should_run(run: ShouldRun) -> ShouldRun {
1406 run.path("src/bootstrap")
Mark Simulacrum6b3413d2017-07-05 12:41:271407 }
1408
Mark Simulacrum6a67a052017-07-20 23:51:071409 fn make_run(run: RunConfig) {
1410 run.builder.ensure(Bootstrap);
Mark Simulacrum6b3413d2017-07-05 12:41:271411 }
Alex Crichton1a040b32016-12-31 03:50:571412}