blob: 95ac2be5423c66f7c9509d2fee9fa57e5a21178c [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 Schneider01555b12017-09-17 19:45:54301
302#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Oliver Schneiderf3817442017-08-28 14:54:50303pub struct Miri {
304 host: Interned<String>,
305}
306
307impl Step for Miri {
308 type Output = ();
309 const ONLY_HOSTS: bool = true;
310 const DEFAULT: bool = true;
311
312 fn should_run(run: ShouldRun) -> ShouldRun {
313 let test_miri = run.builder.build.config.test_miri;
314 run.path("src/tools/miri").default_condition(test_miri)
315 }
316
317 fn make_run(run: RunConfig) {
318 run.builder.ensure(Miri {
319 host: run.target,
320 });
321 }
322
323 /// Runs `cargo test` for miri.
324 fn run(self, builder: &Builder) {
325 let build = builder.build;
326 let host = self.host;
327 let compiler = builder.compiler(1, host);
328
329 let miri = builder.ensure(tool::Miri { compiler, target: self.host });
330 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
331 cargo.arg("--manifest-path").arg(build.src.join("src/tools/miri/Cargo.toml"));
332
333 // Don't build tests dynamically, just a pain to work with
334 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
335 // miri tests need to know about the stage sysroot
336 cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
337 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
338 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
339 cargo.env("MIRI_PATH", miri);
340
341 builder.add_rustc_lib_path(compiler, &mut cargo);
342
Oliver Schneiderab018c72017-08-30 16:59:26343 try_run_expecting(
344 build,
345 &mut cargo,
346 builder.build.config.toolstate.miri.passes(ToolState::Testing),
347 );
Oliver Schneiderf3817442017-08-28 14:54:50348 }
349}
350
Nick Camerond0070e82017-09-01 06:43:00351
Mark Simulacrumdec44b02017-07-17 15:52:05352fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
Nick Cameron04415dc2017-06-30 18:58:54353 // Configure PATH to find the right rustc. NB. we have to use PATH
354 // and not RUSTC because the Cargo test suite has tests that will
355 // fail if rustc is not spelled `rustc`.
Mark Simulacrumdec44b02017-07-17 15:52:05356 let path = builder.sysroot(compiler).join("bin");
Nick Cameron04415dc2017-06-30 18:58:54357 let old_path = env::var_os("PATH").unwrap_or_default();
358 env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
Brian Anderson3a790ac2016-03-18 20:54:31359}
Alex Crichton9dd3c542016-03-29 20:14:52360
Mark Simulacrum528646e2017-07-14 00:48:44361#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
362pub struct Tidy {
363 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43364}
365
Mark Simulacrum528646e2017-07-14 00:48:44366impl Step for Tidy {
Mark Simulacrum001e9f32017-07-05 01:41:43367 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27368 const DEFAULT: bool = true;
369 const ONLY_HOSTS: bool = true;
370 const ONLY_BUILD: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43371
372 /// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
373 ///
374 /// This tool in `src/tools` checks up on various bits and pieces of style and
375 /// otherwise just implements a few lint-like checks that are specific to the
376 /// compiler itself.
377 fn run(self, builder: &Builder) {
378 let build = builder.build;
379 let host = self.host;
380
381 let _folder = build.fold_output(|| "tidy");
382 println!("tidy check ({})", host);
Mark Simulacrum60388302017-07-05 16:46:41383 let mut cmd = builder.tool_cmd(Tool::Tidy);
Mark Simulacrum001e9f32017-07-05 01:41:43384 cmd.arg(build.src.join("src"));
385 if !build.config.vendor {
386 cmd.arg("--no-vendor");
387 }
388 if build.config.quiet_tests {
389 cmd.arg("--quiet");
390 }
391 try_run(build, &mut cmd);
Eduard-Mihai Burtescud29f0bc2017-02-10 20:59:40392 }
Mark Simulacrum6b3413d2017-07-05 12:41:27393
Mark Simulacrum56128fb2017-07-19 00:03:38394 fn should_run(run: ShouldRun) -> ShouldRun {
395 run.path("src/tools/tidy")
Mark Simulacrum6b3413d2017-07-05 12:41:27396 }
397
Mark Simulacrum6a67a052017-07-20 23:51:07398 fn make_run(run: RunConfig) {
399 run.builder.ensure(Tidy {
400 host: run.builder.build.build,
Mark Simulacrum6b3413d2017-07-05 12:41:27401 });
402 }
Alex Crichton9dd3c542016-03-29 20:14:52403}
Alex Crichtonb325baf2016-04-05 18:34:23404
Mark Simulacrum528646e2017-07-14 00:48:44405fn testdir(build: &Build, host: Interned<String>) -> PathBuf {
Alex Crichtonb325baf2016-04-05 18:34:23406 build.out.join(host).join("test")
407}
408
Mark Simulacrum528646e2017-07-14 00:48:44409#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum1ab89302017-07-07 17:51:57410struct Test {
Mark Simulacrum1ab89302017-07-07 17:51:57411 path: &'static str,
412 mode: &'static str,
413 suite: &'static str,
414}
415
Mark Simulacrumaa8b93b2017-07-07 18:31:29416static DEFAULT_COMPILETESTS: &[Test] = &[
417 Test { path: "src/test/ui", mode: "ui", suite: "ui" },
418 Test { path: "src/test/run-pass", mode: "run-pass", suite: "run-pass" },
419 Test { path: "src/test/compile-fail", mode: "compile-fail", suite: "compile-fail" },
420 Test { path: "src/test/parse-fail", mode: "parse-fail", suite: "parse-fail" },
421 Test { path: "src/test/run-fail", mode: "run-fail", suite: "run-fail" },
Mark Simulacrum1ab89302017-07-07 17:51:57422 Test {
Mark Simulacrum1ab89302017-07-07 17:51:57423 path: "src/test/run-pass-valgrind",
424 mode: "run-pass-valgrind",
425 suite: "run-pass-valgrind"
426 },
Mark Simulacrumaa8b93b2017-07-07 18:31:29427 Test { path: "src/test/mir-opt", mode: "mir-opt", suite: "mir-opt" },
428 Test { path: "src/test/codegen", mode: "codegen", suite: "codegen" },
429 Test { path: "src/test/codegen-units", mode: "codegen-units", suite: "codegen-units" },
430 Test { path: "src/test/incremental", mode: "incremental", suite: "incremental" },
Mark Simulacrum6b3413d2017-07-05 12:41:27431
Mark Simulacrumaa8b93b2017-07-07 18:31:29432 // What this runs varies depending on the native platform being apple
433 Test { path: "src/test/debuginfo", mode: "debuginfo-XXX", suite: "debuginfo" },
Mark Simulacrumaa8b93b2017-07-07 18:31:29434];
Mark Simulacrum6b3413d2017-07-05 12:41:27435
Mark Simulacrumf1d04a32017-07-20 15:42:18436#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
437pub struct DefaultCompiletest {
438 compiler: Compiler,
439 target: Interned<String>,
440 mode: &'static str,
441 suite: &'static str,
442}
443
444impl Step for DefaultCompiletest {
445 type Output = ();
446 const DEFAULT: bool = true;
447
448 fn should_run(mut run: ShouldRun) -> ShouldRun {
449 for test in DEFAULT_COMPILETESTS {
450 run = run.path(test.path);
451 }
452 run
453 }
454
Mark Simulacrum6a67a052017-07-20 23:51:07455 fn make_run(run: RunConfig) {
456 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
Mark Simulacrumf1d04a32017-07-20 15:42:18457
Mark Simulacrum6a67a052017-07-20 23:51:07458 let test = run.path.map(|path| {
Mark Simulacrumf1d04a32017-07-20 15:42:18459 DEFAULT_COMPILETESTS.iter().find(|&&test| {
460 path.ends_with(test.path)
461 }).unwrap_or_else(|| {
462 panic!("make_run in compile test to receive test path, received {:?}", path);
463 })
464 });
465
466 if let Some(test) = test {
Mark Simulacrum6a67a052017-07-20 23:51:07467 run.builder.ensure(DefaultCompiletest {
Mark Simulacrumf1d04a32017-07-20 15:42:18468 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07469 target: run.target,
Mark Simulacrumf1d04a32017-07-20 15:42:18470 mode: test.mode,
471 suite: test.suite,
472 });
473 } else {
474 for test in DEFAULT_COMPILETESTS {
Mark Simulacrum6a67a052017-07-20 23:51:07475 run.builder.ensure(DefaultCompiletest {
Mark Simulacrumf1d04a32017-07-20 15:42:18476 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07477 target: run.target,
Mark Simulacrumf1d04a32017-07-20 15:42:18478 mode: test.mode,
479 suite: test.suite
480 });
481 }
482 }
483 }
484
485 fn run(self, builder: &Builder) {
486 builder.ensure(Compiletest {
487 compiler: self.compiler,
488 target: self.target,
489 mode: self.mode,
490 suite: self.suite,
491 })
492 }
493}
494
Mark Simulacrumaa8b93b2017-07-07 18:31:29495// Also default, but host-only.
496static HOST_COMPILETESTS: &[Test] = &[
497 Test { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" },
498 Test { path: "src/test/run-pass-fulldeps", mode: "run-pass", suite: "run-pass-fulldeps" },
499 Test { path: "src/test/run-fail-fulldeps", mode: "run-fail", suite: "run-fail-fulldeps" },
Mark Simulacrum1ab89302017-07-07 17:51:57500 Test {
Mark Simulacrum1ab89302017-07-07 17:51:57501 path: "src/test/compile-fail-fulldeps",
502 mode: "compile-fail",
503 suite: "compile-fail-fulldeps",
504 },
Mark Simulacrumaa8b93b2017-07-07 18:31:29505 Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" },
506 Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" },
Mark Simulacrum6b3413d2017-07-05 12:41:27507
Mark Simulacrumaa8b93b2017-07-07 18:31:29508 Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" },
509 Test { path: "src/test/run-pass/pretty", mode: "pretty", suite: "run-pass" },
510 Test { path: "src/test/run-fail/pretty", mode: "pretty", suite: "run-fail" },
511 Test { path: "src/test/run-pass-valgrind/pretty", mode: "pretty", suite: "run-pass-valgrind" },
512 Test { path: "src/test/run-pass-fulldeps/pretty", mode: "pretty", suite: "run-pass-fulldeps" },
513 Test { path: "src/test/run-fail-fulldeps/pretty", mode: "pretty", suite: "run-fail-fulldeps" },
Mark Simulacrum6b3413d2017-07-05 12:41:27514];
515
Mark Simulacrumf1d04a32017-07-20 15:42:18516#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
517pub struct HostCompiletest {
518 compiler: Compiler,
519 target: Interned<String>,
520 mode: &'static str,
521 suite: &'static str,
522}
Mark Simulacrum6b3413d2017-07-05 12:41:27523
Mark Simulacrumf1d04a32017-07-20 15:42:18524impl Step for HostCompiletest {
Mark Simulacrum001e9f32017-07-05 01:41:43525 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27526 const DEFAULT: bool = true;
Mark Simulacrumf1d04a32017-07-20 15:42:18527 const ONLY_HOSTS: bool = true;
Mark Simulacrum6b3413d2017-07-05 12:41:27528
Mark Simulacrum56128fb2017-07-19 00:03:38529 fn should_run(mut run: ShouldRun) -> ShouldRun {
Mark Simulacrumf1d04a32017-07-20 15:42:18530 for test in HOST_COMPILETESTS {
Mark Simulacrum56128fb2017-07-19 00:03:38531 run = run.path(test.path);
532 }
533 run
Mark Simulacrum6b3413d2017-07-05 12:41:27534 }
535
Mark Simulacrum6a67a052017-07-20 23:51:07536 fn make_run(run: RunConfig) {
537 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:27538
Mark Simulacrum6a67a052017-07-20 23:51:07539 let test = run.path.map(|path| {
Mark Simulacrumf1d04a32017-07-20 15:42:18540 HOST_COMPILETESTS.iter().find(|&&test| {
Mark Simulacrum1ab89302017-07-07 17:51:57541 path.ends_with(test.path)
Mark Simulacrum6b3413d2017-07-05 12:41:27542 }).unwrap_or_else(|| {
543 panic!("make_run in compile test to receive test path, received {:?}", path);
544 })
545 });
546
Mark Simulacrumf1d04a32017-07-20 15:42:18547 if let Some(test) = test {
Mark Simulacrum6a67a052017-07-20 23:51:07548 run.builder.ensure(HostCompiletest {
Mark Simulacrumf1d04a32017-07-20 15:42:18549 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07550 target: run.target,
Mark Simulacrumf1d04a32017-07-20 15:42:18551 mode: test.mode,
552 suite: test.suite,
Mark Simulacrum6b3413d2017-07-05 12:41:27553 });
Mark Simulacrumf1d04a32017-07-20 15:42:18554 } else {
555 for test in HOST_COMPILETESTS {
Mark Simulacruma88a09c2017-07-23 13:22:12556 if test.mode == "pretty" {
557 continue;
558 }
Mark Simulacrum6a67a052017-07-20 23:51:07559 run.builder.ensure(HostCompiletest {
Mark Simulacrumaa8b93b2017-07-07 18:31:29560 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07561 target: run.target,
Mark Simulacrumaa8b93b2017-07-07 18:31:29562 mode: test.mode,
563 suite: test.suite
564 });
565 }
Mark Simulacrum6b3413d2017-07-05 12:41:27566 }
567 }
Alex Crichtonf72bfe62016-05-02 22:16:15568
Mark Simulacrumf1d04a32017-07-20 15:42:18569 fn run(self, builder: &Builder) {
570 builder.ensure(Compiletest {
571 compiler: self.compiler,
572 target: self.target,
573 mode: self.mode,
574 suite: self.suite,
575 })
576 }
577}
578
579#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
580struct Compiletest {
581 compiler: Compiler,
582 target: Interned<String>,
583 mode: &'static str,
584 suite: &'static str,
585}
586
587impl Step for Compiletest {
588 type Output = ();
589
590 fn should_run(run: ShouldRun) -> ShouldRun {
591 run.never()
592 }
593
Mark Simulacrum001e9f32017-07-05 01:41:43594 /// Executes the `compiletest` tool to run a suite of tests.
595 ///
596 /// Compiles all tests with `compiler` for `target` with the specified
597 /// compiletest `mode` and `suite` arguments. For example `mode` can be
598 /// "run-pass" or `suite` can be something like `debuginfo`.
599 fn run(self, builder: &Builder) {
600 let build = builder.build;
601 let compiler = self.compiler;
602 let target = self.target;
603 let mode = self.mode;
604 let suite = self.suite;
Mark Simulacrum6b3413d2017-07-05 12:41:27605
606 // Skip codegen tests if they aren't enabled in configuration.
607 if !build.config.codegen_tests && suite == "codegen" {
608 return;
609 }
610
611 if suite == "debuginfo" {
Mark Simulacrum951616c2017-07-20 17:23:29612 // Skip debuginfo tests on MSVC
613 if build.build.contains("msvc") {
614 return;
615 }
616
Mark Simulacrum6b3413d2017-07-05 12:41:27617 if mode == "debuginfo-XXX" {
618 return if build.build.contains("apple") {
619 builder.ensure(Compiletest {
620 mode: "debuginfo-lldb",
621 ..self
Mark Simulacrum528646e2017-07-14 00:48:44622 });
Mark Simulacrum6b3413d2017-07-05 12:41:27623 } else {
624 builder.ensure(Compiletest {
625 mode: "debuginfo-gdb",
626 ..self
Mark Simulacrum528646e2017-07-14 00:48:44627 });
Mark Simulacrum6b3413d2017-07-05 12:41:27628 };
629 }
630
Mark Simulacrum6b3413d2017-07-05 12:41:27631 builder.ensure(dist::DebuggerScripts {
Mark Simulacrum528646e2017-07-14 00:48:44632 sysroot: builder.sysroot(compiler),
Mark Simulacrumfef9b482017-07-23 16:03:40633 host: target
Mark Simulacrum6b3413d2017-07-05 12:41:27634 });
635 }
636
637 if suite.ends_with("fulldeps") ||
638 // FIXME: Does pretty need librustc compiled? Note that there are
639 // fulldeps test suites with mode = pretty as well.
640 mode == "pretty" ||
641 mode == "rustdoc" ||
642 mode == "run-make" {
643 builder.ensure(compile::Rustc { compiler, target });
644 }
645
646 builder.ensure(compile::Test { compiler, target });
647 builder.ensure(native::TestHelpers { target });
Mark Simulacrumaa8b93b2017-07-07 18:31:29648 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum6b3413d2017-07-05 12:41:27649
Mark Simulacrum001e9f32017-07-05 01:41:43650 let _folder = build.fold_output(|| format!("test_{}", suite));
651 println!("Check compiletest suite={} mode={} ({} -> {})",
Mark Simulacrum528646e2017-07-14 00:48:44652 suite, mode, &compiler.host, target);
Mark Simulacrum6b3413d2017-07-05 12:41:27653 let mut cmd = builder.tool_cmd(Tool::Compiletest);
Alex Crichtonb325baf2016-04-05 18:34:23654
Mark Simulacrum001e9f32017-07-05 01:41:43655 // compiletest currently has... a lot of arguments, so let's just pass all
656 // of them!
Brian Anderson8401e372016-09-15 19:42:26657
Mark Simulacrumc114fe52017-07-05 17:21:33658 cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
Mark Simulacrum60388302017-07-05 16:46:41659 cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
Mark Simulacrumc114fe52017-07-05 17:21:33660 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
Mark Simulacrum4e5333c2017-07-25 22:54:33661
662 // Avoid depending on rustdoc when we don't need it.
663 if mode == "rustdoc" || mode == "run-make" {
Mark Simulacrumfacf5a92017-08-04 22:13:01664 cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
Mark Simulacrum4e5333c2017-07-25 22:54:33665 }
666
Mark Simulacrum001e9f32017-07-05 01:41:43667 cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
668 cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
669 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
670 cmd.arg("--mode").arg(mode);
671 cmd.arg("--target").arg(target);
Mark Simulacrum528646e2017-07-14 00:48:44672 cmd.arg("--host").arg(&*compiler.host);
673 cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(build.build));
Alex Crichtonf4e4ec72016-05-13 22:26:41674
Mark Simulacrum001e9f32017-07-05 01:41:43675 if let Some(ref nodejs) = build.config.nodejs {
676 cmd.arg("--nodejs").arg(nodejs);
677 }
Alex Crichtonf4e4ec72016-05-13 22:26:41678
Mark Simulacrum001e9f32017-07-05 01:41:43679 let mut flags = vec!["-Crpath".to_string()];
680 if build.config.rust_optimize_tests {
681 flags.push("-O".to_string());
682 }
683 if build.config.rust_debuginfo_tests {
684 flags.push("-g".to_string());
685 }
Alex Crichtoncbe62922016-04-19 16:44:19686
Mark Simulacrum60388302017-07-05 16:46:41687 let mut hostflags = build.rustc_flags(compiler.host);
Mark Simulacrum001e9f32017-07-05 01:41:43688 hostflags.extend(flags.clone());
689 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
Alex Crichtoncbe62922016-04-19 16:44:19690
Mark Simulacrum528646e2017-07-14 00:48:44691 let mut targetflags = build.rustc_flags(target);
Mark Simulacrum001e9f32017-07-05 01:41:43692 targetflags.extend(flags);
693 targetflags.push(format!("-Lnative={}",
694 build.test_helpers_out(target).display()));
695 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
Alex Crichtonb325baf2016-04-05 18:34:23696
Mark Simulacrum001e9f32017-07-05 01:41:43697 cmd.arg("--docck-python").arg(build.python());
Alex Crichtonb325baf2016-04-05 18:34:23698
Mark Simulacrum001e9f32017-07-05 01:41:43699 if build.build.ends_with("apple-darwin") {
700 // Force /usr/bin/python on macOS for LLDB tests because we're loading the
701 // LLDB plugin's compiled module which only works with the system python
702 // (namely not Homebrew-installed python)
703 cmd.arg("--lldb-python").arg("/usr/bin/python");
704 } else {
705 cmd.arg("--lldb-python").arg(build.python());
706 }
Alex Crichtonb325baf2016-04-05 18:34:23707
Mark Simulacrum001e9f32017-07-05 01:41:43708 if let Some(ref gdb) = build.config.gdb {
709 cmd.arg("--gdb").arg(gdb);
710 }
711 if let Some(ref vers) = build.lldb_version {
712 cmd.arg("--lldb-version").arg(vers);
713 }
714 if let Some(ref dir) = build.lldb_python_dir {
715 cmd.arg("--lldb-python-dir").arg(dir);
716 }
Alex Crichtonb325baf2016-04-05 18:34:23717
Mark Simulacrum44ffb612017-07-30 04:12:53718 cmd.args(&build.config.cmd.test_args());
Corey Farwellc8c6d2c2016-10-30 01:58:52719
Mark Simulacrum001e9f32017-07-05 01:41:43720 if build.is_verbose() {
721 cmd.arg("--verbose");
722 }
Alex Crichton126e09e2016-04-14 22:51:03723
Mark Simulacrum001e9f32017-07-05 01:41:43724 if build.config.quiet_tests {
725 cmd.arg("--quiet");
726 }
Alex Crichton1747ce22017-01-28 21:38:06727
bjorn30c97bbf2017-08-13 10:30:54728 if build.config.llvm_enabled {
729 let llvm_config = build.llvm_config(target);
730 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
731 cmd.arg("--llvm-version").arg(llvm_version);
732 if !build.is_rust_llvm(target) {
733 cmd.arg("--system-llvm");
734 }
735
736 // Only pass correct values for these flags for the `run-make` suite as it
737 // requires that a C++ compiler was configured which isn't always the case.
738 if suite == "run-make" {
739 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
740 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
741 cmd.arg("--cc").arg(build.cc(target))
742 .arg("--cxx").arg(build.cxx(target).unwrap())
743 .arg("--cflags").arg(build.cflags(target).join(" "))
744 .arg("--llvm-components").arg(llvm_components.trim())
745 .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
746 }
747 }
748 if suite == "run-make" && !build.config.llvm_enabled {
bjorn31c28cf52017-08-13 14:49:09749 println!("Ignoring run-make test suite as they generally dont work without LLVM");
bjorn30c97bbf2017-08-13 10:30:54750 return;
751 }
752
753 if suite != "run-make" {
Mark Simulacrum001e9f32017-07-05 01:41:43754 cmd.arg("--cc").arg("")
755 .arg("--cxx").arg("")
756 .arg("--cflags").arg("")
757 .arg("--llvm-components").arg("")
758 .arg("--llvm-cxxflags").arg("");
759 }
760
761 if build.remote_tested(target) {
Mark Simulacrum6b3413d2017-07-05 12:41:27762 cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
Mark Simulacrum001e9f32017-07-05 01:41:43763 }
764
765 // Running a C compiler on MSVC requires a few env vars to be set, to be
766 // sure to set them here.
767 //
768 // Note that if we encounter `PATH` we make sure to append to our own `PATH`
769 // rather than stomp over it.
770 if target.contains("msvc") {
Mark Simulacrum528646e2017-07-14 00:48:44771 for &(ref k, ref v) in build.cc[&target].0.env() {
Mark Simulacrum001e9f32017-07-05 01:41:43772 if k != "PATH" {
773 cmd.env(k, v);
774 }
Alex Crichton126e09e2016-04-14 22:51:03775 }
776 }
Mark Simulacrum001e9f32017-07-05 01:41:43777 cmd.env("RUSTC_BOOTSTRAP", "1");
778 build.add_rust_test_threads(&mut cmd);
779
780 if build.config.sanitizers {
781 cmd.env("SANITIZER_SUPPORT", "1");
782 }
783
784 if build.config.profiler {
785 cmd.env("PROFILER_SUPPORT", "1");
786 }
787
788 cmd.arg("--adb-path").arg("adb");
789 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
790 if target.contains("android") {
791 // Assume that cc for this target comes from the android sysroot
792 cmd.arg("--android-cross-path")
793 .arg(build.cc(target).parent().unwrap().parent().unwrap());
794 } else {
795 cmd.arg("--android-cross-path").arg("");
796 }
797
798 build.ci_env.force_coloring_in_ci(&mut cmd);
799
800 let _time = util::timeit();
801 try_run(build, &mut cmd);
Alex Crichton126e09e2016-04-14 22:51:03802 }
Alex Crichtonb325baf2016-04-05 18:34:23803}
Alex Crichtonede89442016-04-15 01:00:35804
Mark Simulacrum528646e2017-07-14 00:48:44805#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
806pub struct Docs {
807 compiler: Compiler,
Mark Simulacruma5ab2ce2017-07-12 15:15:00808}
809
Mark Simulacrum528646e2017-07-14 00:48:44810impl Step for Docs {
Mark Simulacruma5ab2ce2017-07-12 15:15:00811 type Output = ();
812 const DEFAULT: bool = true;
813 const ONLY_HOSTS: bool = true;
Alex Crichtonede89442016-04-15 01:00:35814
Mark Simulacrum56128fb2017-07-19 00:03:38815 fn should_run(run: ShouldRun) -> ShouldRun {
816 run.path("src/doc")
Mark Simulacruma5ab2ce2017-07-12 15:15:00817 }
818
Mark Simulacrum6a67a052017-07-20 23:51:07819 fn make_run(run: RunConfig) {
820 run.builder.ensure(Docs {
821 compiler: run.builder.compiler(run.builder.top_stage, run.host),
Mark Simulacruma5ab2ce2017-07-12 15:15:00822 });
823 }
824
825 /// Run `rustdoc --test` for all documentation in `src/doc`.
826 ///
827 /// This will run all tests in our markdown documentation (e.g. the book)
828 /// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
829 /// `compiler`.
830 fn run(self, builder: &Builder) {
831 let build = builder.build;
832 let compiler = self.compiler;
Mark Simulacrumceecd622017-07-12 16:12:47833
834 builder.ensure(compile::Test { compiler, target: compiler.host });
835
Mark Simulacruma5ab2ce2017-07-12 15:15:00836 // Do a breadth-first traversal of the `src/doc` directory and just run
837 // tests for all files that end in `*.md`
838 let mut stack = vec![build.src.join("src/doc")];
839 let _time = util::timeit();
840 let _folder = build.fold_output(|| "test_docs");
841
842 while let Some(p) = stack.pop() {
843 if p.is_dir() {
844 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
845 continue
846 }
847
848 if p.extension().and_then(|s| s.to_str()) != Some("md") {
849 continue;
850 }
851
852 // The nostarch directory in the book is for no starch, and so isn't
853 // guaranteed to build. We don't care if it doesn't build, so skip it.
854 if p.to_str().map_or(false, |p| p.contains("nostarch")) {
855 continue;
856 }
857
858 markdown_test(builder, compiler, &p);
Alex Crichtonede89442016-04-15 01:00:35859 }
Alex Crichtonede89442016-04-15 01:00:35860 }
861}
862
Mark Simulacrum528646e2017-07-14 00:48:44863#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
864pub struct ErrorIndex {
865 compiler: Compiler,
Mark Simulacrum001e9f32017-07-05 01:41:43866}
Alex Crichton0e272de2016-11-16 20:31:19867
Mark Simulacrum528646e2017-07-14 00:48:44868impl Step for ErrorIndex {
Mark Simulacrum001e9f32017-07-05 01:41:43869 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27870 const DEFAULT: bool = true;
871 const ONLY_HOSTS: bool = true;
872
Mark Simulacrum56128fb2017-07-19 00:03:38873 fn should_run(run: ShouldRun) -> ShouldRun {
874 run.path("src/tools/error_index_generator")
Mark Simulacrum6b3413d2017-07-05 12:41:27875 }
876
Mark Simulacrum6a67a052017-07-20 23:51:07877 fn make_run(run: RunConfig) {
878 run.builder.ensure(ErrorIndex {
879 compiler: run.builder.compiler(run.builder.top_stage, run.host),
Mark Simulacrum6b3413d2017-07-05 12:41:27880 });
881 }
Alex Crichtonede89442016-04-15 01:00:35882
Mark Simulacrum001e9f32017-07-05 01:41:43883 /// Run the error index generator tool to execute the tests located in the error
884 /// index.
885 ///
886 /// The `error_index_generator` tool lives in `src/tools` and is used to
887 /// generate a markdown file from the error indexes of the code base which is
888 /// then passed to `rustdoc --test`.
889 fn run(self, builder: &Builder) {
890 let build = builder.build;
891 let compiler = self.compiler;
892
Mark Simulacrum6b3413d2017-07-05 12:41:27893 builder.ensure(compile::Std { compiler, target: compiler.host });
894
Mark Simulacrum001e9f32017-07-05 01:41:43895 let _folder = build.fold_output(|| "test_error_index");
896 println!("Testing error-index stage{}", compiler.stage);
897
898 let dir = testdir(build, compiler.host);
899 t!(fs::create_dir_all(&dir));
900 let output = dir.join("error-index.md");
901
902 let _time = util::timeit();
Mark Simulacrum60388302017-07-05 16:46:41903 build.run(builder.tool_cmd(Tool::ErrorIndex)
Mark Simulacrum001e9f32017-07-05 01:41:43904 .arg("markdown")
905 .arg(&output)
906 .env("CFG_BUILD", &build.build));
907
Mark Simulacrumc114fe52017-07-05 17:21:33908 markdown_test(builder, compiler, &output);
Mark Simulacrum001e9f32017-07-05 01:41:43909 }
Alex Crichtonede89442016-04-15 01:00:35910}
911
Mark Simulacrumc114fe52017-07-05 17:21:33912fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
913 let build = builder.build;
Mark Simulacrumdd1d75e2017-06-04 23:55:50914 let mut file = t!(File::open(markdown));
915 let mut contents = String::new();
916 t!(file.read_to_string(&mut contents));
917 if !contents.contains("```") {
918 return;
919 }
920
Mark Simulacrumbc8fabb2017-06-06 18:00:22921 println!("doc tests for: {}", markdown.display());
Mark Simulacrumfacf5a92017-08-04 22:13:01922 let mut cmd = builder.rustdoc_cmd(compiler.host);
Alex Crichton0e272de2016-11-16 20:31:19923 build.add_rust_test_threads(&mut cmd);
Alex Crichtonede89442016-04-15 01:00:35924 cmd.arg("--test");
925 cmd.arg(markdown);
Alex Crichton6f62fae2016-12-12 17:03:35926 cmd.env("RUSTC_BOOTSTRAP", "1");
Corey Farwellc8c6d2c2016-10-30 01:58:52927
Mark Simulacrum44ffb612017-07-30 04:12:53928 let test_args = build.config.cmd.test_args().join(" ");
Corey Farwellc8c6d2c2016-10-30 01:58:52929 cmd.arg("--test-args").arg(test_args);
930
kennytm6ac07872017-05-21 20:27:47931 if build.config.quiet_tests {
Josh Stone617aea42017-06-02 16:27:44932 try_run_quiet(build, &mut cmd);
kennytm6ac07872017-05-21 20:27:47933 } else {
Josh Stone617aea42017-06-02 16:27:44934 try_run(build, &mut cmd);
kennytm6ac07872017-05-21 20:27:47935 }
Alex Crichtonede89442016-04-15 01:00:35936}
Alex Crichtonbb9062a2016-04-29 21:23:15937
Mark Simulacrum528646e2017-07-14 00:48:44938#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum981afa52017-07-18 21:28:53939pub struct CrateLibrustc {
Mark Simulacrum528646e2017-07-14 00:48:44940 compiler: Compiler,
941 target: Interned<String>,
Mark Simulacrum6b3413d2017-07-05 12:41:27942 test_kind: TestKind,
Mark Simulacrum528646e2017-07-14 00:48:44943 krate: Option<Interned<String>>,
Mark Simulacrum6b3413d2017-07-05 12:41:27944}
945
Mark Simulacrum981afa52017-07-18 21:28:53946impl Step for CrateLibrustc {
Mark Simulacrum6b3413d2017-07-05 12:41:27947 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27948 const DEFAULT: bool = true;
949 const ONLY_HOSTS: bool = true;
950
Mark Simulacrum56128fb2017-07-19 00:03:38951 fn should_run(run: ShouldRun) -> ShouldRun {
952 run.krate("rustc-main")
Mark Simulacrum6b3413d2017-07-05 12:41:27953 }
954
Mark Simulacrum6a67a052017-07-20 23:51:07955 fn make_run(run: RunConfig) {
956 let builder = run.builder;
957 let compiler = builder.compiler(builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:27958
Mark Simulacrum6a67a052017-07-20 23:51:07959 let make = |name: Option<Interned<String>>| {
Mark Simulacrum6b3413d2017-07-05 12:41:27960 let test_kind = if builder.kind == Kind::Test {
961 TestKind::Test
962 } else if builder.kind == Kind::Bench {
963 TestKind::Bench
964 } else {
Mark Simulacrum981afa52017-07-18 21:28:53965 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
Mark Simulacrum6b3413d2017-07-05 12:41:27966 };
967
Mark Simulacrum981afa52017-07-18 21:28:53968 builder.ensure(CrateLibrustc {
Mark Simulacrum6b3413d2017-07-05 12:41:27969 compiler,
Mark Simulacrum6a67a052017-07-20 23:51:07970 target: run.target,
Zack M. Davis1b6c9602017-08-07 05:54:09971 test_kind,
Mark Simulacrum6b3413d2017-07-05 12:41:27972 krate: name,
973 });
974 };
975
Mark Simulacrum6a67a052017-07-20 23:51:07976 if let Some(path) = run.path {
Mark Simulacrum6b3413d2017-07-05 12:41:27977 for (name, krate_path) in builder.crates("rustc-main") {
978 if path.ends_with(krate_path) {
Mark Simulacrum6a67a052017-07-20 23:51:07979 make(Some(name));
Mark Simulacrum6b3413d2017-07-05 12:41:27980 }
981 }
982 } else {
Mark Simulacrum6a67a052017-07-20 23:51:07983 make(None);
Mark Simulacrum6b3413d2017-07-05 12:41:27984 }
985 }
986
987
988 fn run(self, builder: &Builder) {
Mark Simulacrum981afa52017-07-18 21:28:53989 builder.ensure(Crate {
Mark Simulacrum6b3413d2017-07-05 12:41:27990 compiler: self.compiler,
991 target: self.target,
992 mode: Mode::Librustc,
993 test_kind: self.test_kind,
994 krate: self.krate,
995 });
996 }
997}
998
Mark Simulacrum528646e2017-07-14 00:48:44999#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum981afa52017-07-18 21:28:531000pub struct Crate {
Mark Simulacrum528646e2017-07-14 00:48:441001 compiler: Compiler,
1002 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431003 mode: Mode,
1004 test_kind: TestKind,
Mark Simulacrum528646e2017-07-14 00:48:441005 krate: Option<Interned<String>>,
Mark Simulacrum001e9f32017-07-05 01:41:431006}
Alex Crichtonbb9062a2016-04-29 21:23:151007
Mark Simulacrum981afa52017-07-18 21:28:531008impl Step for Crate {
Mark Simulacrum001e9f32017-07-05 01:41:431009 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271010 const DEFAULT: bool = true;
1011
Mark Simulacrum56128fb2017-07-19 00:03:381012 fn should_run(run: ShouldRun) -> ShouldRun {
1013 run.krate("std").krate("test")
Mark Simulacrum6b3413d2017-07-05 12:41:271014 }
1015
Mark Simulacrum6a67a052017-07-20 23:51:071016 fn make_run(run: RunConfig) {
1017 let builder = run.builder;
1018 let compiler = builder.compiler(builder.top_stage, run.host);
Mark Simulacrum6b3413d2017-07-05 12:41:271019
Mark Simulacrum6a67a052017-07-20 23:51:071020 let make = |mode: Mode, name: Option<Interned<String>>| {
Mark Simulacrum6b3413d2017-07-05 12:41:271021 let test_kind = if builder.kind == Kind::Test {
1022 TestKind::Test
1023 } else if builder.kind == Kind::Bench {
1024 TestKind::Bench
1025 } else {
Mark Simulacrum981afa52017-07-18 21:28:531026 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
Mark Simulacrum6b3413d2017-07-05 12:41:271027 };
1028
Mark Simulacrum981afa52017-07-18 21:28:531029 builder.ensure(Crate {
Mark Simulacrum6a67a052017-07-20 23:51:071030 compiler,
1031 target: run.target,
Zack M. Davis1b6c9602017-08-07 05:54:091032 mode,
1033 test_kind,
Mark Simulacrum6b3413d2017-07-05 12:41:271034 krate: name,
1035 });
1036 };
1037
Mark Simulacrum6a67a052017-07-20 23:51:071038 if let Some(path) = run.path {
Mark Simulacrum6b3413d2017-07-05 12:41:271039 for (name, krate_path) in builder.crates("std") {
1040 if path.ends_with(krate_path) {
Mark Simulacrum6a67a052017-07-20 23:51:071041 make(Mode::Libstd, Some(name));
Mark Simulacrum6b3413d2017-07-05 12:41:271042 }
1043 }
1044 for (name, krate_path) in builder.crates("test") {
1045 if path.ends_with(krate_path) {
Mark Simulacrum6a67a052017-07-20 23:51:071046 make(Mode::Libtest, Some(name));
Mark Simulacrum6b3413d2017-07-05 12:41:271047 }
1048 }
1049 } else {
Mark Simulacrum6a67a052017-07-20 23:51:071050 make(Mode::Libstd, None);
1051 make(Mode::Libtest, None);
Mark Simulacrum6b3413d2017-07-05 12:41:271052 }
1053 }
Alex Crichton7046fea2016-12-25 23:20:331054
Mark Simulacrum001e9f32017-07-05 01:41:431055 /// Run all unit tests plus documentation tests for an entire crate DAG defined
1056 /// by a `Cargo.toml`
1057 ///
1058 /// This is what runs tests for crates like the standard library, compiler, etc.
1059 /// It essentially is the driver for running `cargo test`.
1060 ///
1061 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
1062 /// arguments, and those arguments are discovered from `cargo metadata`.
1063 fn run(self, builder: &Builder) {
1064 let build = builder.build;
1065 let compiler = self.compiler;
1066 let target = self.target;
1067 let mode = self.mode;
1068 let test_kind = self.test_kind;
1069 let krate = self.krate;
Alex Crichtonbb9062a2016-04-29 21:23:151070
Mark Simulacrum6b3413d2017-07-05 12:41:271071 builder.ensure(compile::Test { compiler, target });
1072 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431073
1074 // If we're not doing a full bootstrap but we're testing a stage2 version of
1075 // libstd, then what we're actually testing is the libstd produced in
1076 // stage1. Reflect that here by updating the compiler that we're working
1077 // with automatically.
1078 let compiler = if build.force_use_stage1(compiler, target) {
Mark Simulacrum6b3413d2017-07-05 12:41:271079 builder.compiler(1, compiler.host)
Mark Simulacrum001e9f32017-07-05 01:41:431080 } else {
1081 compiler.clone()
1082 };
1083
Alex Crichton90105672017-07-17 16:32:081084 let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
1085 let (name, root) = match mode {
1086 Mode::Libstd => {
1087 compile::std_cargo(build, &compiler, target, &mut cargo);
1088 ("libstd", "std")
1089 }
1090 Mode::Libtest => {
1091 compile::test_cargo(build, &compiler, target, &mut cargo);
1092 ("libtest", "test")
1093 }
1094 Mode::Librustc => {
1095 builder.ensure(compile::Rustc { compiler, target });
1096 compile::rustc_cargo(build, &compiler, target, &mut cargo);
1097 ("librustc", "rustc-main")
1098 }
1099 _ => panic!("can only test libraries"),
1100 };
1101 let root = INTERNER.intern_string(String::from(root));
1102 let _folder = build.fold_output(|| {
1103 format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, name)
1104 });
1105 println!("{} {} stage{} ({} -> {})", test_kind, name, compiler.stage,
1106 &compiler.host, target);
1107
Mark Simulacrum001e9f32017-07-05 01:41:431108 // Build up the base `cargo test` command.
1109 //
1110 // Pass in some standard flags then iterate over the graph we've discovered
1111 // in `cargo metadata` with the maps above and figure out what `-p`
1112 // arguments need to get passed.
Mark Simulacrum001e9f32017-07-05 01:41:431113 if test_kind.subcommand() == "test" && !build.fail_fast {
1114 cargo.arg("--no-fail-fast");
Alex Crichtonbb9062a2016-04-29 21:23:151115 }
Mark Simulacrum001e9f32017-07-05 01:41:431116
1117 match krate {
1118 Some(krate) => {
1119 cargo.arg("-p").arg(krate);
1120 }
1121 None => {
1122 let mut visited = HashSet::new();
1123 let mut next = vec![root];
1124 while let Some(name) = next.pop() {
Alex Crichton90105672017-07-17 16:32:081125 // Right now jemalloc and the sanitizer crates are
1126 // target-specific crate in the sense that it's not present
1127 // on all platforms. Custom skip it here for now, but if we
1128 // add more this probably wants to get more generalized.
Mark Simulacrum001e9f32017-07-05 01:41:431129 //
Alex Crichton90105672017-07-17 16:32:081130 // Also skip `build_helper` as it's not compiled normally
1131 // for target during the bootstrap and it's just meant to be
1132 // a helper crate, not tested. If it leaks through then it
1133 // ends up messing with various mtime calculations and such.
1134 if !name.contains("jemalloc") &&
1135 *name != *"build_helper" &&
1136 !(name.starts_with("rustc_") && name.ends_with("san")) {
Mark Simulacrum001e9f32017-07-05 01:41:431137 cargo.arg("-p").arg(&format!("{}:0.0.0", name));
1138 }
Mark Simulacrum528646e2017-07-14 00:48:441139 for dep in build.crates[&name].deps.iter() {
Mark Simulacrum001e9f32017-07-05 01:41:431140 if visited.insert(dep) {
Mark Simulacrum528646e2017-07-14 00:48:441141 next.push(*dep);
Mark Simulacrum001e9f32017-07-05 01:41:431142 }
Alex Crichtona270b802016-10-21 20:18:091143 }
1144 }
Alex Crichtonbb9062a2016-04-29 21:23:151145 }
1146 }
Alex Crichtonbb9062a2016-04-29 21:23:151147
Mark Simulacrum001e9f32017-07-05 01:41:431148 // The tests are going to run with the *target* libraries, so we need to
1149 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
1150 //
1151 // Note that to run the compiler we need to run with the *host* libraries,
1152 // but our wrapper scripts arrange for that to be the case anyway.
1153 let mut dylib_path = dylib_path();
Mark Simulacrum528646e2017-07-14 00:48:441154 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
Mark Simulacrum001e9f32017-07-05 01:41:431155 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
Alex Crichtonbb9062a2016-04-29 21:23:151156
Mark Simulacrum001e9f32017-07-05 01:41:431157 cargo.arg("--");
Mark Simulacrum44ffb612017-07-30 04:12:531158 cargo.args(&build.config.cmd.test_args());
Alex Crichton0e272de2016-11-16 20:31:191159
Mark Simulacrum001e9f32017-07-05 01:41:431160 if build.config.quiet_tests {
1161 cargo.arg("--quiet");
1162 }
Corey Farwellc8c6d2c2016-10-30 01:58:521163
Mark Simulacrum001e9f32017-07-05 01:41:431164 let _time = util::timeit();
Alex Crichton0e272de2016-11-16 20:31:191165
Mark Simulacrum001e9f32017-07-05 01:41:431166 if target.contains("emscripten") {
Alex Crichton8e7849e2017-07-29 00:52:441167 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1168 build.config.nodejs.as_ref().expect("nodejs not configured"));
Mark Simulacrum001e9f32017-07-05 01:41:431169 } else if build.remote_tested(target) {
Alex Crichton8e7849e2017-07-29 00:52:441170 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1171 format!("{} run",
1172 builder.tool_exe(Tool::RemoteTestClient).display()));
Mark Simulacrum001e9f32017-07-05 01:41:431173 }
Alex Crichton8e7849e2017-07-29 00:52:441174 try_run(build, &mut cargo);
Alex Crichton39a5d3f2016-06-28 20:31:301175 }
1176}
1177
Mark Simulacrumf87696b2017-09-02 14:02:321178#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1179pub struct Rustdoc {
1180 host: Interned<String>,
1181 test_kind: TestKind,
1182}
1183
1184impl Step for Rustdoc {
1185 type Output = ();
1186 const DEFAULT: bool = true;
1187 const ONLY_HOSTS: bool = true;
1188
1189 fn should_run(run: ShouldRun) -> ShouldRun {
1190 run.path("src/librustdoc").path("src/tools/rustdoc")
1191 }
1192
1193 fn make_run(run: RunConfig) {
1194 let builder = run.builder;
1195
1196 let test_kind = if builder.kind == Kind::Test {
1197 TestKind::Test
1198 } else if builder.kind == Kind::Bench {
1199 TestKind::Bench
1200 } else {
1201 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
1202 };
1203
1204 builder.ensure(Rustdoc {
1205 host: run.host,
1206 test_kind,
1207 });
1208 }
1209
1210 fn run(self, builder: &Builder) {
1211 let build = builder.build;
1212 let test_kind = self.test_kind;
1213
1214 let compiler = builder.compiler(builder.top_stage, self.host);
1215 let target = compiler.host;
1216
Alex Crichton3da54fb2017-09-15 22:28:591217 let mut cargo = tool::prepare_tool_cargo(builder,
1218 compiler,
1219 target,
1220 test_kind.subcommand(),
1221 "src/tools/rustdoc");
Mark Simulacrumf87696b2017-09-02 14:02:321222 let _folder = build.fold_output(|| {
1223 format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
1224 });
1225 println!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
1226 &compiler.host, target);
1227
1228 if test_kind.subcommand() == "test" && !build.fail_fast {
1229 cargo.arg("--no-fail-fast");
1230 }
1231
1232 cargo.arg("-p").arg("rustdoc:0.0.0");
1233
1234 cargo.arg("--");
1235 cargo.args(&build.config.cmd.test_args());
1236
1237 if build.config.quiet_tests {
1238 cargo.arg("--quiet");
1239 }
1240
1241 let _time = util::timeit();
1242
1243 try_run(build, &mut cargo);
1244 }
1245}
1246
Alex Crichton8e7849e2017-07-29 00:52:441247fn envify(s: &str) -> String {
1248 s.chars().map(|c| {
1249 match c {
1250 '-' => '_',
1251 c => c,
Alex Crichton1747ce22017-01-28 21:38:061252 }
Alex Crichton8e7849e2017-07-29 00:52:441253 }).flat_map(|c| c.to_uppercase()).collect()
Alex Crichton39a5d3f2016-06-28 20:31:301254}
1255
Mark Simulacrumceecd622017-07-12 16:12:471256/// Some test suites are run inside emulators or on remote devices, and most
1257/// of our test binaries are linked dynamically which means we need to ship
1258/// the standard library and such to the emulator ahead of time. This step
1259/// represents this and is a dependency of all test suites.
1260///
1261/// Most of the time this is a noop. For some steps such as shipping data to
1262/// QEMU we have to build our own tools so we've got conditional dependencies
1263/// on those programs as well. Note that the remote test client is built for
1264/// the build target (us) and the server is built for the target.
Mark Simulacrum528646e2017-07-14 00:48:441265#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1266pub struct RemoteCopyLibs {
1267 compiler: Compiler,
1268 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431269}
Alex Crichton1747ce22017-01-28 21:38:061270
Mark Simulacrum528646e2017-07-14 00:48:441271impl Step for RemoteCopyLibs {
Mark Simulacrum001e9f32017-07-05 01:41:431272 type Output = ();
Alex Crichton1747ce22017-01-28 21:38:061273
Mark Simulacrum56128fb2017-07-19 00:03:381274 fn should_run(run: ShouldRun) -> ShouldRun {
1275 run.never()
Mark Simulacrum681b1232017-07-14 12:30:161276 }
1277
Mark Simulacrum001e9f32017-07-05 01:41:431278 fn run(self, builder: &Builder) {
1279 let build = builder.build;
1280 let compiler = self.compiler;
1281 let target = self.target;
1282 if !build.remote_tested(target) {
1283 return
1284 }
Alex Crichton1747ce22017-01-28 21:38:061285
Mark Simulacrum6b3413d2017-07-05 12:41:271286 builder.ensure(compile::Test { compiler, target });
1287
Mark Simulacrum001e9f32017-07-05 01:41:431288 println!("REMOTE copy libs to emulator ({})", target);
1289 t!(fs::create_dir_all(build.out.join("tmp")));
1290
Mark Simulacrumfe0eca02017-07-23 01:29:081291 let server = builder.ensure(tool::RemoteTestServer { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431292
1293 // Spawn the emulator and wait for it to come online
Mark Simulacrum6b3413d2017-07-05 12:41:271294 let tool = builder.tool_exe(Tool::RemoteTestClient);
Mark Simulacrum001e9f32017-07-05 01:41:431295 let mut cmd = Command::new(&tool);
1296 cmd.arg("spawn-emulator")
1297 .arg(target)
1298 .arg(&server)
1299 .arg(build.out.join("tmp"));
1300 if let Some(rootfs) = build.qemu_rootfs(target) {
1301 cmd.arg(rootfs);
1302 }
1303 build.run(&mut cmd);
1304
1305 // Push all our dylibs to the emulator
Mark Simulacrum60388302017-07-05 16:46:411306 for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
Mark Simulacrum001e9f32017-07-05 01:41:431307 let f = t!(f);
1308 let name = f.file_name().into_string().unwrap();
1309 if util::is_dylib(&name) {
1310 build.run(Command::new(&tool)
1311 .arg("push")
1312 .arg(f.path()));
1313 }
Alex Crichton1747ce22017-01-28 21:38:061314 }
1315 }
1316}
1317
Mark Simulacrum528646e2017-07-14 00:48:441318#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431319pub struct Distcheck;
1320
Mark Simulacrum528646e2017-07-14 00:48:441321impl Step for Distcheck {
Mark Simulacrum001e9f32017-07-05 01:41:431322 type Output = ();
Mark Simulacrum44ffb612017-07-30 04:12:531323 const ONLY_BUILD: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:431324
Mark Simulacrum56128fb2017-07-19 00:03:381325 fn should_run(run: ShouldRun) -> ShouldRun {
1326 run.path("distcheck")
Mark Simulacrum681b1232017-07-14 12:30:161327 }
1328
Mark Simulacrum8f2e5762017-07-22 13:35:421329 fn make_run(run: RunConfig) {
1330 run.builder.ensure(Distcheck);
1331 }
1332
Mark Simulacrum001e9f32017-07-05 01:41:431333 /// Run "distcheck", a 'make check' from a tarball
1334 fn run(self, builder: &Builder) {
1335 let build = builder.build;
1336
Mark Simulacrum001e9f32017-07-05 01:41:431337 println!("Distcheck");
1338 let dir = build.out.join("tmp").join("distcheck");
1339 let _ = fs::remove_dir_all(&dir);
1340 t!(fs::create_dir_all(&dir));
1341
Mark Simulacrum1c118232017-07-22 16:48:291342 // Guarantee that these are built before we begin running.
1343 builder.ensure(dist::PlainSourceTarball);
1344 builder.ensure(dist::Src);
1345
Mark Simulacrum001e9f32017-07-05 01:41:431346 let mut cmd = Command::new("tar");
1347 cmd.arg("-xzf")
Mark Simulacrum5984e702017-07-13 00:52:311348 .arg(builder.ensure(dist::PlainSourceTarball))
Mark Simulacrum001e9f32017-07-05 01:41:431349 .arg("--strip-components=1")
1350 .current_dir(&dir);
1351 build.run(&mut cmd);
1352 build.run(Command::new("./configure")
1353 .args(&build.config.configure_args)
1354 .arg("--enable-vendor")
1355 .current_dir(&dir));
1356 build.run(Command::new(build_helper::make(&build.build))
1357 .arg("check")
1358 .current_dir(&dir));
1359
1360 // Now make sure that rust-src has all of libstd's dependencies
1361 println!("Distcheck rust-src");
1362 let dir = build.out.join("tmp").join("distcheck-src");
1363 let _ = fs::remove_dir_all(&dir);
1364 t!(fs::create_dir_all(&dir));
1365
1366 let mut cmd = Command::new("tar");
1367 cmd.arg("-xzf")
Mark Simulacrum5984e702017-07-13 00:52:311368 .arg(builder.ensure(dist::Src))
Mark Simulacrum001e9f32017-07-05 01:41:431369 .arg("--strip-components=1")
1370 .current_dir(&dir);
1371 build.run(&mut cmd);
1372
1373 let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
1374 build.run(Command::new(&build.initial_cargo)
1375 .arg("generate-lockfile")
1376 .arg("--manifest-path")
1377 .arg(&toml)
1378 .current_dir(&dir));
Alex Crichtond38db822016-12-09 01:13:551379 }
Alex Crichtond38db822016-12-09 01:13:551380}
Alex Crichton1a040b32016-12-31 03:50:571381
Mark Simulacrum528646e2017-07-14 00:48:441382#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431383pub struct Bootstrap;
1384
Mark Simulacrum528646e2017-07-14 00:48:441385impl Step for Bootstrap {
Mark Simulacrum001e9f32017-07-05 01:41:431386 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271387 const DEFAULT: bool = true;
1388 const ONLY_HOSTS: bool = true;
1389 const ONLY_BUILD: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:431390
1391 /// Test the build system itself
1392 fn run(self, builder: &Builder) {
1393 let build = builder.build;
1394 let mut cmd = Command::new(&build.initial_cargo);
1395 cmd.arg("test")
1396 .current_dir(build.src.join("src/bootstrap"))
1397 .env("CARGO_TARGET_DIR", build.out.join("bootstrap"))
1398 .env("RUSTC_BOOTSTRAP", "1")
1399 .env("RUSTC", &build.initial_rustc);
1400 if !build.fail_fast {
1401 cmd.arg("--no-fail-fast");
1402 }
Mark Simulacrum44ffb612017-07-30 04:12:531403 cmd.arg("--").args(&build.config.cmd.test_args());
Mark Simulacrum001e9f32017-07-05 01:41:431404 try_run(build, &mut cmd);
Josh Stone617aea42017-06-02 16:27:441405 }
Mark Simulacrum6b3413d2017-07-05 12:41:271406
Mark Simulacrum56128fb2017-07-19 00:03:381407 fn should_run(run: ShouldRun) -> ShouldRun {
1408 run.path("src/bootstrap")
Mark Simulacrum6b3413d2017-07-05 12:41:271409 }
1410
Mark Simulacrum6a67a052017-07-20 23:51:071411 fn make_run(run: RunConfig) {
1412 run.builder.ensure(Bootstrap);
Mark Simulacrum6b3413d2017-07-05 12:41:271413 }
Alex Crichton1a040b32016-12-31 03:50:571414}