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