]> git.lizzy.rs Git - rust.git/blob - src/bootstrap/check.rs
Auto merge of #42856 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
[rust.git] / src / bootstrap / check.rs
1 // 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
11 //! Implementation of the test-related targets of the build system.
12 //!
13 //! This file implements the various regression test suites that we execute on
14 //! our CI.
15
16 extern crate build_helper;
17
18 use std::collections::HashSet;
19 use std::env;
20 use std::fmt;
21 use std::fs::{self, File};
22 use std::path::{PathBuf, Path};
23 use std::process::Command;
24 use std::io::Read;
25
26 use build_helper::output;
27
28 use {Build, Compiler, Mode};
29 use dist;
30 use util::{self, dylib_path, dylib_path_var, exe};
31
32 const ADB_TEST_DIR: &'static str = "/data/tmp/work";
33
34 /// The two modes of the test runner; tests or benchmarks.
35 #[derive(Copy, Clone)]
36 pub enum TestKind {
37     /// Run `cargo test`
38     Test,
39     /// Run `cargo bench`
40     Bench,
41 }
42
43 impl TestKind {
44     // Return the cargo subcommand for this test kind
45     fn subcommand(self) -> &'static str {
46         match self {
47             TestKind::Test => "test",
48             TestKind::Bench => "bench",
49         }
50     }
51 }
52
53 impl fmt::Display for TestKind {
54     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
55         f.write_str(match *self {
56             TestKind::Test => "Testing",
57             TestKind::Bench => "Benchmarking",
58         })
59     }
60 }
61
62 fn try_run(build: &Build, cmd: &mut Command) {
63     if build.flags.cmd.no_fail_fast() {
64         if !build.try_run(cmd) {
65             let failures = build.delayed_failures.get();
66             build.delayed_failures.set(failures + 1);
67         }
68     } else {
69         build.run(cmd);
70     }
71 }
72
73 fn try_run_quiet(build: &Build, cmd: &mut Command) {
74     if build.flags.cmd.no_fail_fast() {
75         if !build.try_run_quiet(cmd) {
76             let failures = build.delayed_failures.get();
77             build.delayed_failures.set(failures + 1);
78         }
79     } else {
80         build.run_quiet(cmd);
81     }
82 }
83
84 /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
85 ///
86 /// This tool in `src/tools` will verify the validity of all our links in the
87 /// documentation to ensure we don't have a bunch of dead ones.
88 pub fn linkcheck(build: &Build, host: &str) {
89     println!("Linkcheck ({})", host);
90     let compiler = Compiler::new(0, host);
91
92     let _time = util::timeit();
93     try_run(build, build.tool_cmd(&compiler, "linkchecker")
94                         .arg(build.out.join(host).join("doc")));
95 }
96
97 /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
98 ///
99 /// This tool in `src/tools` will check out a few Rust projects and run `cargo
100 /// test` to ensure that we don't regress the test suites there.
101 pub fn cargotest(build: &Build, stage: u32, host: &str) {
102     let ref compiler = Compiler::new(stage, host);
103
104     // Note that this is a short, cryptic, and not scoped directory name. This
105     // is currently to minimize the length of path on Windows where we otherwise
106     // quickly run into path name limit constraints.
107     let out_dir = build.out.join("ct");
108     t!(fs::create_dir_all(&out_dir));
109
110     let _time = util::timeit();
111     let mut cmd = Command::new(build.tool(&Compiler::new(0, host), "cargotest"));
112     build.prepare_tool_cmd(compiler, &mut cmd);
113     try_run(build, cmd.arg(&build.cargo)
114                       .arg(&out_dir)
115                       .env("RUSTC", build.compiler_path(compiler))
116                       .env("RUSTDOC", build.rustdoc(compiler)));
117 }
118
119 /// Runs `cargo test` for `cargo` packaged with Rust.
120 pub fn cargo(build: &Build, stage: u32, host: &str) {
121     let ref compiler = Compiler::new(stage, host);
122
123     // Configure PATH to find the right rustc. NB. we have to use PATH
124     // and not RUSTC because the Cargo test suite has tests that will
125     // fail if rustc is not spelled `rustc`.
126     let path = build.sysroot(compiler).join("bin");
127     let old_path = ::std::env::var("PATH").expect("");
128     let sep = if cfg!(windows) { ";" } else {":" };
129     let ref newpath = format!("{}{}{}", path.display(), sep, old_path);
130
131     let mut cargo = build.cargo(compiler, Mode::Tool, host, "test");
132     cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
133     if build.flags.cmd.no_fail_fast() {
134         cargo.arg("--no-fail-fast");
135     }
136
137     // Don't build tests dynamically, just a pain to work with
138     cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
139
140     // Don't run cross-compile tests, we may not have cross-compiled libstd libs
141     // available.
142     cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
143
144     try_run(build, cargo.env("PATH", newpath));
145 }
146
147 /// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
148 ///
149 /// This tool in `src/tools` checks up on various bits and pieces of style and
150 /// otherwise just implements a few lint-like checks that are specific to the
151 /// compiler itself.
152 pub fn tidy(build: &Build, host: &str) {
153     let _folder = build.fold_output(|| "tidy");
154     println!("tidy check ({})", host);
155     let compiler = Compiler::new(0, host);
156     let mut cmd = build.tool_cmd(&compiler, "tidy");
157     cmd.arg(build.src.join("src"));
158     if !build.config.vendor {
159         cmd.arg("--no-vendor");
160     }
161     if build.config.quiet_tests {
162         cmd.arg("--quiet");
163     }
164     try_run(build, &mut cmd);
165 }
166
167 fn testdir(build: &Build, host: &str) -> PathBuf {
168     build.out.join(host).join("test")
169 }
170
171 /// Executes the `compiletest` tool to run a suite of tests.
172 ///
173 /// Compiles all tests with `compiler` for `target` with the specified
174 /// compiletest `mode` and `suite` arguments. For example `mode` can be
175 /// "run-pass" or `suite` can be something like `debuginfo`.
176 pub fn compiletest(build: &Build,
177                    compiler: &Compiler,
178                    target: &str,
179                    mode: &str,
180                    suite: &str) {
181     let _folder = build.fold_output(|| format!("test_{}", suite));
182     println!("Check compiletest suite={} mode={} ({} -> {})",
183              suite, mode, compiler.host, target);
184     let mut cmd = Command::new(build.tool(&Compiler::new(0, compiler.host),
185                                           "compiletest"));
186     build.prepare_tool_cmd(compiler, &mut cmd);
187
188     // compiletest currently has... a lot of arguments, so let's just pass all
189     // of them!
190
191     cmd.arg("--compile-lib-path").arg(build.rustc_libdir(compiler));
192     cmd.arg("--run-lib-path").arg(build.sysroot_libdir(compiler, target));
193     cmd.arg("--rustc-path").arg(build.compiler_path(compiler));
194     cmd.arg("--rustdoc-path").arg(build.rustdoc(compiler));
195     cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
196     cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
197     cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
198     cmd.arg("--mode").arg(mode);
199     cmd.arg("--target").arg(target);
200     cmd.arg("--host").arg(compiler.host);
201     cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build));
202
203     if let Some(nodejs) = build.config.nodejs.as_ref() {
204         cmd.arg("--nodejs").arg(nodejs);
205     }
206
207     let mut flags = vec!["-Crpath".to_string()];
208     if build.config.rust_optimize_tests {
209         flags.push("-O".to_string());
210     }
211     if build.config.rust_debuginfo_tests {
212         flags.push("-g".to_string());
213     }
214
215     let mut hostflags = build.rustc_flags(&compiler.host);
216     hostflags.extend(flags.clone());
217     cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
218
219     let mut targetflags = build.rustc_flags(&target);
220     targetflags.extend(flags);
221     targetflags.push(format!("-Lnative={}",
222                              build.test_helpers_out(target).display()));
223     cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
224
225     cmd.arg("--docck-python").arg(build.python());
226
227     if build.config.build.ends_with("apple-darwin") {
228         // Force /usr/bin/python on macOS for LLDB tests because we're loading the
229         // LLDB plugin's compiled module which only works with the system python
230         // (namely not Homebrew-installed python)
231         cmd.arg("--lldb-python").arg("/usr/bin/python");
232     } else {
233         cmd.arg("--lldb-python").arg(build.python());
234     }
235
236     if let Some(ref gdb) = build.config.gdb {
237         cmd.arg("--gdb").arg(gdb);
238     }
239     if let Some(ref vers) = build.lldb_version {
240         cmd.arg("--lldb-version").arg(vers);
241     }
242     if let Some(ref dir) = build.lldb_python_dir {
243         cmd.arg("--lldb-python-dir").arg(dir);
244     }
245     let llvm_config = build.llvm_config(target);
246     let llvm_version = output(Command::new(&llvm_config).arg("--version"));
247     cmd.arg("--llvm-version").arg(llvm_version);
248     if !build.is_rust_llvm(target) {
249         cmd.arg("--system-llvm");
250     }
251
252     cmd.args(&build.flags.cmd.test_args());
253
254     if build.config.verbose() || build.flags.verbose() {
255         cmd.arg("--verbose");
256     }
257
258     if build.config.quiet_tests {
259         cmd.arg("--quiet");
260     }
261
262     // Only pass correct values for these flags for the `run-make` suite as it
263     // requires that a C++ compiler was configured which isn't always the case.
264     if suite == "run-make" {
265         let llvm_components = output(Command::new(&llvm_config).arg("--components"));
266         let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
267         cmd.arg("--cc").arg(build.cc(target))
268            .arg("--cxx").arg(build.cxx(target).unwrap())
269            .arg("--cflags").arg(build.cflags(target).join(" "))
270            .arg("--llvm-components").arg(llvm_components.trim())
271            .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
272     } else {
273         cmd.arg("--cc").arg("")
274            .arg("--cxx").arg("")
275            .arg("--cflags").arg("")
276            .arg("--llvm-components").arg("")
277            .arg("--llvm-cxxflags").arg("");
278     }
279
280     if build.remote_tested(target) {
281         cmd.arg("--remote-test-client")
282            .arg(build.tool(&Compiler::new(0, &build.config.build),
283                            "remote-test-client"));
284     }
285
286     // Running a C compiler on MSVC requires a few env vars to be set, to be
287     // sure to set them here.
288     //
289     // Note that if we encounter `PATH` we make sure to append to our own `PATH`
290     // rather than stomp over it.
291     if target.contains("msvc") {
292         for &(ref k, ref v) in build.cc[target].0.env() {
293             if k != "PATH" {
294                 cmd.env(k, v);
295             }
296         }
297     }
298     cmd.env("RUSTC_BOOTSTRAP", "1");
299     build.add_rust_test_threads(&mut cmd);
300
301     if build.config.sanitizers {
302         cmd.env("SANITIZER_SUPPORT", "1");
303     }
304
305     if build.config.profiler {
306         cmd.env("PROFILER_SUPPORT", "1");
307     }
308
309     cmd.arg("--adb-path").arg("adb");
310     cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
311     if target.contains("android") {
312         // Assume that cc for this target comes from the android sysroot
313         cmd.arg("--android-cross-path")
314            .arg(build.cc(target).parent().unwrap().parent().unwrap());
315     } else {
316         cmd.arg("--android-cross-path").arg("");
317     }
318
319     build.ci_env.force_coloring_in_ci(&mut cmd);
320
321     let _time = util::timeit();
322     try_run(build, &mut cmd);
323 }
324
325 /// Run `rustdoc --test` for all documentation in `src/doc`.
326 ///
327 /// This will run all tests in our markdown documentation (e.g. the book)
328 /// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
329 /// `compiler`.
330 pub fn docs(build: &Build, compiler: &Compiler) {
331     // Do a breadth-first traversal of the `src/doc` directory and just run
332     // tests for all files that end in `*.md`
333     let mut stack = vec![build.src.join("src/doc")];
334     let _time = util::timeit();
335     let _folder = build.fold_output(|| "test_docs");
336
337     while let Some(p) = stack.pop() {
338         if p.is_dir() {
339             stack.extend(t!(p.read_dir()).map(|p| t!(p).path()).filter(|p| {
340                 p.extension().and_then(|s| s.to_str()) == Some("md") &&
341                 // The nostarch directory in the book is for no starch, and so isn't guaranteed to
342                 // build. We don't care if it doesn't build, so skip it.
343                 p.to_str().map_or(true, |p| !p.contains("nostarch"))
344             }));
345             continue
346         }
347
348         markdown_test(build, compiler, &p);
349     }
350 }
351
352 /// Run the error index generator tool to execute the tests located in the error
353 /// index.
354 ///
355 /// The `error_index_generator` tool lives in `src/tools` and is used to
356 /// generate a markdown file from the error indexes of the code base which is
357 /// then passed to `rustdoc --test`.
358 pub fn error_index(build: &Build, compiler: &Compiler) {
359     let _folder = build.fold_output(|| "test_error_index");
360     println!("Testing error-index stage{}", compiler.stage);
361
362     let dir = testdir(build, compiler.host);
363     t!(fs::create_dir_all(&dir));
364     let output = dir.join("error-index.md");
365
366     let _time = util::timeit();
367     build.run(build.tool_cmd(&Compiler::new(0, compiler.host),
368                              "error_index_generator")
369                    .arg("markdown")
370                    .arg(&output)
371                    .env("CFG_BUILD", &build.config.build));
372
373     markdown_test(build, compiler, &output);
374 }
375
376 fn markdown_test(build: &Build, compiler: &Compiler, markdown: &Path) {
377     let mut file = t!(File::open(markdown));
378     let mut contents = String::new();
379     t!(file.read_to_string(&mut contents));
380     if !contents.contains("```") {
381         return;
382     }
383
384     println!("doc tests for: {}", markdown.display());
385     let mut cmd = Command::new(build.rustdoc(compiler));
386     build.add_rustc_lib_path(compiler, &mut cmd);
387     build.add_rust_test_threads(&mut cmd);
388     cmd.arg("--test");
389     cmd.arg(markdown);
390     cmd.env("RUSTC_BOOTSTRAP", "1");
391
392     let test_args = build.flags.cmd.test_args().join(" ");
393     cmd.arg("--test-args").arg(test_args);
394
395     if build.config.quiet_tests {
396         try_run_quiet(build, &mut cmd);
397     } else {
398         try_run(build, &mut cmd);
399     }
400 }
401
402 /// Run all unit tests plus documentation tests for an entire crate DAG defined
403 /// by a `Cargo.toml`
404 ///
405 /// This is what runs tests for crates like the standard library, compiler, etc.
406 /// It essentially is the driver for running `cargo test`.
407 ///
408 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
409 /// arguments, and those arguments are discovered from `cargo metadata`.
410 pub fn krate(build: &Build,
411              compiler: &Compiler,
412              target: &str,
413              mode: Mode,
414              test_kind: TestKind,
415              krate: Option<&str>) {
416     let (name, path, features, root) = match mode {
417         Mode::Libstd => {
418             ("libstd", "src/libstd", build.std_features(), "std")
419         }
420         Mode::Libtest => {
421             ("libtest", "src/libtest", String::new(), "test")
422         }
423         Mode::Librustc => {
424             ("librustc", "src/rustc", build.rustc_features(), "rustc-main")
425         }
426         _ => panic!("can only test libraries"),
427     };
428     let _folder = build.fold_output(|| {
429         format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, name)
430     });
431     println!("{} {} stage{} ({} -> {})", test_kind, name, compiler.stage,
432              compiler.host, target);
433
434     // If we're not doing a full bootstrap but we're testing a stage2 version of
435     // libstd, then what we're actually testing is the libstd produced in
436     // stage1. Reflect that here by updating the compiler that we're working
437     // with automatically.
438     let compiler = if build.force_use_stage1(compiler, target) {
439         Compiler::new(1, compiler.host)
440     } else {
441         compiler.clone()
442     };
443
444     // Build up the base `cargo test` command.
445     //
446     // Pass in some standard flags then iterate over the graph we've discovered
447     // in `cargo metadata` with the maps above and figure out what `-p`
448     // arguments need to get passed.
449     let mut cargo = build.cargo(&compiler, mode, target, test_kind.subcommand());
450     cargo.arg("--manifest-path")
451          .arg(build.src.join(path).join("Cargo.toml"))
452          .arg("--features").arg(features);
453     if test_kind.subcommand() == "test" && build.flags.cmd.no_fail_fast() {
454         cargo.arg("--no-fail-fast");
455     }
456
457     match krate {
458         Some(krate) => {
459             cargo.arg("-p").arg(krate);
460         }
461         None => {
462             let mut visited = HashSet::new();
463             let mut next = vec![root];
464             while let Some(name) = next.pop() {
465                 // Right now jemalloc is our only target-specific crate in the
466                 // sense that it's not present on all platforms. Custom skip it
467                 // here for now, but if we add more this probably wants to get
468                 // more generalized.
469                 //
470                 // Also skip `build_helper` as it's not compiled normally for
471                 // target during the bootstrap and it's just meant to be a
472                 // helper crate, not tested. If it leaks through then it ends up
473                 // messing with various mtime calculations and such.
474                 if !name.contains("jemalloc") && name != "build_helper" {
475                     cargo.arg("-p").arg(&format!("{}:0.0.0", name));
476                 }
477                 for dep in build.crates[name].deps.iter() {
478                     if visited.insert(dep) {
479                         next.push(dep);
480                     }
481                 }
482             }
483         }
484     }
485
486     // The tests are going to run with the *target* libraries, so we need to
487     // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
488     //
489     // Note that to run the compiler we need to run with the *host* libraries,
490     // but our wrapper scripts arrange for that to be the case anyway.
491     let mut dylib_path = dylib_path();
492     dylib_path.insert(0, build.sysroot_libdir(&compiler, target));
493     cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
494
495     if target.contains("emscripten") || build.remote_tested(target) {
496         cargo.arg("--no-run");
497     }
498
499     cargo.arg("--");
500
501     if build.config.quiet_tests {
502         cargo.arg("--quiet");
503     }
504
505     let _time = util::timeit();
506
507     if target.contains("emscripten") {
508         build.run(&mut cargo);
509         krate_emscripten(build, &compiler, target, mode);
510     } else if build.remote_tested(target) {
511         build.run(&mut cargo);
512         krate_remote(build, &compiler, target, mode);
513     } else {
514         cargo.args(&build.flags.cmd.test_args());
515         try_run(build, &mut cargo);
516     }
517 }
518
519 fn krate_emscripten(build: &Build,
520                     compiler: &Compiler,
521                     target: &str,
522                     mode: Mode) {
523     let mut tests = Vec::new();
524     let out_dir = build.cargo_out(compiler, mode, target);
525     find_tests(&out_dir.join("deps"), target, &mut tests);
526
527     for test in tests {
528         let test_file_name = test.to_string_lossy().into_owned();
529         println!("running {}", test_file_name);
530         let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured");
531         let mut cmd = Command::new(nodejs);
532         cmd.arg(&test_file_name);
533         if build.config.quiet_tests {
534             cmd.arg("--quiet");
535         }
536         try_run(build, &mut cmd);
537     }
538 }
539
540 fn krate_remote(build: &Build,
541                 compiler: &Compiler,
542                 target: &str,
543                 mode: Mode) {
544     let mut tests = Vec::new();
545     let out_dir = build.cargo_out(compiler, mode, target);
546     find_tests(&out_dir.join("deps"), target, &mut tests);
547
548     let tool = build.tool(&Compiler::new(0, &build.config.build),
549                           "remote-test-client");
550     for test in tests {
551         let mut cmd = Command::new(&tool);
552         cmd.arg("run")
553            .arg(&test);
554         if build.config.quiet_tests {
555             cmd.arg("--quiet");
556         }
557         cmd.args(&build.flags.cmd.test_args());
558         try_run(build, &mut cmd);
559     }
560 }
561
562 fn find_tests(dir: &Path,
563               target: &str,
564               dst: &mut Vec<PathBuf>) {
565     for e in t!(dir.read_dir()).map(|e| t!(e)) {
566         let file_type = t!(e.file_type());
567         if !file_type.is_file() {
568             continue
569         }
570         let filename = e.file_name().into_string().unwrap();
571         if (target.contains("windows") && filename.ends_with(".exe")) ||
572            (!target.contains("windows") && !filename.contains(".")) ||
573            (target.contains("emscripten") &&
574             filename.ends_with(".js") &&
575             !filename.ends_with(".asm.js")) {
576             dst.push(e.path());
577         }
578     }
579 }
580
581 pub fn remote_copy_libs(build: &Build, compiler: &Compiler, target: &str) {
582     if !build.remote_tested(target) {
583         return
584     }
585
586     println!("REMOTE copy libs to emulator ({})", target);
587     t!(fs::create_dir_all(build.out.join("tmp")));
588
589     let server = build.cargo_out(compiler, Mode::Tool, target)
590                       .join(exe("remote-test-server", target));
591
592     // Spawn the emulator and wait for it to come online
593     let tool = build.tool(&Compiler::new(0, &build.config.build),
594                           "remote-test-client");
595     let mut cmd = Command::new(&tool);
596     cmd.arg("spawn-emulator")
597        .arg(target)
598        .arg(&server)
599        .arg(build.out.join("tmp"));
600     if let Some(rootfs) = build.qemu_rootfs(target) {
601         cmd.arg(rootfs);
602     }
603     build.run(&mut cmd);
604
605     // Push all our dylibs to the emulator
606     for f in t!(build.sysroot_libdir(compiler, target).read_dir()) {
607         let f = t!(f);
608         let name = f.file_name().into_string().unwrap();
609         if util::is_dylib(&name) {
610             build.run(Command::new(&tool)
611                               .arg("push")
612                               .arg(f.path()));
613         }
614     }
615 }
616
617 /// Run "distcheck", a 'make check' from a tarball
618 pub fn distcheck(build: &Build) {
619     if build.config.build != "x86_64-unknown-linux-gnu" {
620         return
621     }
622     if !build.config.host.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
623         return
624     }
625     if !build.config.target.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
626         return
627     }
628
629     println!("Distcheck");
630     let dir = build.out.join("tmp").join("distcheck");
631     let _ = fs::remove_dir_all(&dir);
632     t!(fs::create_dir_all(&dir));
633
634     let mut cmd = Command::new("tar");
635     cmd.arg("-xzf")
636        .arg(dist::rust_src_location(build))
637        .arg("--strip-components=1")
638        .current_dir(&dir);
639     build.run(&mut cmd);
640     build.run(Command::new("./configure")
641                      .args(&build.config.configure_args)
642                      .arg("--enable-vendor")
643                      .current_dir(&dir));
644     build.run(Command::new(build_helper::make(&build.config.build))
645                      .arg("check")
646                      .current_dir(&dir));
647
648     // Now make sure that rust-src has all of libstd's dependencies
649     println!("Distcheck rust-src");
650     let dir = build.out.join("tmp").join("distcheck-src");
651     let _ = fs::remove_dir_all(&dir);
652     t!(fs::create_dir_all(&dir));
653
654     let mut cmd = Command::new("tar");
655     cmd.arg("-xzf")
656        .arg(dist::rust_src_installer(build))
657        .arg("--strip-components=1")
658        .current_dir(&dir);
659     build.run(&mut cmd);
660
661     let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
662     build.run(Command::new(&build.cargo)
663                      .arg("generate-lockfile")
664                      .arg("--manifest-path")
665                      .arg(&toml)
666                      .current_dir(&dir));
667 }
668
669 /// Test the build system itself
670 pub fn bootstrap(build: &Build) {
671     let mut cmd = Command::new(&build.cargo);
672     cmd.arg("test")
673        .current_dir(build.src.join("src/bootstrap"))
674        .env("CARGO_TARGET_DIR", build.out.join("bootstrap"))
675        .env("RUSTC_BOOTSTRAP", "1")
676        .env("RUSTC", &build.rustc);
677     if build.flags.cmd.no_fail_fast() {
678         cmd.arg("--no-fail-fast");
679     }
680     cmd.arg("--").args(&build.flags.cmd.test_args());
681     try_run(build, &mut cmd);
682 }