blob: 4be013e480e3419bf3b5088018c63f44ee38cb83 [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
Mark Simulacrum5b44cbc2017-06-26 16:23:5026use build_helper::{self, output};
Alex Crichton126e09e2016-04-14 22:51:0327
Mark Simulacrum001e9f32017-07-05 01:41:4328use {Build, Mode};
Alex Crichtond38db822016-12-09 01:13:5529use dist;
Mark Simulacrum001e9f32017-07-05 01:41:4330use util::{self, dylib_path, dylib_path_var};
31
32use compile;
33use native;
Mark Simulacrum56128fb2017-07-19 00:03:3834use builder::{Kind, ShouldRun, Builder, Compiler, Step};
Mark Simulacrumceecd622017-07-12 16:12:4735use tool::{self, Tool};
Mark Simulacrum528646e2017-07-14 00:48:4436use cache::{INTERNER, Interned};
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
Josh Stone617aea42017-06-02 16:27:4468fn try_run(build: &Build, cmd: &mut Command) {
Mark Simulacrum4dc8fe92017-06-27 19:37:2469 if !build.fail_fast {
Josh Stone617aea42017-06-02 16:27:4470 if !build.try_run(cmd) {
71 let failures = build.delayed_failures.get();
72 build.delayed_failures.set(failures + 1);
73 }
74 } else {
75 build.run(cmd);
76 }
77}
78
79fn try_run_quiet(build: &Build, cmd: &mut Command) {
Mark Simulacrum4dc8fe92017-06-27 19:37:2480 if !build.fail_fast {
Josh Stone617aea42017-06-02 16:27:4481 if !build.try_run_quiet(cmd) {
82 let failures = build.delayed_failures.get();
83 build.delayed_failures.set(failures + 1);
84 }
85 } else {
86 build.run_quiet(cmd);
87 }
88}
89
Mark Simulacrum0a1b5e82017-07-04 23:53:5390// rules.test("check-linkchecker", "src/tools/linkchecker")
91// .dep(|s| s.name("tool-linkchecker").stage(0))
92// .dep(|s| s.name("default:doc"))
93// .default(build.config.docs)
94// .host(true)
95// .run(move |s| check::linkcheck(build, s.target));
Alex Crichton0e272de2016-11-16 20:31:1996
Mark Simulacrum528646e2017-07-14 00:48:4497#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
98pub struct Linkcheck {
99 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43100}
101
Mark Simulacrum528646e2017-07-14 00:48:44102impl Step for Linkcheck {
Mark Simulacrum001e9f32017-07-05 01:41:43103 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27104 const ONLY_HOSTS: bool = true;
105 const DEFAULT: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43106
107 /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
108 ///
109 /// This tool in `src/tools` will verify the validity of all our links in the
110 /// documentation to ensure we don't have a bunch of dead ones.
111 fn run(self, builder: &Builder) {
112 let build = builder.build;
113 let host = self.host;
114
115 println!("Linkcheck ({})", host);
Mark Simulacrum6b3413d2017-07-05 12:41:27116
117 builder.default_doc(None);
Mark Simulacrum001e9f32017-07-05 01:41:43118
119 let _time = util::timeit();
Mark Simulacrum6b3413d2017-07-05 12:41:27120 try_run(build, builder.tool_cmd(Tool::Linkchecker)
Mark Simulacrum001e9f32017-07-05 01:41:43121 .arg(build.out.join(host).join("doc")));
122 }
Mark Simulacrum6b3413d2017-07-05 12:41:27123
Mark Simulacrum56128fb2017-07-19 00:03:38124 fn should_run(run: ShouldRun) -> ShouldRun {
125 run.path("src/tools/linkchecker")
Mark Simulacrum6b3413d2017-07-05 12:41:27126 }
127
Mark Simulacrum528646e2017-07-14 00:48:44128 fn make_run(
129 builder: &Builder,
130 path: Option<&Path>,
131 host: Interned<String>,
132 _target: Interned<String>,
133 ) {
Mark Simulacrum6b3413d2017-07-05 12:41:27134 if path.is_some() {
135 builder.ensure(Linkcheck { host });
136 } else {
137 if builder.build.config.docs {
138 builder.ensure(Linkcheck { host });
139 }
140 }
141 }
Alex Crichtondefd1b32016-03-08 07:15:55142}
Brian Anderson3a790ac2016-03-18 20:54:31143
Mark Simulacrum0a1b5e82017-07-04 23:53:53144// rules.test("check-cargotest", "src/tools/cargotest")
145// .dep(|s| s.name("tool-cargotest").stage(0))
146// .dep(|s| s.name("librustc"))
147// .host(true)
148// .run(move |s| check::cargotest(build, s.stage, s.target));
Brian Anderson80199222016-04-06 18:03:42149
Mark Simulacrum528646e2017-07-14 00:48:44150#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
151pub struct Cargotest {
Mark Simulacrum001e9f32017-07-05 01:41:43152 stage: u32,
Mark Simulacrum528646e2017-07-14 00:48:44153 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43154}
Alex Crichton73c2d2a2016-04-14 21:27:51155
Mark Simulacrum528646e2017-07-14 00:48:44156impl Step for Cargotest {
Mark Simulacrum001e9f32017-07-05 01:41:43157 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27158 const ONLY_HOSTS: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43159
Mark Simulacrum56128fb2017-07-19 00:03:38160 fn should_run(run: ShouldRun) -> ShouldRun {
161 run.path("src/tools/cargotest")
Mark Simulacrumceecd622017-07-12 16:12:47162 }
163
Mark Simulacrum528646e2017-07-14 00:48:44164 fn make_run(
165 builder: &Builder,
166 _path: Option<&Path>,
167 host: Interned<String>,
168 _target: Interned<String>,
169 ) {
Mark Simulacrumceecd622017-07-12 16:12:47170 builder.ensure(Cargotest {
171 stage: builder.top_stage,
172 host: host,
173 });
174 }
175
Mark Simulacrum001e9f32017-07-05 01:41:43176 /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
177 ///
178 /// This tool in `src/tools` will check out a few Rust projects and run `cargo
179 /// test` to ensure that we don't regress the test suites there.
180 fn run(self, builder: &Builder) {
181 let build = builder.build;
Mark Simulacrum60388302017-07-05 16:46:41182 let compiler = builder.compiler(self.stage, self.host);
Mark Simulacrum6b3413d2017-07-05 12:41:27183 builder.ensure(compile::Rustc { compiler, target: compiler.host });
Mark Simulacrum001e9f32017-07-05 01:41:43184
185 // Note that this is a short, cryptic, and not scoped directory name. This
186 // is currently to minimize the length of path on Windows where we otherwise
187 // quickly run into path name limit constraints.
188 let out_dir = build.out.join("ct");
189 t!(fs::create_dir_all(&out_dir));
190
191 let _time = util::timeit();
Mark Simulacrum6b3413d2017-07-05 12:41:27192 let mut cmd = builder.tool_cmd(Tool::CargoTest);
Mark Simulacrum001e9f32017-07-05 01:41:43193 try_run(build, cmd.arg(&build.initial_cargo)
194 .arg(&out_dir)
Mark Simulacrumc114fe52017-07-05 17:21:33195 .env("RUSTC", builder.rustc(compiler))
196 .env("RUSTDOC", builder.rustdoc(compiler)));
Mark Simulacrum001e9f32017-07-05 01:41:43197 }
Alex Crichton009f45f2017-04-18 00:24:05198}
199
Mark Simulacrum0a1b5e82017-07-04 23:53:53200//rules.test("check-cargo", "cargo")
201// .dep(|s| s.name("tool-cargo"))
202// .host(true)
203// .run(move |s| check::cargo(build, s.stage, s.target));
Alex Crichton009f45f2017-04-18 00:24:05204
Mark Simulacrum528646e2017-07-14 00:48:44205#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
206pub struct Cargo {
Mark Simulacrum001e9f32017-07-05 01:41:43207 stage: u32,
Mark Simulacrum528646e2017-07-14 00:48:44208 host: Interned<String>,
Nick Cameron04415dc2017-06-30 18:58:54209}
210
Mark Simulacrum528646e2017-07-14 00:48:44211impl Step for Cargo {
Mark Simulacrum001e9f32017-07-05 01:41:43212 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27213 const ONLY_HOSTS: bool = true;
214
Mark Simulacrum56128fb2017-07-19 00:03:38215 fn should_run(run: ShouldRun) -> ShouldRun {
216 run.path("src/tools/cargo")
Mark Simulacrum6b3413d2017-07-05 12:41:27217 }
218
Mark Simulacrum528646e2017-07-14 00:48:44219 fn make_run(
220 builder: &Builder,
221 _path: Option<&Path>,
222 _host: Interned<String>,
223 target: Interned<String>,
224 ) {
Mark Simulacrumdec44b02017-07-17 15:52:05225 builder.ensure(Cargo {
Mark Simulacrum60388302017-07-05 16:46:41226 stage: builder.top_stage,
227 host: target,
Mark Simulacrum6b3413d2017-07-05 12:41:27228 });
229 }
Nick Cameron04415dc2017-06-30 18:58:54230
Mark Simulacrum001e9f32017-07-05 01:41:43231 /// Runs `cargo test` for `cargo` packaged with Rust.
232 fn run(self, builder: &Builder) {
233 let build = builder.build;
Mark Simulacrum6b3413d2017-07-05 12:41:27234 let compiler = builder.compiler(self.stage, self.host);
Nick Cameron04415dc2017-06-30 18:58:54235
Mark Simulacrum4a21c722017-07-20 12:27:13236 builder.ensure(tool::Cargo { stage: self.stage, target: self.host });
Mark Simulacrumc114fe52017-07-05 17:21:33237 let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
Mark Simulacrum001e9f32017-07-05 01:41:43238 cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
239 if !build.fail_fast {
240 cargo.arg("--no-fail-fast");
241 }
Nick Cameron04415dc2017-06-30 18:58:54242
Mark Simulacrum001e9f32017-07-05 01:41:43243 // Don't build tests dynamically, just a pain to work with
244 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
245
246 // Don't run cross-compile tests, we may not have cross-compiled libstd libs
247 // available.
248 cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
249
Mark Simulacrumdec44b02017-07-17 15:52:05250 try_run(build, cargo.env("PATH", &path_for_cargo(builder, compiler)));
Mark Simulacrum001e9f32017-07-05 01:41:43251 }
252}
253
Mark Simulacrumdec44b02017-07-17 15:52:05254#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
255pub struct Rls {
Mark Simulacrum001e9f32017-07-05 01:41:43256 stage: u32,
Mark Simulacrumdec44b02017-07-17 15:52:05257 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43258}
259
Mark Simulacrumdec44b02017-07-17 15:52:05260// rules.test("check-rls", "src/tools/rls")
261// .dep(|s| s.name("tool-rls"))
262// .host(true)
263// .run(move |s| check::rls(build, s.stage, s.target));
264impl Step for Rls {
Mark Simulacrum001e9f32017-07-05 01:41:43265 type Output = ();
Mark Simulacrumdec44b02017-07-17 15:52:05266 const ONLY_HOSTS: bool = true;
267
Mark Simulacrum56128fb2017-07-19 00:03:38268 fn should_run(run: ShouldRun) -> ShouldRun {
269 run.path("src/tools/rls")
Mark Simulacrumdec44b02017-07-17 15:52:05270 }
271
272 fn make_run(
273 builder: &Builder,
274 _path: Option<&Path>,
275 _host: Interned<String>,
276 target: Interned<String>,
277 ) {
278 builder.ensure(Rls {
279 stage: builder.top_stage,
280 host: target,
281 });
282 }
Mark Simulacrum001e9f32017-07-05 01:41:43283
284 /// Runs `cargo test` for the rls.
285 fn run(self, builder: &Builder) {
286 let build = builder.build;
287 let stage = self.stage;
288 let host = self.host;
Mark Simulacrumdec44b02017-07-17 15:52:05289 let compiler = builder.compiler(stage, host);
Mark Simulacrum001e9f32017-07-05 01:41:43290
Mark Simulacrum4a21c722017-07-20 12:27:13291 builder.ensure(tool::Rls { stage: self.stage, target: self.host });
Mark Simulacrumdec44b02017-07-17 15:52:05292 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
Mark Simulacrum001e9f32017-07-05 01:41:43293 cargo.arg("--manifest-path").arg(build.src.join("src/tools/rls/Cargo.toml"));
294
295 // Don't build tests dynamically, just a pain to work with
296 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
297
Mark Simulacrumdec44b02017-07-17 15:52:05298 builder.add_rustc_lib_path(compiler, &mut cargo);
Mark Simulacrum001e9f32017-07-05 01:41:43299
300 try_run(build, &mut cargo);
301 }
Nick Cameron04415dc2017-06-30 18:58:54302}
303
Mark Simulacrumdec44b02017-07-17 15:52:05304fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
Nick Cameron04415dc2017-06-30 18:58:54305 // Configure PATH to find the right rustc. NB. we have to use PATH
306 // and not RUSTC because the Cargo test suite has tests that will
307 // fail if rustc is not spelled `rustc`.
Mark Simulacrumdec44b02017-07-17 15:52:05308 let path = builder.sysroot(compiler).join("bin");
Nick Cameron04415dc2017-06-30 18:58:54309 let old_path = env::var_os("PATH").unwrap_or_default();
310 env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
Brian Anderson3a790ac2016-03-18 20:54:31311}
Alex Crichton9dd3c542016-03-29 20:14:52312
Mark Simulacrum0a1b5e82017-07-04 23:53:53313//rules.test("check-tidy", "src/tools/tidy")
314// .dep(|s| s.name("tool-tidy").stage(0))
315// .default(true)
316// .host(true)
317// .only_build(true)
318// .run(move |s| check::tidy(build, s.target));
Mark Simulacrum001e9f32017-07-05 01:41:43319
Mark Simulacrum528646e2017-07-14 00:48:44320#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
321pub struct Tidy {
322 host: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:43323}
324
Mark Simulacrum528646e2017-07-14 00:48:44325impl Step for Tidy {
Mark Simulacrum001e9f32017-07-05 01:41:43326 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27327 const DEFAULT: bool = true;
328 const ONLY_HOSTS: bool = true;
329 const ONLY_BUILD: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:43330
331 /// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
332 ///
333 /// This tool in `src/tools` checks up on various bits and pieces of style and
334 /// otherwise just implements a few lint-like checks that are specific to the
335 /// compiler itself.
336 fn run(self, builder: &Builder) {
337 let build = builder.build;
338 let host = self.host;
339
340 let _folder = build.fold_output(|| "tidy");
341 println!("tidy check ({})", host);
Mark Simulacrum60388302017-07-05 16:46:41342 let mut cmd = builder.tool_cmd(Tool::Tidy);
Mark Simulacrum001e9f32017-07-05 01:41:43343 cmd.arg(build.src.join("src"));
344 if !build.config.vendor {
345 cmd.arg("--no-vendor");
346 }
347 if build.config.quiet_tests {
348 cmd.arg("--quiet");
349 }
350 try_run(build, &mut cmd);
Eduard-Mihai Burtescud29f0bc2017-02-10 20:59:40351 }
Mark Simulacrum6b3413d2017-07-05 12:41:27352
Mark Simulacrum56128fb2017-07-19 00:03:38353 fn should_run(run: ShouldRun) -> ShouldRun {
354 run.path("src/tools/tidy")
Mark Simulacrum6b3413d2017-07-05 12:41:27355 }
356
Mark Simulacrum528646e2017-07-14 00:48:44357 fn make_run(
358 builder: &Builder,
359 _path: Option<&Path>,
360 _host: Interned<String>,
361 _target: Interned<String>,
362 ) {
Mark Simulacrum6b3413d2017-07-05 12:41:27363 builder.ensure(Tidy {
Mark Simulacrum528646e2017-07-14 00:48:44364 host: builder.build.build,
Mark Simulacrum6b3413d2017-07-05 12:41:27365 });
366 }
Alex Crichton9dd3c542016-03-29 20:14:52367}
Alex Crichtonb325baf2016-04-05 18:34:23368
Mark Simulacrum528646e2017-07-14 00:48:44369fn testdir(build: &Build, host: Interned<String>) -> PathBuf {
Alex Crichtonb325baf2016-04-05 18:34:23370 build.out.join(host).join("test")
371}
372
Mark Simulacrum0a1b5e82017-07-04 23:53:53373// // ========================================================================
374// // Test targets
375// //
376// // Various unit tests and tests suites we can run
377// {
378// let mut suite = |name, path, mode, dir| {
379// rules.test(name, path)
380// .dep(|s| s.name("libtest"))
381// .dep(|s| s.name("tool-compiletest").target(s.host).stage(0))
382// .dep(|s| s.name("test-helpers"))
383// .dep(|s| s.name("remote-copy-libs"))
384// .default(mode != "pretty") // pretty tests don't run everywhere
385// .run(move |s| {
386// check::compiletest(build, &s.compiler(), s.target, mode, dir)
387// });
388// };
389//
390// suite("check-ui", "src/test/ui", "ui", "ui");
391// suite("check-rpass", "src/test/run-pass", "run-pass", "run-pass");
392// suite("check-cfail", "src/test/compile-fail", "compile-fail", "compile-fail");
393// suite("check-pfail", "src/test/parse-fail", "parse-fail", "parse-fail");
394// suite("check-rfail", "src/test/run-fail", "run-fail", "run-fail");
395// suite("check-rpass-valgrind", "src/test/run-pass-valgrind",
396// "run-pass-valgrind", "run-pass-valgrind");
397// suite("check-mir-opt", "src/test/mir-opt", "mir-opt", "mir-opt");
398// if build.config.codegen_tests {
399// suite("check-codegen", "src/test/codegen", "codegen", "codegen");
400// }
401// suite("check-codegen-units", "src/test/codegen-units", "codegen-units",
402// "codegen-units");
403// suite("check-incremental", "src/test/incremental", "incremental",
404// "incremental");
405// }
406//
407// if build.build.contains("msvc") {
408// // nothing to do for debuginfo tests
409// } else {
410// rules.test("check-debuginfo-lldb", "src/test/debuginfo-lldb")
411// .dep(|s| s.name("libtest"))
412// .dep(|s| s.name("tool-compiletest").target(s.host).stage(0))
413// .dep(|s| s.name("test-helpers"))
414// .dep(|s| s.name("debugger-scripts"))
415// .run(move |s| check::compiletest(build, &s.compiler(), s.target,
416// "debuginfo-lldb", "debuginfo"));
417// rules.test("check-debuginfo-gdb", "src/test/debuginfo-gdb")
418// .dep(|s| s.name("libtest"))
419// .dep(|s| s.name("tool-compiletest").target(s.host).stage(0))
420// .dep(|s| s.name("test-helpers"))
421// .dep(|s| s.name("debugger-scripts"))
422// .dep(|s| s.name("remote-copy-libs"))
423// .run(move |s| check::compiletest(build, &s.compiler(), s.target,
424// "debuginfo-gdb", "debuginfo"));
425// let mut rule = rules.test("check-debuginfo", "src/test/debuginfo");
426// rule.default(true);
427// if build.build.contains("apple") {
428// rule.dep(|s| s.name("check-debuginfo-lldb"));
429// } else {
430// rule.dep(|s| s.name("check-debuginfo-gdb"));
431// }
432// }
433//
434//
435//
436// {
437// let mut suite = |name, path, mode, dir| {
438// rules.test(name, path)
439// .dep(|s| s.name("librustc"))
440// .dep(|s| s.name("test-helpers"))
441// .dep(|s| s.name("tool-compiletest").target(s.host).stage(0))
442// .default(mode != "pretty")
443// .host(true)
444// .run(move |s| {
445// check::compiletest(build, &s.compiler(), s.target, mode, dir)
446// });
447// };
448//
449// suite("check-ui-full", "src/test/ui-fulldeps", "ui", "ui-fulldeps");
450// suite("check-rpass-full", "src/test/run-pass-fulldeps",
451// "run-pass", "run-pass-fulldeps");
452// suite("check-rfail-full", "src/test/run-fail-fulldeps",
453// "run-fail", "run-fail-fulldeps");
454// suite("check-cfail-full", "src/test/compile-fail-fulldeps",
455// "compile-fail", "compile-fail-fulldeps");
456// suite("check-rmake", "src/test/run-make", "run-make", "run-make");
457// suite("check-rustdoc", "src/test/rustdoc", "rustdoc", "rustdoc");
458// suite("check-pretty", "src/test/pretty", "pretty", "pretty");
459// suite("check-pretty-rpass", "src/test/run-pass/pretty", "pretty",
460// "run-pass");
461// suite("check-pretty-rfail", "src/test/run-fail/pretty", "pretty",
462// "run-fail");
463// suite("check-pretty-valgrind", "src/test/run-pass-valgrind/pretty", "pretty",
464// "run-pass-valgrind");
465// suite("check-pretty-rpass-full", "src/test/run-pass-fulldeps/pretty",
466// "pretty", "run-pass-fulldeps");
467// suite("check-pretty-rfail-full", "src/test/run-fail-fulldeps/pretty",
468// "pretty", "run-fail-fulldeps");
469// }
470
Mark Simulacrum528646e2017-07-14 00:48:44471#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum1ab89302017-07-07 17:51:57472struct Test {
Mark Simulacrum1ab89302017-07-07 17:51:57473 path: &'static str,
474 mode: &'static str,
475 suite: &'static str,
476}
477
Mark Simulacrumaa8b93b2017-07-07 18:31:29478static DEFAULT_COMPILETESTS: &[Test] = &[
479 Test { path: "src/test/ui", mode: "ui", suite: "ui" },
480 Test { path: "src/test/run-pass", mode: "run-pass", suite: "run-pass" },
481 Test { path: "src/test/compile-fail", mode: "compile-fail", suite: "compile-fail" },
482 Test { path: "src/test/parse-fail", mode: "parse-fail", suite: "parse-fail" },
483 Test { path: "src/test/run-fail", mode: "run-fail", suite: "run-fail" },
Mark Simulacrum1ab89302017-07-07 17:51:57484 Test {
Mark Simulacrum1ab89302017-07-07 17:51:57485 path: "src/test/run-pass-valgrind",
486 mode: "run-pass-valgrind",
487 suite: "run-pass-valgrind"
488 },
Mark Simulacrumaa8b93b2017-07-07 18:31:29489 Test { path: "src/test/mir-opt", mode: "mir-opt", suite: "mir-opt" },
490 Test { path: "src/test/codegen", mode: "codegen", suite: "codegen" },
491 Test { path: "src/test/codegen-units", mode: "codegen-units", suite: "codegen-units" },
492 Test { path: "src/test/incremental", mode: "incremental", suite: "incremental" },
Mark Simulacrum6b3413d2017-07-05 12:41:27493
Mark Simulacrumaa8b93b2017-07-07 18:31:29494 // What this runs varies depending on the native platform being apple
495 Test { path: "src/test/debuginfo", mode: "debuginfo-XXX", suite: "debuginfo" },
Mark Simulacrumf1d04a32017-07-20 15:42:18496 Test { path: "src/test/debuginfo-lldb", mode: "debuginfo-lldb", suite: "debuginfo" },
497 Test { path: "src/test/debuginfo-gdb", mode: "debuginfo-gdb", suite: "debuginfo" },
Mark Simulacrumaa8b93b2017-07-07 18:31:29498];
Mark Simulacrum6b3413d2017-07-05 12:41:27499
Mark Simulacrumf1d04a32017-07-20 15:42:18500#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
501pub struct DefaultCompiletest {
502 compiler: Compiler,
503 target: Interned<String>,
504 mode: &'static str,
505 suite: &'static str,
506}
507
508impl Step for DefaultCompiletest {
509 type Output = ();
510 const DEFAULT: bool = true;
511
512 fn should_run(mut run: ShouldRun) -> ShouldRun {
513 for test in DEFAULT_COMPILETESTS {
514 run = run.path(test.path);
515 }
516 run
517 }
518
519 fn make_run(
520 builder: &Builder,
521 path: Option<&Path>,
522 host: Interned<String>,
523 target: Interned<String>,
524 ) {
525 let compiler = builder.compiler(builder.top_stage, host);
526
527 let test = path.map(|path| {
528 DEFAULT_COMPILETESTS.iter().find(|&&test| {
529 path.ends_with(test.path)
530 }).unwrap_or_else(|| {
531 panic!("make_run in compile test to receive test path, received {:?}", path);
532 })
533 });
534
535 if let Some(test) = test {
536 builder.ensure(DefaultCompiletest {
537 compiler,
538 target,
539 mode: test.mode,
540 suite: test.suite,
541 });
542 } else {
543 for test in DEFAULT_COMPILETESTS {
544 builder.ensure(DefaultCompiletest {
545 compiler,
546 target,
547 mode: test.mode,
548 suite: test.suite
549 });
550 }
551 }
552 }
553
554 fn run(self, builder: &Builder) {
555 builder.ensure(Compiletest {
556 compiler: self.compiler,
557 target: self.target,
558 mode: self.mode,
559 suite: self.suite,
560 })
561 }
562}
563
Mark Simulacrumaa8b93b2017-07-07 18:31:29564// Also default, but host-only.
565static HOST_COMPILETESTS: &[Test] = &[
566 Test { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" },
567 Test { path: "src/test/run-pass-fulldeps", mode: "run-pass", suite: "run-pass-fulldeps" },
568 Test { path: "src/test/run-fail-fulldeps", mode: "run-fail", suite: "run-fail-fulldeps" },
Mark Simulacrum1ab89302017-07-07 17:51:57569 Test {
Mark Simulacrum1ab89302017-07-07 17:51:57570 path: "src/test/compile-fail-fulldeps",
571 mode: "compile-fail",
572 suite: "compile-fail-fulldeps",
573 },
Mark Simulacrumaa8b93b2017-07-07 18:31:29574 Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" },
575 Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" },
Mark Simulacrum6b3413d2017-07-05 12:41:27576
Mark Simulacrumaa8b93b2017-07-07 18:31:29577 Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" },
578 Test { path: "src/test/run-pass/pretty", mode: "pretty", suite: "run-pass" },
579 Test { path: "src/test/run-fail/pretty", mode: "pretty", suite: "run-fail" },
580 Test { path: "src/test/run-pass-valgrind/pretty", mode: "pretty", suite: "run-pass-valgrind" },
581 Test { path: "src/test/run-pass-fulldeps/pretty", mode: "pretty", suite: "run-pass-fulldeps" },
582 Test { path: "src/test/run-fail-fulldeps/pretty", mode: "pretty", suite: "run-fail-fulldeps" },
Mark Simulacrum6b3413d2017-07-05 12:41:27583];
584
Mark Simulacrumf1d04a32017-07-20 15:42:18585#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
586pub struct HostCompiletest {
587 compiler: Compiler,
588 target: Interned<String>,
589 mode: &'static str,
590 suite: &'static str,
591}
Mark Simulacrum6b3413d2017-07-05 12:41:27592
Mark Simulacrumf1d04a32017-07-20 15:42:18593impl Step for HostCompiletest {
Mark Simulacrum001e9f32017-07-05 01:41:43594 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27595 const DEFAULT: bool = true;
Mark Simulacrumf1d04a32017-07-20 15:42:18596 const ONLY_HOSTS: bool = true;
Mark Simulacrum6b3413d2017-07-05 12:41:27597
Mark Simulacrum56128fb2017-07-19 00:03:38598 fn should_run(mut run: ShouldRun) -> ShouldRun {
Mark Simulacrumf1d04a32017-07-20 15:42:18599 for test in HOST_COMPILETESTS {
Mark Simulacrum56128fb2017-07-19 00:03:38600 run = run.path(test.path);
601 }
602 run
Mark Simulacrum6b3413d2017-07-05 12:41:27603 }
604
Mark Simulacrum528646e2017-07-14 00:48:44605 fn make_run(
606 builder: &Builder,
607 path: Option<&Path>,
608 host: Interned<String>,
609 target: Interned<String>,
610 ) {
Mark Simulacrum6b3413d2017-07-05 12:41:27611 let compiler = builder.compiler(builder.top_stage, host);
612
613 let test = path.map(|path| {
Mark Simulacrumf1d04a32017-07-20 15:42:18614 HOST_COMPILETESTS.iter().find(|&&test| {
Mark Simulacrum1ab89302017-07-07 17:51:57615 path.ends_with(test.path)
Mark Simulacrum6b3413d2017-07-05 12:41:27616 }).unwrap_or_else(|| {
617 panic!("make_run in compile test to receive test path, received {:?}", path);
618 })
619 });
620
Mark Simulacrumf1d04a32017-07-20 15:42:18621 if let Some(test) = test {
622 builder.ensure(HostCompiletest {
623 compiler,
624 target,
625 mode: test.mode,
626 suite: test.suite,
Mark Simulacrum6b3413d2017-07-05 12:41:27627 });
Mark Simulacrumf1d04a32017-07-20 15:42:18628 } else {
629 for test in HOST_COMPILETESTS {
630 builder.ensure(HostCompiletest {
Mark Simulacrumaa8b93b2017-07-07 18:31:29631 compiler,
632 target,
633 mode: test.mode,
634 suite: test.suite
635 });
636 }
Mark Simulacrum6b3413d2017-07-05 12:41:27637 }
638 }
Alex Crichtonf72bfe62016-05-02 22:16:15639
Mark Simulacrumf1d04a32017-07-20 15:42:18640 fn run(self, builder: &Builder) {
641 builder.ensure(Compiletest {
642 compiler: self.compiler,
643 target: self.target,
644 mode: self.mode,
645 suite: self.suite,
646 })
647 }
648}
649
650#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
651struct Compiletest {
652 compiler: Compiler,
653 target: Interned<String>,
654 mode: &'static str,
655 suite: &'static str,
656}
657
658impl Step for Compiletest {
659 type Output = ();
660
661 fn should_run(run: ShouldRun) -> ShouldRun {
662 run.never()
663 }
664
Mark Simulacrum001e9f32017-07-05 01:41:43665 /// Executes the `compiletest` tool to run a suite of tests.
666 ///
667 /// Compiles all tests with `compiler` for `target` with the specified
668 /// compiletest `mode` and `suite` arguments. For example `mode` can be
669 /// "run-pass" or `suite` can be something like `debuginfo`.
670 fn run(self, builder: &Builder) {
671 let build = builder.build;
672 let compiler = self.compiler;
673 let target = self.target;
674 let mode = self.mode;
675 let suite = self.suite;
Mark Simulacrum6b3413d2017-07-05 12:41:27676
677 // Skip codegen tests if they aren't enabled in configuration.
678 if !build.config.codegen_tests && suite == "codegen" {
679 return;
680 }
681
682 if suite == "debuginfo" {
683 if mode == "debuginfo-XXX" {
684 return if build.build.contains("apple") {
685 builder.ensure(Compiletest {
686 mode: "debuginfo-lldb",
687 ..self
Mark Simulacrum528646e2017-07-14 00:48:44688 });
Mark Simulacrum6b3413d2017-07-05 12:41:27689 } else {
690 builder.ensure(Compiletest {
691 mode: "debuginfo-gdb",
692 ..self
Mark Simulacrum528646e2017-07-14 00:48:44693 });
Mark Simulacrum6b3413d2017-07-05 12:41:27694 };
695 }
696
697 // Skip debuginfo tests on MSVC
698 if build.build.contains("msvc") {
699 return;
700 }
701
702 builder.ensure(dist::DebuggerScripts {
Mark Simulacrum528646e2017-07-14 00:48:44703 sysroot: builder.sysroot(compiler),
Mark Simulacrum5984e702017-07-13 00:52:31704 target: target
Mark Simulacrum6b3413d2017-07-05 12:41:27705 });
706 }
707
708 if suite.ends_with("fulldeps") ||
709 // FIXME: Does pretty need librustc compiled? Note that there are
710 // fulldeps test suites with mode = pretty as well.
711 mode == "pretty" ||
712 mode == "rustdoc" ||
713 mode == "run-make" {
714 builder.ensure(compile::Rustc { compiler, target });
715 }
716
717 builder.ensure(compile::Test { compiler, target });
718 builder.ensure(native::TestHelpers { target });
Mark Simulacrumaa8b93b2017-07-07 18:31:29719 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum6b3413d2017-07-05 12:41:27720
Mark Simulacrum001e9f32017-07-05 01:41:43721 let _folder = build.fold_output(|| format!("test_{}", suite));
722 println!("Check compiletest suite={} mode={} ({} -> {})",
Mark Simulacrum528646e2017-07-14 00:48:44723 suite, mode, &compiler.host, target);
Mark Simulacrum6b3413d2017-07-05 12:41:27724 let mut cmd = builder.tool_cmd(Tool::Compiletest);
Alex Crichtonb325baf2016-04-05 18:34:23725
Mark Simulacrum001e9f32017-07-05 01:41:43726 // compiletest currently has... a lot of arguments, so let's just pass all
727 // of them!
Brian Anderson8401e372016-09-15 19:42:26728
Mark Simulacrumc114fe52017-07-05 17:21:33729 cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
Mark Simulacrum60388302017-07-05 16:46:41730 cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
Mark Simulacrumc114fe52017-07-05 17:21:33731 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
732 cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
Mark Simulacrum001e9f32017-07-05 01:41:43733 cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
734 cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
735 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
736 cmd.arg("--mode").arg(mode);
737 cmd.arg("--target").arg(target);
Mark Simulacrum528646e2017-07-14 00:48:44738 cmd.arg("--host").arg(&*compiler.host);
739 cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(build.build));
Alex Crichtonf4e4ec72016-05-13 22:26:41740
Mark Simulacrum001e9f32017-07-05 01:41:43741 if let Some(ref nodejs) = build.config.nodejs {
742 cmd.arg("--nodejs").arg(nodejs);
743 }
Alex Crichtonf4e4ec72016-05-13 22:26:41744
Mark Simulacrum001e9f32017-07-05 01:41:43745 let mut flags = vec!["-Crpath".to_string()];
746 if build.config.rust_optimize_tests {
747 flags.push("-O".to_string());
748 }
749 if build.config.rust_debuginfo_tests {
750 flags.push("-g".to_string());
751 }
Alex Crichtoncbe62922016-04-19 16:44:19752
Mark Simulacrum60388302017-07-05 16:46:41753 let mut hostflags = build.rustc_flags(compiler.host);
Mark Simulacrum001e9f32017-07-05 01:41:43754 hostflags.extend(flags.clone());
755 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
Alex Crichtoncbe62922016-04-19 16:44:19756
Mark Simulacrum528646e2017-07-14 00:48:44757 let mut targetflags = build.rustc_flags(target);
Mark Simulacrum001e9f32017-07-05 01:41:43758 targetflags.extend(flags);
759 targetflags.push(format!("-Lnative={}",
760 build.test_helpers_out(target).display()));
761 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
Alex Crichtonb325baf2016-04-05 18:34:23762
Mark Simulacrum001e9f32017-07-05 01:41:43763 cmd.arg("--docck-python").arg(build.python());
Alex Crichtonb325baf2016-04-05 18:34:23764
Mark Simulacrum001e9f32017-07-05 01:41:43765 if build.build.ends_with("apple-darwin") {
766 // Force /usr/bin/python on macOS for LLDB tests because we're loading the
767 // LLDB plugin's compiled module which only works with the system python
768 // (namely not Homebrew-installed python)
769 cmd.arg("--lldb-python").arg("/usr/bin/python");
770 } else {
771 cmd.arg("--lldb-python").arg(build.python());
772 }
Alex Crichtonb325baf2016-04-05 18:34:23773
Mark Simulacrum001e9f32017-07-05 01:41:43774 if let Some(ref gdb) = build.config.gdb {
775 cmd.arg("--gdb").arg(gdb);
776 }
777 if let Some(ref vers) = build.lldb_version {
778 cmd.arg("--lldb-version").arg(vers);
779 }
780 if let Some(ref dir) = build.lldb_python_dir {
781 cmd.arg("--lldb-python-dir").arg(dir);
782 }
783 let llvm_config = build.llvm_config(target);
784 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
785 cmd.arg("--llvm-version").arg(llvm_version);
786 if !build.is_rust_llvm(target) {
787 cmd.arg("--system-llvm");
788 }
Alex Crichtonb325baf2016-04-05 18:34:23789
Mark Simulacrum001e9f32017-07-05 01:41:43790 cmd.args(&build.flags.cmd.test_args());
Corey Farwellc8c6d2c2016-10-30 01:58:52791
Mark Simulacrum001e9f32017-07-05 01:41:43792 if build.is_verbose() {
793 cmd.arg("--verbose");
794 }
Alex Crichton126e09e2016-04-14 22:51:03795
Mark Simulacrum001e9f32017-07-05 01:41:43796 if build.config.quiet_tests {
797 cmd.arg("--quiet");
798 }
Alex Crichton1747ce22017-01-28 21:38:06799
Mark Simulacrum001e9f32017-07-05 01:41:43800 // Only pass correct values for these flags for the `run-make` suite as it
801 // requires that a C++ compiler was configured which isn't always the case.
802 if suite == "run-make" {
803 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
804 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
805 cmd.arg("--cc").arg(build.cc(target))
806 .arg("--cxx").arg(build.cxx(target).unwrap())
807 .arg("--cflags").arg(build.cflags(target).join(" "))
808 .arg("--llvm-components").arg(llvm_components.trim())
809 .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
810 } else {
811 cmd.arg("--cc").arg("")
812 .arg("--cxx").arg("")
813 .arg("--cflags").arg("")
814 .arg("--llvm-components").arg("")
815 .arg("--llvm-cxxflags").arg("");
816 }
817
818 if build.remote_tested(target) {
Mark Simulacrum6b3413d2017-07-05 12:41:27819 cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
Mark Simulacrum001e9f32017-07-05 01:41:43820 }
821
822 // Running a C compiler on MSVC requires a few env vars to be set, to be
823 // sure to set them here.
824 //
825 // Note that if we encounter `PATH` we make sure to append to our own `PATH`
826 // rather than stomp over it.
827 if target.contains("msvc") {
Mark Simulacrum528646e2017-07-14 00:48:44828 for &(ref k, ref v) in build.cc[&target].0.env() {
Mark Simulacrum001e9f32017-07-05 01:41:43829 if k != "PATH" {
830 cmd.env(k, v);
831 }
Alex Crichton126e09e2016-04-14 22:51:03832 }
833 }
Mark Simulacrum001e9f32017-07-05 01:41:43834 cmd.env("RUSTC_BOOTSTRAP", "1");
835 build.add_rust_test_threads(&mut cmd);
836
837 if build.config.sanitizers {
838 cmd.env("SANITIZER_SUPPORT", "1");
839 }
840
841 if build.config.profiler {
842 cmd.env("PROFILER_SUPPORT", "1");
843 }
844
845 cmd.arg("--adb-path").arg("adb");
846 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
847 if target.contains("android") {
848 // Assume that cc for this target comes from the android sysroot
849 cmd.arg("--android-cross-path")
850 .arg(build.cc(target).parent().unwrap().parent().unwrap());
851 } else {
852 cmd.arg("--android-cross-path").arg("");
853 }
854
855 build.ci_env.force_coloring_in_ci(&mut cmd);
856
857 let _time = util::timeit();
858 try_run(build, &mut cmd);
Alex Crichton126e09e2016-04-14 22:51:03859 }
Alex Crichtonb325baf2016-04-05 18:34:23860}
Alex Crichtonede89442016-04-15 01:00:35861
Mark Simulacrum528646e2017-07-14 00:48:44862#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
863pub struct Docs {
864 compiler: Compiler,
Mark Simulacruma5ab2ce2017-07-12 15:15:00865}
866
Mark Simulacrum0a1b5e82017-07-04 23:53:53867// rules.test("check-docs", "src/doc")
868// .dep(|s| s.name("libtest"))
869// .default(true)
870// .host(true)
871// .run(move |s| check::docs(build, &s.compiler()));
Mark Simulacrum528646e2017-07-14 00:48:44872impl Step for Docs {
Mark Simulacruma5ab2ce2017-07-12 15:15:00873 type Output = ();
874 const DEFAULT: bool = true;
875 const ONLY_HOSTS: bool = true;
Alex Crichtonede89442016-04-15 01:00:35876
Mark Simulacrum56128fb2017-07-19 00:03:38877 fn should_run(run: ShouldRun) -> ShouldRun {
878 run.path("src/doc")
Mark Simulacruma5ab2ce2017-07-12 15:15:00879 }
880
Mark Simulacrum528646e2017-07-14 00:48:44881 fn make_run(
882 builder: &Builder,
883 _path: Option<&Path>,
884 host: Interned<String>,
885 _target: Interned<String>,
886 ) {
Mark Simulacruma5ab2ce2017-07-12 15:15:00887 builder.ensure(Docs {
888 compiler: builder.compiler(builder.top_stage, host),
889 });
890 }
891
892 /// Run `rustdoc --test` for all documentation in `src/doc`.
893 ///
894 /// This will run all tests in our markdown documentation (e.g. the book)
895 /// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
896 /// `compiler`.
897 fn run(self, builder: &Builder) {
898 let build = builder.build;
899 let compiler = self.compiler;
Mark Simulacrumceecd622017-07-12 16:12:47900
901 builder.ensure(compile::Test { compiler, target: compiler.host });
902
Mark Simulacruma5ab2ce2017-07-12 15:15:00903 // Do a breadth-first traversal of the `src/doc` directory and just run
904 // tests for all files that end in `*.md`
905 let mut stack = vec![build.src.join("src/doc")];
906 let _time = util::timeit();
907 let _folder = build.fold_output(|| "test_docs");
908
909 while let Some(p) = stack.pop() {
910 if p.is_dir() {
911 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
912 continue
913 }
914
915 if p.extension().and_then(|s| s.to_str()) != Some("md") {
916 continue;
917 }
918
919 // The nostarch directory in the book is for no starch, and so isn't
920 // guaranteed to build. We don't care if it doesn't build, so skip it.
921 if p.to_str().map_or(false, |p| p.contains("nostarch")) {
922 continue;
923 }
924
925 markdown_test(builder, compiler, &p);
Alex Crichtonede89442016-04-15 01:00:35926 }
Alex Crichtonede89442016-04-15 01:00:35927 }
928}
929
Mark Simulacrum0a1b5e82017-07-04 23:53:53930//rules.test("check-error-index", "src/tools/error_index_generator")
931// .dep(|s| s.name("libstd"))
932// .dep(|s| s.name("tool-error-index").host(s.host).stage(0))
933// .default(true)
934// .host(true)
935// .run(move |s| check::error_index(build, &s.compiler()));
Alex Crichtonede89442016-04-15 01:00:35936
Mark Simulacrum528646e2017-07-14 00:48:44937#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
938pub struct ErrorIndex {
939 compiler: Compiler,
Mark Simulacrum001e9f32017-07-05 01:41:43940}
Alex Crichton0e272de2016-11-16 20:31:19941
Mark Simulacrum528646e2017-07-14 00:48:44942impl Step for ErrorIndex {
Mark Simulacrum001e9f32017-07-05 01:41:43943 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:27944 const DEFAULT: bool = true;
945 const ONLY_HOSTS: bool = true;
946
Mark Simulacrum56128fb2017-07-19 00:03:38947 fn should_run(run: ShouldRun) -> ShouldRun {
948 run.path("src/tools/error_index_generator")
Mark Simulacrum6b3413d2017-07-05 12:41:27949 }
950
Mark Simulacrum528646e2017-07-14 00:48:44951 fn make_run(
952 builder: &Builder,
953 _path: Option<&Path>,
954 host: Interned<String>,
955 _target: Interned<String>,
956 ) {
Mark Simulacrum6b3413d2017-07-05 12:41:27957 builder.ensure(ErrorIndex {
958 compiler: builder.compiler(builder.top_stage, host),
959 });
960 }
Alex Crichtonede89442016-04-15 01:00:35961
Mark Simulacrum001e9f32017-07-05 01:41:43962 /// Run the error index generator tool to execute the tests located in the error
963 /// index.
964 ///
965 /// The `error_index_generator` tool lives in `src/tools` and is used to
966 /// generate a markdown file from the error indexes of the code base which is
967 /// then passed to `rustdoc --test`.
968 fn run(self, builder: &Builder) {
969 let build = builder.build;
970 let compiler = self.compiler;
971
Mark Simulacrum6b3413d2017-07-05 12:41:27972 builder.ensure(compile::Std { compiler, target: compiler.host });
973
Mark Simulacrum001e9f32017-07-05 01:41:43974 let _folder = build.fold_output(|| "test_error_index");
975 println!("Testing error-index stage{}", compiler.stage);
976
977 let dir = testdir(build, compiler.host);
978 t!(fs::create_dir_all(&dir));
979 let output = dir.join("error-index.md");
980
981 let _time = util::timeit();
Mark Simulacrum60388302017-07-05 16:46:41982 build.run(builder.tool_cmd(Tool::ErrorIndex)
Mark Simulacrum001e9f32017-07-05 01:41:43983 .arg("markdown")
984 .arg(&output)
985 .env("CFG_BUILD", &build.build));
986
Mark Simulacrumc114fe52017-07-05 17:21:33987 markdown_test(builder, compiler, &output);
Mark Simulacrum001e9f32017-07-05 01:41:43988 }
Alex Crichtonede89442016-04-15 01:00:35989}
990
Mark Simulacrumc114fe52017-07-05 17:21:33991fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
992 let build = builder.build;
Mark Simulacrumdd1d75e2017-06-04 23:55:50993 let mut file = t!(File::open(markdown));
994 let mut contents = String::new();
995 t!(file.read_to_string(&mut contents));
996 if !contents.contains("```") {
997 return;
998 }
999
Mark Simulacrumbc8fabb2017-06-06 18:00:221000 println!("doc tests for: {}", markdown.display());
Mark Simulacrumc114fe52017-07-05 17:21:331001 let mut cmd = Command::new(builder.rustdoc(compiler));
1002 builder.add_rustc_lib_path(compiler, &mut cmd);
Alex Crichton0e272de2016-11-16 20:31:191003 build.add_rust_test_threads(&mut cmd);
Alex Crichtonede89442016-04-15 01:00:351004 cmd.arg("--test");
1005 cmd.arg(markdown);
Alex Crichton6f62fae2016-12-12 17:03:351006 cmd.env("RUSTC_BOOTSTRAP", "1");
Corey Farwellc8c6d2c2016-10-30 01:58:521007
kennytm6ac07872017-05-21 20:27:471008 let test_args = build.flags.cmd.test_args().join(" ");
Corey Farwellc8c6d2c2016-10-30 01:58:521009 cmd.arg("--test-args").arg(test_args);
1010
kennytm6ac07872017-05-21 20:27:471011 if build.config.quiet_tests {
Josh Stone617aea42017-06-02 16:27:441012 try_run_quiet(build, &mut cmd);
kennytm6ac07872017-05-21 20:27:471013 } else {
Josh Stone617aea42017-06-02 16:27:441014 try_run(build, &mut cmd);
kennytm6ac07872017-05-21 20:27:471015 }
Alex Crichtonede89442016-04-15 01:00:351016}
Alex Crichtonbb9062a2016-04-29 21:23:151017
Mark Simulacrum6b3413d2017-07-05 12:41:271018// for (krate, path, _default) in krates("rustc-main") {
1019// rules.test(&krate.test_step, path)
1020// .dep(|s| s.name("librustc"))
1021// .dep(|s| s.name("remote-copy-libs"))
1022// .host(true)
1023// .run(move |s| check::krate(build, &s.compiler(), s.target,
1024// Mode::Librustc, TestKind::Test,
1025// Some(&krate.name)));
1026// }
1027// rules.test("check-rustc-all", "path/to/nowhere")
1028// .dep(|s| s.name("librustc"))
1029// .dep(|s| s.name("remote-copy-libs"))
1030// .default(true)
1031// .host(true)
1032// .run(move |s| check::krate(build, &s.compiler(), s.target,
1033// Mode::Librustc, TestKind::Test, None));
Mark Simulacrum528646e2017-07-14 00:48:441034#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum981afa52017-07-18 21:28:531035pub struct CrateLibrustc {
Mark Simulacrum528646e2017-07-14 00:48:441036 compiler: Compiler,
1037 target: Interned<String>,
Mark Simulacrum6b3413d2017-07-05 12:41:271038 test_kind: TestKind,
Mark Simulacrum528646e2017-07-14 00:48:441039 krate: Option<Interned<String>>,
Mark Simulacrum6b3413d2017-07-05 12:41:271040}
1041
Mark Simulacrum981afa52017-07-18 21:28:531042impl Step for CrateLibrustc {
Mark Simulacrum6b3413d2017-07-05 12:41:271043 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271044 const DEFAULT: bool = true;
1045 const ONLY_HOSTS: bool = true;
1046
Mark Simulacrum56128fb2017-07-19 00:03:381047 fn should_run(run: ShouldRun) -> ShouldRun {
1048 run.krate("rustc-main")
Mark Simulacrum6b3413d2017-07-05 12:41:271049 }
1050
Mark Simulacrum528646e2017-07-14 00:48:441051 fn make_run(
1052 builder: &Builder,
1053 path: Option<&Path>,
1054 host: Interned<String>,
1055 target: Interned<String>,
1056 ) {
Mark Simulacrum6b3413d2017-07-05 12:41:271057 let compiler = builder.compiler(builder.top_stage, host);
1058
Mark Simulacrum528646e2017-07-14 00:48:441059 let run = |name: Option<Interned<String>>| {
Mark Simulacrum6b3413d2017-07-05 12:41:271060 let test_kind = if builder.kind == Kind::Test {
1061 TestKind::Test
1062 } else if builder.kind == Kind::Bench {
1063 TestKind::Bench
1064 } else {
Mark Simulacrum981afa52017-07-18 21:28:531065 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
Mark Simulacrum6b3413d2017-07-05 12:41:271066 };
1067
Mark Simulacrum981afa52017-07-18 21:28:531068 builder.ensure(CrateLibrustc {
Mark Simulacrum6b3413d2017-07-05 12:41:271069 compiler,
1070 target,
1071 test_kind: test_kind,
1072 krate: name,
1073 });
1074 };
1075
1076 if let Some(path) = path {
1077 for (name, krate_path) in builder.crates("rustc-main") {
1078 if path.ends_with(krate_path) {
1079 run(Some(name));
1080 }
1081 }
1082 } else {
1083 run(None);
1084 }
1085 }
1086
1087
1088 fn run(self, builder: &Builder) {
Mark Simulacrum981afa52017-07-18 21:28:531089 builder.ensure(Crate {
Mark Simulacrum6b3413d2017-07-05 12:41:271090 compiler: self.compiler,
1091 target: self.target,
1092 mode: Mode::Librustc,
1093 test_kind: self.test_kind,
1094 krate: self.krate,
1095 });
1096 }
1097}
1098
1099
Mark Simulacrum0a1b5e82017-07-04 23:53:531100// for (krate, path, _default) in krates("std") {
1101// rules.test(&krate.test_step, path)
1102// .dep(|s| s.name("libtest"))
1103// .dep(|s| s.name("remote-copy-libs"))
1104// .run(move |s| check::krate(build, &s.compiler(), s.target,
1105// Mode::Libstd, TestKind::Test,
1106// Some(&krate.name)));
1107// }
1108// rules.test("check-std-all", "path/to/nowhere")
1109// .dep(|s| s.name("libtest"))
1110// .dep(|s| s.name("remote-copy-libs"))
1111// .default(true)
1112// .run(move |s| check::krate(build, &s.compiler(), s.target,
1113// Mode::Libstd, TestKind::Test, None));
1114//
1115// // std benchmarks
1116// for (krate, path, _default) in krates("std") {
1117// rules.bench(&krate.bench_step, path)
1118// .dep(|s| s.name("libtest"))
1119// .dep(|s| s.name("remote-copy-libs"))
1120// .run(move |s| check::krate(build, &s.compiler(), s.target,
1121// Mode::Libstd, TestKind::Bench,
1122// Some(&krate.name)));
1123// }
1124// rules.bench("bench-std-all", "path/to/nowhere")
1125// .dep(|s| s.name("libtest"))
1126// .dep(|s| s.name("remote-copy-libs"))
1127// .default(true)
1128// .run(move |s| check::krate(build, &s.compiler(), s.target,
1129// Mode::Libstd, TestKind::Bench, None));
1130//
1131// for (krate, path, _default) in krates("test") {
1132// rules.test(&krate.test_step, path)
1133// .dep(|s| s.name("libtest"))
1134// .dep(|s| s.name("remote-copy-libs"))
1135// .run(move |s| check::krate(build, &s.compiler(), s.target,
1136// Mode::Libtest, TestKind::Test,
1137// Some(&krate.name)));
1138// }
1139// rules.test("check-test-all", "path/to/nowhere")
1140// .dep(|s| s.name("libtest"))
1141// .dep(|s| s.name("remote-copy-libs"))
1142// .default(true)
1143// .run(move |s| check::krate(build, &s.compiler(), s.target,
1144// Mode::Libtest, TestKind::Test, None));
Mark Simulacrum0a1b5e82017-07-04 23:53:531145
Mark Simulacrum528646e2017-07-14 00:48:441146#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum981afa52017-07-18 21:28:531147pub struct Crate {
Mark Simulacrum528646e2017-07-14 00:48:441148 compiler: Compiler,
1149 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431150 mode: Mode,
1151 test_kind: TestKind,
Mark Simulacrum528646e2017-07-14 00:48:441152 krate: Option<Interned<String>>,
Mark Simulacrum001e9f32017-07-05 01:41:431153}
Alex Crichtonbb9062a2016-04-29 21:23:151154
Mark Simulacrum981afa52017-07-18 21:28:531155impl Step for Crate {
Mark Simulacrum001e9f32017-07-05 01:41:431156 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271157 const DEFAULT: bool = true;
1158
Mark Simulacrum56128fb2017-07-19 00:03:381159 fn should_run(run: ShouldRun) -> ShouldRun {
1160 run.krate("std").krate("test")
Mark Simulacrum6b3413d2017-07-05 12:41:271161 }
1162
Mark Simulacrum528646e2017-07-14 00:48:441163 fn make_run(
1164 builder: &Builder,
1165 path: Option<&Path>,
1166 host: Interned<String>,
1167 target: Interned<String>,
1168 ) {
Mark Simulacrum6b3413d2017-07-05 12:41:271169 let compiler = builder.compiler(builder.top_stage, host);
1170
Mark Simulacrum528646e2017-07-14 00:48:441171 let run = |mode: Mode, name: Option<Interned<String>>| {
Mark Simulacrum6b3413d2017-07-05 12:41:271172 let test_kind = if builder.kind == Kind::Test {
1173 TestKind::Test
1174 } else if builder.kind == Kind::Bench {
1175 TestKind::Bench
1176 } else {
Mark Simulacrum981afa52017-07-18 21:28:531177 panic!("unexpected builder.kind in crate: {:?}", builder.kind);
Mark Simulacrum6b3413d2017-07-05 12:41:271178 };
1179
Mark Simulacrum981afa52017-07-18 21:28:531180 builder.ensure(Crate {
Mark Simulacrum6b3413d2017-07-05 12:41:271181 compiler, target,
1182 mode: mode,
1183 test_kind: test_kind,
1184 krate: name,
1185 });
1186 };
1187
1188 if let Some(path) = path {
1189 for (name, krate_path) in builder.crates("std") {
1190 if path.ends_with(krate_path) {
1191 run(Mode::Libstd, Some(name));
1192 }
1193 }
1194 for (name, krate_path) in builder.crates("test") {
1195 if path.ends_with(krate_path) {
1196 run(Mode::Libtest, Some(name));
1197 }
1198 }
1199 } else {
1200 run(Mode::Libstd, None);
1201 run(Mode::Libtest, None);
1202 }
1203 }
Alex Crichton7046fea2016-12-25 23:20:331204
Mark Simulacrum001e9f32017-07-05 01:41:431205 /// Run all unit tests plus documentation tests for an entire crate DAG defined
1206 /// by a `Cargo.toml`
1207 ///
1208 /// This is what runs tests for crates like the standard library, compiler, etc.
1209 /// It essentially is the driver for running `cargo test`.
1210 ///
1211 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
1212 /// arguments, and those arguments are discovered from `cargo metadata`.
1213 fn run(self, builder: &Builder) {
1214 let build = builder.build;
1215 let compiler = self.compiler;
1216 let target = self.target;
1217 let mode = self.mode;
1218 let test_kind = self.test_kind;
1219 let krate = self.krate;
Alex Crichtonbb9062a2016-04-29 21:23:151220
Mark Simulacrum6b3413d2017-07-05 12:41:271221 builder.ensure(compile::Test { compiler, target });
1222 builder.ensure(RemoteCopyLibs { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431223 let (name, path, features, root) = match mode {
1224 Mode::Libstd => {
1225 ("libstd", "src/libstd", build.std_features(), "std")
1226 }
1227 Mode::Libtest => {
1228 ("libtest", "src/libtest", String::new(), "test")
1229 }
1230 Mode::Librustc => {
Mark Simulacrumceecd622017-07-12 16:12:471231 builder.ensure(compile::Rustc { compiler, target });
Mark Simulacrum001e9f32017-07-05 01:41:431232 ("librustc", "src/rustc", build.rustc_features(), "rustc-main")
1233 }
1234 _ => panic!("can only test libraries"),
1235 };
Mark Simulacrum528646e2017-07-14 00:48:441236 let root = INTERNER.intern_string(String::from(root));
Mark Simulacrum001e9f32017-07-05 01:41:431237 let _folder = build.fold_output(|| {
1238 format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, name)
1239 });
1240 println!("{} {} stage{} ({} -> {})", test_kind, name, compiler.stage,
Mark Simulacrum528646e2017-07-14 00:48:441241 &compiler.host, target);
Mark Simulacrum001e9f32017-07-05 01:41:431242
1243 // If we're not doing a full bootstrap but we're testing a stage2 version of
1244 // libstd, then what we're actually testing is the libstd produced in
1245 // stage1. Reflect that here by updating the compiler that we're working
1246 // with automatically.
1247 let compiler = if build.force_use_stage1(compiler, target) {
Mark Simulacrum6b3413d2017-07-05 12:41:271248 builder.compiler(1, compiler.host)
Mark Simulacrum001e9f32017-07-05 01:41:431249 } else {
1250 compiler.clone()
1251 };
1252
1253 // Build up the base `cargo test` command.
1254 //
1255 // Pass in some standard flags then iterate over the graph we've discovered
1256 // in `cargo metadata` with the maps above and figure out what `-p`
1257 // arguments need to get passed.
Mark Simulacrumc114fe52017-07-05 17:21:331258 let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
Mark Simulacrum001e9f32017-07-05 01:41:431259 cargo.arg("--manifest-path")
1260 .arg(build.src.join(path).join("Cargo.toml"))
1261 .arg("--features").arg(features);
1262 if test_kind.subcommand() == "test" && !build.fail_fast {
1263 cargo.arg("--no-fail-fast");
Alex Crichtonbb9062a2016-04-29 21:23:151264 }
Mark Simulacrum001e9f32017-07-05 01:41:431265
1266 match krate {
1267 Some(krate) => {
1268 cargo.arg("-p").arg(krate);
1269 }
1270 None => {
1271 let mut visited = HashSet::new();
1272 let mut next = vec![root];
1273 while let Some(name) = next.pop() {
1274 // Right now jemalloc is our only target-specific crate in the
1275 // sense that it's not present on all platforms. Custom skip it
1276 // here for now, but if we add more this probably wants to get
1277 // more generalized.
1278 //
1279 // Also skip `build_helper` as it's not compiled normally for
1280 // target during the bootstrap and it's just meant to be a
1281 // helper crate, not tested. If it leaks through then it ends up
1282 // messing with various mtime calculations and such.
Mark Simulacrum528646e2017-07-14 00:48:441283 if !name.contains("jemalloc") && *name != *"build_helper" {
Mark Simulacrum001e9f32017-07-05 01:41:431284 cargo.arg("-p").arg(&format!("{}:0.0.0", name));
1285 }
Mark Simulacrum528646e2017-07-14 00:48:441286 for dep in build.crates[&name].deps.iter() {
Mark Simulacrum001e9f32017-07-05 01:41:431287 if visited.insert(dep) {
Mark Simulacrum528646e2017-07-14 00:48:441288 next.push(*dep);
Mark Simulacrum001e9f32017-07-05 01:41:431289 }
Alex Crichtona270b802016-10-21 20:18:091290 }
1291 }
Alex Crichtonbb9062a2016-04-29 21:23:151292 }
1293 }
Alex Crichtonbb9062a2016-04-29 21:23:151294
Mark Simulacrum001e9f32017-07-05 01:41:431295 // The tests are going to run with the *target* libraries, so we need to
1296 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
1297 //
1298 // Note that to run the compiler we need to run with the *host* libraries,
1299 // but our wrapper scripts arrange for that to be the case anyway.
1300 let mut dylib_path = dylib_path();
Mark Simulacrum528646e2017-07-14 00:48:441301 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
Mark Simulacrum001e9f32017-07-05 01:41:431302 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
Alex Crichtonbb9062a2016-04-29 21:23:151303
Mark Simulacrum001e9f32017-07-05 01:41:431304 if target.contains("emscripten") || build.remote_tested(target) {
1305 cargo.arg("--no-run");
1306 }
Alex Crichton0e272de2016-11-16 20:31:191307
Mark Simulacrum001e9f32017-07-05 01:41:431308 cargo.arg("--");
Alex Crichton0e272de2016-11-16 20:31:191309
Mark Simulacrum001e9f32017-07-05 01:41:431310 if build.config.quiet_tests {
1311 cargo.arg("--quiet");
1312 }
Corey Farwellc8c6d2c2016-10-30 01:58:521313
Mark Simulacrum001e9f32017-07-05 01:41:431314 let _time = util::timeit();
Alex Crichton0e272de2016-11-16 20:31:191315
Mark Simulacrum001e9f32017-07-05 01:41:431316 if target.contains("emscripten") {
1317 build.run(&mut cargo);
Mark Simulacrum60388302017-07-05 16:46:411318 krate_emscripten(build, compiler, target, mode);
Mark Simulacrum001e9f32017-07-05 01:41:431319 } else if build.remote_tested(target) {
1320 build.run(&mut cargo);
Mark Simulacrum60388302017-07-05 16:46:411321 krate_remote(builder, compiler, target, mode);
Mark Simulacrum001e9f32017-07-05 01:41:431322 } else {
1323 cargo.args(&build.flags.cmd.test_args());
1324 try_run(build, &mut cargo);
1325 }
Alex Crichton39a5d3f2016-06-28 20:31:301326 }
1327}
1328
Brian Andersonb8b50f02016-09-06 00:41:501329fn krate_emscripten(build: &Build,
Mark Simulacrum60388302017-07-05 16:46:411330 compiler: Compiler,
Mark Simulacrum528646e2017-07-14 00:48:441331 target: Interned<String>,
Brian Andersonb8b50f02016-09-06 00:41:501332 mode: Mode) {
Alex Crichton1747ce22017-01-28 21:38:061333 let out_dir = build.cargo_out(compiler, mode, target);
Mark Simulacrum5b44cbc2017-06-26 16:23:501334 let tests = find_tests(&out_dir.join("deps"), target);
Ross Schulmanad9184c2016-09-05 23:56:481335
Mark Simulacrum5b44cbc2017-06-26 16:23:501336 let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured");
Alex Crichton1747ce22017-01-28 21:38:061337 for test in tests {
Mark Simulacrum5b44cbc2017-06-26 16:23:501338 println!("running {}", test.display());
Alex Crichton1747ce22017-01-28 21:38:061339 let mut cmd = Command::new(nodejs);
Mark Simulacrum5b44cbc2017-06-26 16:23:501340 cmd.arg(&test);
Alex Crichton1747ce22017-01-28 21:38:061341 if build.config.quiet_tests {
1342 cmd.arg("--quiet");
1343 }
Josh Stone617aea42017-06-02 16:27:441344 try_run(build, &mut cmd);
Alex Crichton1747ce22017-01-28 21:38:061345 }
1346}
1347
Mark Simulacrum60388302017-07-05 16:46:411348fn krate_remote(builder: &Builder,
1349 compiler: Compiler,
Mark Simulacrum528646e2017-07-14 00:48:441350 target: Interned<String>,
Alex Crichton7bc2cbf2017-04-26 15:52:191351 mode: Mode) {
Mark Simulacrum60388302017-07-05 16:46:411352 let build = builder.build;
Alex Crichton1747ce22017-01-28 21:38:061353 let out_dir = build.cargo_out(compiler, mode, target);
Mark Simulacrum5b44cbc2017-06-26 16:23:501354 let tests = find_tests(&out_dir.join("deps"), target);
Alex Crichton1747ce22017-01-28 21:38:061355
Mark Simulacrum6b3413d2017-07-05 12:41:271356 let tool = builder.tool_exe(Tool::RemoteTestClient);
Alex Crichton1747ce22017-01-28 21:38:061357 for test in tests {
1358 let mut cmd = Command::new(&tool);
1359 cmd.arg("run")
1360 .arg(&test);
1361 if build.config.quiet_tests {
1362 cmd.arg("--quiet");
1363 }
1364 cmd.args(&build.flags.cmd.test_args());
Josh Stone617aea42017-06-02 16:27:441365 try_run(build, &mut cmd);
Alex Crichton1747ce22017-01-28 21:38:061366 }
1367}
Ross Schulmanad9184c2016-09-05 23:56:481368
Mark Simulacrum528646e2017-07-14 00:48:441369fn find_tests(dir: &Path, target: Interned<String>) -> Vec<PathBuf> {
Mark Simulacrum5b44cbc2017-06-26 16:23:501370 let mut dst = Vec::new();
Alex Crichton39a5d3f2016-06-28 20:31:301371 for e in t!(dir.read_dir()).map(|e| t!(e)) {
1372 let file_type = t!(e.file_type());
1373 if !file_type.is_file() {
1374 continue
1375 }
1376 let filename = e.file_name().into_string().unwrap();
1377 if (target.contains("windows") && filename.ends_with(".exe")) ||
Ross Schulmanad9184c2016-09-05 23:56:481378 (!target.contains("windows") && !filename.contains(".")) ||
Marco A L Barbosa554f21b2017-06-13 12:32:491379 (target.contains("emscripten") &&
1380 filename.ends_with(".js") &&
1381 !filename.ends_with(".asm.js")) {
Alex Crichton39a5d3f2016-06-28 20:31:301382 dst.push(e.path());
1383 }
1384 }
Mark Simulacrum5b44cbc2017-06-26 16:23:501385 dst
Alex Crichton39a5d3f2016-06-28 20:31:301386}
1387
Mark Simulacrum0a1b5e82017-07-04 23:53:531388// rules.test("remote-copy-libs", "path/to/nowhere")
1389// .dep(|s| s.name("libtest"))
1390// .dep(move |s| {
1391// if build.remote_tested(s.target) {
1392// s.name("tool-remote-test-client").target(s.host).stage(0)
1393// } else {
1394// Step::noop()
1395// }
1396// })
1397// .dep(move |s| {
1398// if build.remote_tested(s.target) {
1399// s.name("tool-remote-test-server")
1400// } else {
1401// Step::noop()
1402// }
1403// })
1404// .run(move |s| check::remote_copy_libs(build, &s.compiler(), s.target));
1405//
Alex Crichtoncf8fde12016-12-31 02:54:051406
Mark Simulacrumceecd622017-07-12 16:12:471407/// Some test suites are run inside emulators or on remote devices, and most
1408/// of our test binaries are linked dynamically which means we need to ship
1409/// the standard library and such to the emulator ahead of time. This step
1410/// represents this and is a dependency of all test suites.
1411///
1412/// Most of the time this is a noop. For some steps such as shipping data to
1413/// QEMU we have to build our own tools so we've got conditional dependencies
1414/// on those programs as well. Note that the remote test client is built for
1415/// the build target (us) and the server is built for the target.
Mark Simulacrum528646e2017-07-14 00:48:441416#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1417pub struct RemoteCopyLibs {
1418 compiler: Compiler,
1419 target: Interned<String>,
Mark Simulacrum001e9f32017-07-05 01:41:431420}
Alex Crichton1747ce22017-01-28 21:38:061421
Mark Simulacrum528646e2017-07-14 00:48:441422impl Step for RemoteCopyLibs {
Mark Simulacrum001e9f32017-07-05 01:41:431423 type Output = ();
Alex Crichton1747ce22017-01-28 21:38:061424
Mark Simulacrum56128fb2017-07-19 00:03:381425 fn should_run(run: ShouldRun) -> ShouldRun {
1426 run.never()
Mark Simulacrum681b1232017-07-14 12:30:161427 }
1428
Mark Simulacrum001e9f32017-07-05 01:41:431429 fn run(self, builder: &Builder) {
1430 let build = builder.build;
1431 let compiler = self.compiler;
1432 let target = self.target;
1433 if !build.remote_tested(target) {
1434 return
1435 }
Alex Crichton1747ce22017-01-28 21:38:061436
Mark Simulacrum6b3413d2017-07-05 12:41:271437 builder.ensure(compile::Test { compiler, target });
1438
Mark Simulacrum001e9f32017-07-05 01:41:431439 println!("REMOTE copy libs to emulator ({})", target);
1440 t!(fs::create_dir_all(build.out.join("tmp")));
1441
Mark Simulacrum5984e702017-07-13 00:52:311442 let server = builder.ensure(tool::RemoteTestServer { stage: compiler.stage, target });
Mark Simulacrum001e9f32017-07-05 01:41:431443
1444 // Spawn the emulator and wait for it to come online
Mark Simulacrum6b3413d2017-07-05 12:41:271445 let tool = builder.tool_exe(Tool::RemoteTestClient);
Mark Simulacrum001e9f32017-07-05 01:41:431446 let mut cmd = Command::new(&tool);
1447 cmd.arg("spawn-emulator")
1448 .arg(target)
1449 .arg(&server)
1450 .arg(build.out.join("tmp"));
1451 if let Some(rootfs) = build.qemu_rootfs(target) {
1452 cmd.arg(rootfs);
1453 }
1454 build.run(&mut cmd);
1455
1456 // Push all our dylibs to the emulator
Mark Simulacrum60388302017-07-05 16:46:411457 for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
Mark Simulacrum001e9f32017-07-05 01:41:431458 let f = t!(f);
1459 let name = f.file_name().into_string().unwrap();
1460 if util::is_dylib(&name) {
1461 build.run(Command::new(&tool)
1462 .arg("push")
1463 .arg(f.path()));
1464 }
Alex Crichton1747ce22017-01-28 21:38:061465 }
1466 }
1467}
1468
Mark Simulacrum0a1b5e82017-07-04 23:53:531469//rules.test("check-distcheck", "distcheck")
1470// .dep(|s| s.name("dist-plain-source-tarball"))
1471// .dep(|s| s.name("dist-src"))
1472// .run(move |_| check::distcheck(build));
1473
Mark Simulacrum528646e2017-07-14 00:48:441474#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431475pub struct Distcheck;
1476
Mark Simulacrum528646e2017-07-14 00:48:441477impl Step for Distcheck {
Mark Simulacrum001e9f32017-07-05 01:41:431478 type Output = ();
1479
Mark Simulacrum56128fb2017-07-19 00:03:381480 fn should_run(run: ShouldRun) -> ShouldRun {
1481 run.path("distcheck")
Mark Simulacrum681b1232017-07-14 12:30:161482 }
1483
Mark Simulacrum001e9f32017-07-05 01:41:431484 /// Run "distcheck", a 'make check' from a tarball
1485 fn run(self, builder: &Builder) {
1486 let build = builder.build;
1487
Mark Simulacrum528646e2017-07-14 00:48:441488 if *build.build != *"x86_64-unknown-linux-gnu" {
Mark Simulacrum001e9f32017-07-05 01:41:431489 return
1490 }
1491 if !build.config.host.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
1492 return
1493 }
1494 if !build.config.target.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
1495 return
1496 }
1497
1498 println!("Distcheck");
1499 let dir = build.out.join("tmp").join("distcheck");
1500 let _ = fs::remove_dir_all(&dir);
1501 t!(fs::create_dir_all(&dir));
1502
1503 let mut cmd = Command::new("tar");
1504 cmd.arg("-xzf")
Mark Simulacrum5984e702017-07-13 00:52:311505 .arg(builder.ensure(dist::PlainSourceTarball))
Mark Simulacrum001e9f32017-07-05 01:41:431506 .arg("--strip-components=1")
1507 .current_dir(&dir);
1508 build.run(&mut cmd);
1509 build.run(Command::new("./configure")
1510 .args(&build.config.configure_args)
1511 .arg("--enable-vendor")
1512 .current_dir(&dir));
1513 build.run(Command::new(build_helper::make(&build.build))
1514 .arg("check")
1515 .current_dir(&dir));
1516
1517 // Now make sure that rust-src has all of libstd's dependencies
1518 println!("Distcheck rust-src");
1519 let dir = build.out.join("tmp").join("distcheck-src");
1520 let _ = fs::remove_dir_all(&dir);
1521 t!(fs::create_dir_all(&dir));
1522
1523 let mut cmd = Command::new("tar");
1524 cmd.arg("-xzf")
Mark Simulacrum5984e702017-07-13 00:52:311525 .arg(builder.ensure(dist::Src))
Mark Simulacrum001e9f32017-07-05 01:41:431526 .arg("--strip-components=1")
1527 .current_dir(&dir);
1528 build.run(&mut cmd);
1529
1530 let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
1531 build.run(Command::new(&build.initial_cargo)
1532 .arg("generate-lockfile")
1533 .arg("--manifest-path")
1534 .arg(&toml)
1535 .current_dir(&dir));
Alex Crichtond38db822016-12-09 01:13:551536 }
Alex Crichtond38db822016-12-09 01:13:551537}
Alex Crichton1a040b32016-12-31 03:50:571538
Mark Simulacrum0a1b5e82017-07-04 23:53:531539//rules.test("check-bootstrap", "src/bootstrap")
1540// .default(true)
1541// .host(true)
1542// .only_build(true)
1543// .run(move |_| check::bootstrap(build));
Mark Simulacrum001e9f32017-07-05 01:41:431544
Mark Simulacrum528646e2017-07-14 00:48:441545#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Mark Simulacrum001e9f32017-07-05 01:41:431546pub struct Bootstrap;
1547
Mark Simulacrum528646e2017-07-14 00:48:441548impl Step for Bootstrap {
Mark Simulacrum001e9f32017-07-05 01:41:431549 type Output = ();
Mark Simulacrum6b3413d2017-07-05 12:41:271550 const DEFAULT: bool = true;
1551 const ONLY_HOSTS: bool = true;
1552 const ONLY_BUILD: bool = true;
Mark Simulacrum001e9f32017-07-05 01:41:431553
1554 /// Test the build system itself
1555 fn run(self, builder: &Builder) {
1556 let build = builder.build;
1557 let mut cmd = Command::new(&build.initial_cargo);
1558 cmd.arg("test")
1559 .current_dir(build.src.join("src/bootstrap"))
1560 .env("CARGO_TARGET_DIR", build.out.join("bootstrap"))
1561 .env("RUSTC_BOOTSTRAP", "1")
1562 .env("RUSTC", &build.initial_rustc);
1563 if !build.fail_fast {
1564 cmd.arg("--no-fail-fast");
1565 }
1566 cmd.arg("--").args(&build.flags.cmd.test_args());
1567 try_run(build, &mut cmd);
Josh Stone617aea42017-06-02 16:27:441568 }
Mark Simulacrum6b3413d2017-07-05 12:41:271569
Mark Simulacrum56128fb2017-07-19 00:03:381570 fn should_run(run: ShouldRun) -> ShouldRun {
1571 run.path("src/bootstrap")
Mark Simulacrum6b3413d2017-07-05 12:41:271572 }
1573
Mark Simulacrum528646e2017-07-14 00:48:441574 fn make_run(
1575 builder: &Builder,
1576 _path: Option<&Path>,
1577 _host: Interned<String>,
1578 _target: Interned<String>,
1579 ) {
Mark Simulacrum6b3413d2017-07-05 12:41:271580 builder.ensure(Bootstrap);
1581 }
Alex Crichton1a040b32016-12-31 03:50:571582}