summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2018-05-30 14:33:43 -0300
committerSantiago Pastorino <spastorino@gmail.com>2018-05-30 14:36:23 -0300
commitb39a1d6f1a30ba29f25d7141038b9a5bf0126e36 (patch)
tree158a3ce450a02f9f9122fff3b01d4835e3eb8484
parentAdd compare-mode to x.py (diff)
downloadgrust-b39a1d6f1a30ba29f25d7141038b9a5bf0126e36.tar.gz
grust-b39a1d6f1a30ba29f25d7141038b9a5bf0126e36.tar.bz2
grust-b39a1d6f1a30ba29f25d7141038b9a5bf0126e36.tar.xz
Run rustfmt
-rw-r--r--src/bootstrap/builder.rs1246
-rw-r--r--src/bootstrap/flags.rs228
-rw-r--r--src/bootstrap/test.rs391
-rw-r--r--src/tools/compiletest/src/runtest.rs124
4 files changed, 1206 insertions, 783 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index e987d3fa4f..4fdb36b3f6 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -11,6 +11,7 @@
11use std::any::Any; 11use std::any::Any;
12use std::cell::{Cell, RefCell}; 12use std::cell::{Cell, RefCell};
13use std::collections::BTreeSet; 13use std::collections::BTreeSet;
14use std::collections::HashMap;
14use std::env; 15use std::env;
15use std::fmt::Debug; 16use std::fmt::Debug;
16use std::fs; 17use std::fs;
@@ -18,26 +19,25 @@ use std::hash::Hash;
18use std::ops::Deref; 19use std::ops::Deref;
19use std::path::{Path, PathBuf}; 20use std::path::{Path, PathBuf};
20use std::process::Command; 21use std::process::Command;
21use std::time::{Instant, Duration}; 22use std::time::{Duration, Instant};
22use std::collections::HashMap;
23 23
24use cache::{Cache, Interned, INTERNER};
25use check;
24use compile; 26use compile;
25use install;
26use dist; 27use dist;
27use util::{exe, libdir, add_lib_path};
28use {Build, Mode, DocTests};
29use cache::{INTERNER, Interned, Cache};
30use check;
31use test;
32use flags::Subcommand;
33use doc; 28use doc;
34use tool; 29use flags::Subcommand;
30use install;
35use native; 31use native;
32use test;
33use tool;
34use util::{add_lib_path, exe, libdir};
35use {Build, DocTests, Mode};
36 36
37pub use Compiler; 37pub use Compiler;
38 38
39use petgraph::Graph;
40use petgraph::graph::NodeIndex; 39use petgraph::graph::NodeIndex;
40use petgraph::Graph;
41 41
42pub struct Builder<'a> { 42pub struct Builder<'a> {
43 pub build: &'a Build, 43 pub build: &'a Build,
@@ -112,8 +112,8 @@ struct StepDescription {
112 112
113#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)] 113#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)]
114pub enum PathSet { 114pub enum PathSet {
115 Set (BTreeSet<PathBuf>), 115 Set(BTreeSet<PathBuf>),
116 Suite (PathBuf) 116 Suite(PathBuf),
117} 117}
118 118
119impl PathSet { 119impl PathSet {
@@ -130,14 +130,18 @@ impl PathSet {
130 fn has(&self, needle: &Path) -> bool { 130 fn has(&self, needle: &Path) -> bool {
131 match self { 131 match self {
132 PathSet::Set(set) => set.iter().any(|p| p.ends_with(needle)), 132 PathSet::Set(set) => set.iter().any(|p| p.ends_with(needle)),
133 PathSet::Suite(_) => false 133 PathSet::Suite(_) => false,
134 } 134 }
135 } 135 }
136 136
137 fn path(&self, builder: &Builder) -> PathBuf { 137 fn path(&self, builder: &Builder) -> PathBuf {
138 match self { 138 match self {
139 PathSet::Set(set) => set.iter().next().unwrap_or(&builder.build.src).to_path_buf(), 139 PathSet::Set(set) => set
140 PathSet::Suite(path) => PathBuf::from(path) 140 .iter()
141 .next()
142 .unwrap_or(&builder.build.src)
143 .to_path_buf(),
144 PathSet::Suite(path) => PathBuf::from(path),
141 } 145 }
142 } 146 }
143} 147}
@@ -158,8 +162,10 @@ impl StepDescription {
158 eprintln!("Skipping {:?} because it is excluded", pathset); 162 eprintln!("Skipping {:?} because it is excluded", pathset);
159 return; 163 return;
160 } else if !builder.config.exclude.is_empty() { 164 } else if !builder.config.exclude.is_empty() {
161 eprintln!("{:?} not skipped for {:?} -- not in {:?}", pathset, 165 eprintln!(
162 self.name, builder.config.exclude); 166 "{:?} not skipped for {:?} -- not in {:?}",
167 pathset, self.name, builder.config.exclude
168 );
163 } 169 }
164 let hosts = &builder.hosts; 170 let hosts = &builder.hosts;
165 171
@@ -188,14 +194,18 @@ impl StepDescription {
188 } 194 }
189 195
190 fn run(v: &[StepDescription], builder: &Builder, paths: &[PathBuf]) { 196 fn run(v: &[StepDescription], builder: &Builder, paths: &[PathBuf]) {
191 let should_runs = v.iter().map(|desc| { 197 let should_runs = v
192 (desc.should_run)(ShouldRun::new(builder)) 198 .iter()
193 }).collect::<Vec<_>>(); 199 .map(|desc| (desc.should_run)(ShouldRun::new(builder)))
200 .collect::<Vec<_>>();
194 201
195 // sanity checks on rules 202 // sanity checks on rules
196 for (desc, should_run) in v.iter().zip(&should_runs) { 203 for (desc, should_run) in v.iter().zip(&should_runs) {
197 assert!(!should_run.paths.is_empty(), 204 assert!(
198 "{:?} should have at least one pathset", desc.name); 205 !should_run.paths.is_empty(),
206 "{:?} should have at least one pathset",
207 desc.name
208 );
199 } 209 }
200 210
201 if paths.is_empty() { 211 if paths.is_empty() {
@@ -278,16 +288,15 @@ impl<'a> ShouldRun<'a> {
278 288
279 // multiple aliases for the same job 289 // multiple aliases for the same job
280 pub fn paths(mut self, paths: &[&str]) -> Self { 290 pub fn paths(mut self, paths: &[&str]) -> Self {
281 self.paths.insert(PathSet::Set(paths.iter().map(PathBuf::from).collect())); 291 self.paths
292 .insert(PathSet::Set(paths.iter().map(PathBuf::from).collect()));
282 self 293 self
283 } 294 }
284 295
285 pub fn is_suite_path(&self, path: &Path) -> Option<&PathSet> { 296 pub fn is_suite_path(&self, path: &Path) -> Option<&PathSet> {
286 self.paths.iter().find(|pathset| { 297 self.paths.iter().find(|pathset| match pathset {
287 match pathset { 298 PathSet::Suite(p) => path.starts_with(p),
288 PathSet::Suite(p) => path.starts_with(p), 299 PathSet::Set(_) => false,
289 PathSet::Set(_) => false
290 }
291 }) 300 })
292 } 301 }
293 302
@@ -326,40 +335,135 @@ impl<'a> Builder<'a> {
326 }}; 335 }};
327 } 336 }
328 match kind { 337 match kind {
329 Kind::Build => describe!(compile::Std, compile::Test, compile::Rustc, 338 Kind::Build => describe!(
330 compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex, 339 compile::Std,
331 tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest, 340 compile::Test,
332 tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient, 341 compile::Rustc,
333 tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy, 342 compile::StartupObjects,
334 native::Llvm, tool::Rustfmt, tool::Miri, native::Lld), 343 tool::BuildManifest,
335 Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend, 344 tool::Rustbook,
336 check::Rustdoc), 345 tool::ErrorIndex,
337 Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass, 346 tool::UnstableBookGen,
338 test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind, 347 tool::Tidy,
339 test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo, 348 tool::Linkchecker,
340 test::UiFullDeps, test::RunPassFullDeps, test::RunFailFullDeps, 349 tool::CargoTest,
341 test::CompileFailFullDeps, test::IncrementalFullDeps, test::Rustdoc, test::Pretty, 350 tool::Compiletest,
342 test::RunPassPretty, test::RunFailPretty, test::RunPassValgrindPretty, 351 tool::RemoteTestServer,
343 test::RunPassFullDepsPretty, test::RunFailFullDepsPretty, 352 tool::RemoteTestClient,
344 test::Crate, test::CrateLibrustc, test::CrateRustdoc, test::Linkcheck, 353 tool::RustInstaller,
345 test::Cargotest, test::Cargo, test::Rls, test::ErrorIndex, test::Distcheck, 354 tool::Cargo,
355 tool::Rls,
356 tool::Rustdoc,
357 tool::Clippy,
358 native::Llvm,
359 tool::Rustfmt,
360 tool::Miri,
361 native::Lld
362 ),
363 Kind::Check => describe!(
364 check::Std,
365 check::Test,
366 check::Rustc,
367 check::CodegenBackend,
368 check::Rustdoc
369 ),
370 Kind::Test => describe!(
371 test::Tidy,
372 test::Bootstrap,
373 test::Ui,
374 test::RunPass,
375 test::CompileFail,
376 test::ParseFail,
377 test::RunFail,
378 test::RunPassValgrind,
379 test::MirOpt,
380 test::Codegen,
381 test::CodegenUnits,
382 test::Incremental,
383 test::Debuginfo,
384 test::UiFullDeps,
385 test::RunPassFullDeps,
386 test::RunFailFullDeps,
387 test::CompileFailFullDeps,
388 test::IncrementalFullDeps,
389 test::Rustdoc,
390 test::Pretty,
391 test::RunPassPretty,
392 test::RunFailPretty,
393 test::RunPassValgrindPretty,
394 test::RunPassFullDepsPretty,
395 test::RunFailFullDepsPretty,
396 test::Crate,
397 test::CrateLibrustc,
398 test::CrateRustdoc,
399 test::Linkcheck,
400 test::Cargotest,
401 test::Cargo,
402 test::Rls,
403 test::ErrorIndex,
404 test::Distcheck,
346 test::RunMakeFullDeps, 405 test::RunMakeFullDeps,
347 test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample, 406 test::Nomicon,
348 test::TheBook, test::UnstableBook, test::RustcBook, 407 test::Reference,
349 test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme, 408 test::RustdocBook,
409 test::RustByExample,
410 test::TheBook,
411 test::UnstableBook,
412 test::RustcBook,
413 test::Rustfmt,
414 test::Miri,
415 test::Clippy,
416 test::RustdocJS,
417 test::RustdocTheme,
350 // Run run-make last, since these won't pass without make on Windows 418 // Run run-make last, since these won't pass without make on Windows
351 test::RunMake, test::RustdocUi), 419 test::RunMake,
420 test::RustdocUi
421 ),
352 Kind::Bench => describe!(test::Crate, test::CrateLibrustc), 422 Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
353 Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook, 423 Kind::Doc => describe!(
354 doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc, 424 doc::UnstableBook,
355 doc::Rustdoc, doc::ErrorIndex, doc::Nomicon, doc::Reference, doc::RustdocBook, 425 doc::UnstableBookGen,
356 doc::RustByExample, doc::RustcBook, doc::CargoBook), 426 doc::TheBook,
357 Kind::Dist => describe!(dist::Docs, dist::RustcDocs, dist::Mingw, dist::Rustc, 427 doc::Standalone,
358 dist::DebuggerScripts, dist::Std, dist::Analysis, dist::Src, 428 doc::Std,
359 dist::PlainSourceTarball, dist::Cargo, dist::Rls, dist::Rustfmt, dist::Extended, 429 doc::Test,
360 dist::HashSign), 430 doc::WhitelistedRustc,
361 Kind::Install => describe!(install::Docs, install::Std, install::Cargo, install::Rls, 431 doc::Rustc,
362 install::Rustfmt, install::Analysis, install::Src, install::Rustc), 432 doc::Rustdoc,
433 doc::ErrorIndex,
434 doc::Nomicon,
435 doc::Reference,
436 doc::RustdocBook,
437 doc::RustByExample,
438 doc::RustcBook,
439 doc::CargoBook
440 ),
441 Kind::Dist => describe!(
442 dist::Docs,
443 dist::RustcDocs,
444 dist::Mingw,
445 dist::Rustc,
446 dist::DebuggerScripts,
447 dist::Std,
448 dist::Analysis,
449 dist::Src,
450 dist::PlainSourceTarball,
451 dist::Cargo,
452 dist::Rls,
453 dist::Rustfmt,
454 dist::Extended,
455 dist::HashSign
456 ),
457 Kind::Install => describe!(
458 install::Docs,
459 install::Std,
460 install::Cargo,
461 install::Rls,
462 install::Rustfmt,
463 install::Analysis,
464 install::Src,
465 install::Rustc
466 ),
363 } 467 }
364 } 468 }
365 469
@@ -394,10 +498,12 @@ impl<'a> Builder<'a> {
394 } 498 }
395 let mut help = String::from("Available paths:\n"); 499 let mut help = String::from("Available paths:\n");
396 for pathset in should_run.paths { 500 for pathset in should_run.paths {
397 if let PathSet::Set(set) = pathset{ 501 if let PathSet::Set(set) = pathset {
398 set.iter().for_each(|path| help.push_str( 502 set.iter().for_each(|path| {
399 format!(" ./x.py {} {}\n", subcommand, path.display()).as_str() 503 help.push_str(
400 )) 504 format!(" ./x.py {} {}\n", subcommand, path.display()).as_str(),
505 )
506 })
401 } 507 }
402 } 508 }
403 Some(help) 509 Some(help)
@@ -428,11 +534,13 @@ impl<'a> Builder<'a> {
428 parent: Cell::new(None), 534 parent: Cell::new(None),
429 }; 535 };
430 536
431
432 if kind == Kind::Dist { 537 if kind == Kind::Dist {
433 assert!(!builder.config.test_miri, "Do not distribute with miri enabled.\n\ 538 assert!(
539 !builder.config.test_miri,
540 "Do not distribute with miri enabled.\n\
434 The distributed libraries would include all MIR (increasing binary size). 541 The distributed libraries would include all MIR (increasing binary size).
435 The distributed MIR would include validation statements."); 542 The distributed MIR would include validation statements."
543 );
436 } 544 }
437 545
438 builder 546 builder
@@ -457,7 +565,9 @@ impl<'a> Builder<'a> {
457 /// obtained through this function, since it ensures that they are valid 565 /// obtained through this function, since it ensures that they are valid
458 /// (i.e., built and assembled). 566 /// (i.e., built and assembled).
459 pub fn compiler(&self, stage: u32, host: Interned<String>) -> Compiler { 567 pub fn compiler(&self, stage: u32, host: Interned<String>) -> Compiler {
460 self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } }) 568 self.ensure(compile::Assemble {
569 target_compiler: Compiler { stage, host },
570 })
461 } 571 }
462 572
463 pub fn sysroot(&self, compiler: Compiler) -> Interned<PathBuf> { 573 pub fn sysroot(&self, compiler: Compiler) -> Interned<PathBuf> {
@@ -467,7 +577,9 @@ impl<'a> Builder<'a> {
467 /// Returns the libdir where the standard library and other artifacts are 577 /// Returns the libdir where the standard library and other artifacts are
468 /// found for a compiler's sysroot. 578 /// found for a compiler's sysroot.
469 pub fn sysroot_libdir( 579 pub fn sysroot_libdir(
470 &self, compiler: Compiler, target: Interned<String> 580 &self,
581 compiler: Compiler,
582 target: Interned<String>,
471 ) -> Interned<PathBuf> { 583 ) -> Interned<PathBuf> {
472 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] 584 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
473 struct Libdir { 585 struct Libdir {
@@ -489,8 +601,12 @@ impl<'a> Builder<'a> {
489 } else { 601 } else {
490 Path::new("lib") 602 Path::new("lib")
491 }; 603 };
492 let sysroot = builder.sysroot(self.compiler).join(lib) 604 let sysroot = builder
493 .join("rustlib").join(self.target).join("lib"); 605 .sysroot(self.compiler)
606 .join(lib)
607 .join("rustlib")
608 .join(self.target)
609 .join("lib");
494 let _ = fs::remove_dir_all(&sysroot); 610 let _ = fs::remove_dir_all(&sysroot);
495 t!(fs::create_dir_all(&sysroot)); 611 t!(fs::create_dir_all(&sysroot));
496 INTERNER.intern_path(sysroot) 612 INTERNER.intern_path(sysroot)
@@ -524,7 +640,7 @@ impl<'a> Builder<'a> {
524 // compiler live next to the compiler and the system will find them 640 // compiler live next to the compiler and the system will find them
525 // automatically. 641 // automatically.
526 if cfg!(windows) { 642 if cfg!(windows) {
527 return 643 return;
528 } 644 }
529 645
530 add_lib_path(vec![self.rustc_libdir(compiler)], cmd); 646 add_lib_path(vec![self.rustc_libdir(compiler)], cmd);
@@ -535,7 +651,9 @@ impl<'a> Builder<'a> {
535 if compiler.is_snapshot(self) { 651 if compiler.is_snapshot(self) {
536 self.initial_rustc.clone() 652 self.initial_rustc.clone()
537 } else { 653 } else {
538 self.sysroot(compiler).join("bin").join(exe("rustc", &compiler.host)) 654 self.sysroot(compiler)
655 .join("bin")
656 .join(exe("rustc", &compiler.host))
539 } 657 }
540 } 658 }
541 659
@@ -547,12 +665,15 @@ impl<'a> Builder<'a> {
547 let mut cmd = Command::new(&self.out.join("bootstrap/debug/rustdoc")); 665 let mut cmd = Command::new(&self.out.join("bootstrap/debug/rustdoc"));
548 let compiler = self.compiler(self.top_stage, host); 666 let compiler = self.compiler(self.top_stage, host);
549 cmd.env("RUSTC_STAGE", compiler.stage.to_string()) 667 cmd.env("RUSTC_STAGE", compiler.stage.to_string())
550 .env("RUSTC_SYSROOT", self.sysroot(compiler)) 668 .env("RUSTC_SYSROOT", self.sysroot(compiler))
551 .env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build)) 669 .env(
552 .env("CFG_RELEASE_CHANNEL", &self.config.channel) 670 "RUSTDOC_LIBDIR",
553 .env("RUSTDOC_REAL", self.rustdoc(host)) 671 self.sysroot_libdir(compiler, self.config.build),
554 .env("RUSTDOC_CRATE_VERSION", self.rust_version()) 672 )
555 .env("RUSTC_BOOTSTRAP", "1"); 673 .env("CFG_RELEASE_CHANNEL", &self.config.channel)
674 .env("RUSTDOC_REAL", self.rustdoc(host))
675 .env("RUSTDOC_CRATE_VERSION", self.rust_version())
676 .env("RUSTC_BOOTSTRAP", "1");
556 if let Some(linker) = self.linker(host) { 677 if let Some(linker) = self.linker(host) {
557 cmd.env("RUSTC_TARGET_LINKER", linker); 678 cmd.env("RUSTC_TARGET_LINKER", linker);
558 } 679 }
@@ -566,17 +687,20 @@ impl<'a> Builder<'a> {
566 /// rustc compiler, its output will be scoped by `mode`'s output directory, 687 /// rustc compiler, its output will be scoped by `mode`'s output directory,
567 /// it will pass the `--target` flag for the specified `target`, and will be 688 /// it will pass the `--target` flag for the specified `target`, and will be
568 /// executing the Cargo command `cmd`. 689 /// executing the Cargo command `cmd`.
569 pub fn cargo(&self, 690 pub fn cargo(
570 compiler: Compiler, 691 &self,
571 mode: Mode, 692 compiler: Compiler,
572 target: Interned<String>, 693 mode: Mode,
573 cmd: &str) -> Command { 694 target: Interned<String>,
695 cmd: &str,
696 ) -> Command {
574 let mut cargo = Command::new(&self.initial_cargo); 697 let mut cargo = Command::new(&self.initial_cargo);
575 let out_dir = self.stage_out(compiler, mode); 698 let out_dir = self.stage_out(compiler, mode);
576 cargo.env("CARGO_TARGET_DIR", out_dir) 699 cargo
577 .arg(cmd) 700 .env("CARGO_TARGET_DIR", out_dir)
578 .arg("--target") 701 .arg(cmd)
579 .arg(target); 702 .arg("--target")
703 .arg(target);
580 704
581 // Set a flag for `check` so that certain build scripts can do less work 705 // Set a flag for `check` so that certain build scripts can do less work
582 // (e.g. not building/requiring LLVM). 706 // (e.g. not building/requiring LLVM).
@@ -619,8 +743,14 @@ impl<'a> Builder<'a> {
619 } 743 }
620 744
621 if !extra_args.is_empty() { 745 if !extra_args.is_empty() {
622 cargo.env("RUSTFLAGS", 746 cargo.env(
623 format!("{} {}", env::var("RUSTFLAGS").unwrap_or_default(), extra_args)); 747 "RUSTFLAGS",
748 format!(
749 "{} {}",
750 env::var("RUSTFLAGS").unwrap_or_default(),
751 extra_args
752 ),
753 );
624 } 754 }
625 755
626 let want_rustdoc = self.doc_tests != DocTests::No; 756 let want_rustdoc = self.doc_tests != DocTests::No;
@@ -631,23 +761,29 @@ impl<'a> Builder<'a> {
631 // 761 //
632 // These variables are primarily all read by 762 // These variables are primarily all read by
633 // src/bootstrap/bin/{rustc.rs,rustdoc.rs} 763 // src/bootstrap/bin/{rustc.rs,rustdoc.rs}
634 cargo.env("RUSTBUILD_NATIVE_DIR", self.native_dir(target)) 764 cargo
635 .env("RUSTC", self.out.join("bootstrap/debug/rustc")) 765 .env("RUSTBUILD_NATIVE_DIR", self.native_dir(target))
636 .env("RUSTC_REAL", self.rustc(compiler)) 766 .env("RUSTC", self.out.join("bootstrap/debug/rustc"))
637 .env("RUSTC_STAGE", stage.to_string()) 767 .env("RUSTC_REAL", self.rustc(compiler))
638 .env("RUSTC_DEBUG_ASSERTIONS", 768 .env("RUSTC_STAGE", stage.to_string())
639 self.config.rust_debug_assertions.to_string()) 769 .env(
640 .env("RUSTC_SYSROOT", self.sysroot(compiler)) 770 "RUSTC_DEBUG_ASSERTIONS",
641 .env("RUSTC_LIBDIR", self.rustc_libdir(compiler)) 771 self.config.rust_debug_assertions.to_string(),
642 .env("RUSTC_RPATH", self.config.rust_rpath.to_string()) 772 )
643 .env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc")) 773 .env("RUSTC_SYSROOT", self.sysroot(compiler))
644 .env("RUSTDOC_REAL", if cmd == "doc" || (cmd == "test" && want_rustdoc) { 774 .env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
645 self.rustdoc(compiler.host) 775 .env("RUSTC_RPATH", self.config.rust_rpath.to_string())
646 } else { 776 .env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
647 PathBuf::from("/path/to/nowhere/rustdoc/not/required") 777 .env(
648 }) 778 "RUSTDOC_REAL",
649 .env("TEST_MIRI", self.config.test_miri.to_string()) 779 if cmd == "doc" || (cmd == "test" && want_rustdoc) {
650 .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir()); 780 self.rustdoc(compiler.host)
781 } else {
782 PathBuf::from("/path/to/nowhere/rustdoc/not/required")
783 },
784 )
785 .env("TEST_MIRI", self.config.test_miri.to_string())
786 .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
651 787
652 if let Some(host_linker) = self.linker(compiler.host) { 788 if let Some(host_linker) = self.linker(compiler.host) {
653 cargo.env("RUSTC_HOST_LINKER", host_linker); 789 cargo.env("RUSTC_HOST_LINKER", host_linker);
@@ -659,7 +795,10 @@ impl<'a> Builder<'a> {
659 cargo.env("RUSTC_ERROR_FORMAT", error_format); 795 cargo.env("RUSTC_ERROR_FORMAT", error_format);
660 } 796 }
661 if cmd != "build" && cmd != "check" && want_rustdoc { 797 if cmd != "build" && cmd != "check" && want_rustdoc {
662 cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build))); 798 cargo.env(
799 "RUSTDOC_LIBDIR",
800 self.rustc_libdir(self.compiler(2, self.config.build)),
801 );
663 } 802 }
664 803
665 if mode == Mode::Tool { 804 if mode == Mode::Tool {
@@ -667,11 +806,17 @@ impl<'a> Builder<'a> {
667 // enabled in the config. Adding debuginfo makes them several times larger. 806 // enabled in the config. Adding debuginfo makes them several times larger.
668 if self.config.rust_debuginfo_tools { 807 if self.config.rust_debuginfo_tools {
669 cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()); 808 cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
670 cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string()); 809 cargo.env(
810 "RUSTC_DEBUGINFO_LINES",
811 self.config.rust_debuginfo_lines.to_string(),
812 );
671 } 813 }
672 } else { 814 } else {
673 cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()); 815 cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
674 cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string()); 816 cargo.env(
817 "RUSTC_DEBUGINFO_LINES",
818 self.config.rust_debuginfo_lines.to_string(),
819 );
675 cargo.env("RUSTC_FORCE_UNSTABLE", "1"); 820 cargo.env("RUSTC_FORCE_UNSTABLE", "1");
676 821
677 // Currently the compiler depends on crates from crates.io, and 822 // Currently the compiler depends on crates from crates.io, and
@@ -718,11 +863,13 @@ impl<'a> Builder<'a> {
718 // If LLVM support is disabled we need to use the snapshot compiler to compile 863 // If LLVM support is disabled we need to use the snapshot compiler to compile
719 // build scripts, as the new compiler doesn't support executables. 864 // build scripts, as the new compiler doesn't support executables.
720 if mode == Mode::Libstd || !self.config.llvm_enabled { 865 if mode == Mode::Libstd || !self.config.llvm_enabled {
721 cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc) 866 cargo
722 .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir()); 867 .env("RUSTC_SNAPSHOT", &self.initial_rustc)
868 .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
723 } else { 869 } else {
724 cargo.env("RUSTC_SNAPSHOT", self.rustc(compiler)) 870 cargo
725 .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler)); 871 .env("RUSTC_SNAPSHOT", self.rustc(compiler))
872 .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler));
726 } 873 }
727 874
728 // Ignore incremental modes except for stage0, since we're 875 // Ignore incremental modes except for stage0, since we're
@@ -780,32 +927,36 @@ impl<'a> Builder<'a> {
780 } 927 }
781 }; 928 };
782 let cc = ccacheify(&self.cc(target)); 929 let cc = ccacheify(&self.cc(target));
783 cargo.env(format!("CC_{}", target), &cc) 930 cargo.env(format!("CC_{}", target), &cc).env("CC", &cc);
784 .env("CC", &cc);
785 931
786 let cflags = self.cflags(target).join(" "); 932 let cflags = self.cflags(target).join(" ");
787 cargo.env(format!("CFLAGS_{}", target), cflags.clone()) 933 cargo
788 .env("CFLAGS", cflags.clone()); 934 .env(format!("CFLAGS_{}", target), cflags.clone())
935 .env("CFLAGS", cflags.clone());
789 936
790 if let Some(ar) = self.ar(target) { 937 if let Some(ar) = self.ar(target) {
791 let ranlib = format!("{} s", ar.display()); 938 let ranlib = format!("{} s", ar.display());
792 cargo.env(format!("AR_{}", target), ar) 939 cargo
793 .env("AR", ar) 940 .env(format!("AR_{}", target), ar)
794 .env(format!("RANLIB_{}", target), ranlib.clone()) 941 .env("AR", ar)
795 .env("RANLIB", ranlib); 942 .env(format!("RANLIB_{}", target), ranlib.clone())
943 .env("RANLIB", ranlib);
796 } 944 }
797 945
798 if let Ok(cxx) = self.cxx(target) { 946 if let Ok(cxx) = self.cxx(target) {
799 let cxx = ccacheify(&cxx); 947 let cxx = ccacheify(&cxx);
800 cargo.env(format!("CXX_{}", target), &cxx) 948 cargo
801 .env("CXX", &cxx) 949 .env(format!("CXX_{}", target), &cxx)
802 .env(format!("CXXFLAGS_{}", target), cflags.clone()) 950 .env("CXX", &cxx)
803 .env("CXXFLAGS", cflags); 951 .env(format!("CXXFLAGS_{}", target), cflags.clone())
952 .env("CXXFLAGS", cflags);
804 } 953 }
805 } 954 }
806 955
807 if cmd == "build" && mode == Mode::Libstd 956 if cmd == "build"
808 && self.config.extended && compiler.is_final_stage(self) 957 && mode == Mode::Libstd
958 && self.config.extended
959 && compiler.is_final_stage(self)
809 { 960 {
810 cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string()); 961 cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
811 } 962 }
@@ -893,7 +1044,10 @@ impl<'a> Builder<'a> {
893 let mut stack = self.stack.borrow_mut(); 1044 let mut stack = self.stack.borrow_mut();
894 for stack_step in stack.iter() { 1045 for stack_step in stack.iter() {
895 // should skip 1046 // should skip
896 if stack_step.downcast_ref::<S>().map_or(true, |stack_step| *stack_step != step) { 1047 if stack_step
1048 .downcast_ref::<S>()
1049 .map_or(true, |stack_step| *stack_step != step)
1050 {
897 continue; 1051 continue;
898 } 1052 }
899 let mut out = String::new(); 1053 let mut out = String::new();
@@ -909,7 +1063,9 @@ impl<'a> Builder<'a> {
909 { 1063 {
910 let mut graph = self.graph.borrow_mut(); 1064 let mut graph = self.graph.borrow_mut();
911 let parent = self.parent.get(); 1065 let parent = self.parent.get();
912 let us = *self.graph_nodes.borrow_mut() 1066 let us = *self
1067 .graph_nodes
1068 .borrow_mut()
913 .entry(format!("{:?}", step)) 1069 .entry(format!("{:?}", step))
914 .or_insert_with(|| graph.add_node(format!("{:?}", step))); 1070 .or_insert_with(|| graph.add_node(format!("{:?}", step)));
915 if let Some(parent) = parent { 1071 if let Some(parent) = parent {
@@ -928,7 +1084,9 @@ impl<'a> Builder<'a> {
928 { 1084 {
929 let mut graph = self.graph.borrow_mut(); 1085 let mut graph = self.graph.borrow_mut();
930 let parent = self.parent.get(); 1086 let parent = self.parent.get();
931 let us = *self.graph_nodes.borrow_mut() 1087 let us = *self
1088 .graph_nodes
1089 .borrow_mut()
932 .entry(format!("{:?}", step)) 1090 .entry(format!("{:?}", step))
933 .or_insert_with(|| graph.add_node(format!("{:?}", step))); 1091 .or_insert_with(|| graph.add_node(format!("{:?}", step)));
934 self.parent.set(Some(us)); 1092 self.parent.set(Some(us));
@@ -950,10 +1108,12 @@ impl<'a> Builder<'a> {
950 self.parent.set(prev_parent); 1108 self.parent.set(prev_parent);
951 1109
952 if self.config.print_step_timings && dur > Duration::from_millis(100) { 1110 if self.config.print_step_timings && dur > Duration::from_millis(100) {
953 println!("[TIMING] {:?} -- {}.{:03}", 1111 println!(
954 step, 1112 "[TIMING] {:?} -- {}.{:03}",
955 dur.as_secs(), 1113 step,
956 dur.subsec_nanos() / 1_000_000); 1114 dur.as_secs(),
1115 dur.subsec_nanos() / 1_000_000
1116 );
957 } 1117 }
958 1118
959 { 1119 {
@@ -961,7 +1121,11 @@ impl<'a> Builder<'a> {
961 let cur_step = stack.pop().expect("step stack empty"); 1121 let cur_step = stack.pop().expect("step stack empty");
962 assert_eq!(cur_step.downcast_ref(), Some(&step)); 1122 assert_eq!(cur_step.downcast_ref(), Some(&step));
963 } 1123 }
964 self.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)); 1124 self.verbose(&format!(
1125 "{}< {:?}",
1126 " ".repeat(self.stack.borrow().len()),
1127 step
1128 ));
965 self.cache.put(step, out.clone()); 1129 self.cache.put(step, out.clone());
966 out 1130 out
967 } 1131 }
@@ -969,9 +1133,9 @@ impl<'a> Builder<'a> {
969 1133
970#[cfg(test)] 1134#[cfg(test)]
971mod __test { 1135mod __test {
1136 use super::*;
972 use config::Config; 1137 use config::Config;
973 use std::thread; 1138 use std::thread;
974 use super::*;
975 1139
976 fn configure(host: &[&str], target: &[&str]) -> Config { 1140 fn configure(host: &[&str], target: &[&str]) -> Config {
977 let mut config = Config::default_opts(); 1141 let mut config = Config::default_opts();
@@ -980,15 +1144,26 @@ mod __test {
980 config.run_host_only = true; 1144 config.run_host_only = true;
981 config.dry_run = true; 1145 config.dry_run = true;
982 // try to avoid spurious failures in dist where we create/delete each others file 1146 // try to avoid spurious failures in dist where we create/delete each others file
983 let dir = config.out.join("tmp-rustbuild-tests") 1147 let dir = config.out.join("tmp-rustbuild-tests").join(
984 .join(&thread::current().name().unwrap_or("unknown").replace(":", "-")); 1148 &thread::current()
1149 .name()
1150 .unwrap_or("unknown")
1151 .replace(":", "-"),
1152 );
985 t!(fs::create_dir_all(&dir)); 1153 t!(fs::create_dir_all(&dir));
986 config.out = dir; 1154 config.out = dir;
987 config.build = INTERNER.intern_str("A"); 1155 config.build = INTERNER.intern_str("A");
988 config.hosts = vec![config.build].clone().into_iter() 1156 config.hosts = vec![config.build]
989 .chain(host.iter().map(|s| INTERNER.intern_str(s))).collect::<Vec<_>>(); 1157 .clone()
990 config.targets = config.hosts.clone().into_iter() 1158 .into_iter()
991 .chain(target.iter().map(|s| INTERNER.intern_str(s))).collect::<Vec<_>>(); 1159 .chain(host.iter().map(|s| INTERNER.intern_str(s)))
1160 .collect::<Vec<_>>();
1161 config.targets = config
1162 .hosts
1163 .clone()
1164 .into_iter()
1165 .chain(target.iter().map(|s| INTERNER.intern_str(s)))
1166 .collect::<Vec<_>>();
992 config 1167 config
993 } 1168 }
994 1169
@@ -1004,21 +1179,27 @@ mod __test {
1004 1179
1005 let a = INTERNER.intern_str("A"); 1180 let a = INTERNER.intern_str("A");
1006 1181
1007 assert_eq!(first(builder.cache.all::<dist::Docs>()), &[ 1182 assert_eq!(
1008 dist::Docs { stage: 2, host: a }, 1183 first(builder.cache.all::<dist::Docs>()),
1009 ]); 1184 &[dist::Docs { stage: 2, host: a },]
1010 assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[ 1185 );
1011 dist::Mingw { host: a }, 1186 assert_eq!(
1012 ]); 1187 first(builder.cache.all::<dist::Mingw>()),
1013 assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[ 1188 &[dist::Mingw { host: a },]
1014 dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, 1189 );
1015 ]); 1190 assert_eq!(
1016 assert_eq!(first(builder.cache.all::<dist::Std>()), &[ 1191 first(builder.cache.all::<dist::Rustc>()),
1017 dist::Std { 1192 &[dist::Rustc {
1193 compiler: Compiler { host: a, stage: 2 }
1194 },]
1195 );
1196 assert_eq!(
1197 first(builder.cache.all::<dist::Std>()),
1198 &[dist::Std {
1018 compiler: Compiler { host: a, stage: 2 }, 1199 compiler: Compiler { host: a, stage: 2 },
1019 target: a, 1200 target: a,
1020 }, 1201 },]
1021 ]); 1202 );
1022 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]); 1203 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
1023 } 1204 }
1024 1205
@@ -1031,27 +1212,36 @@ mod __test {
1031 let a = INTERNER.intern_str("A"); 1212 let a = INTERNER.intern_str("A");
1032 let b = INTERNER.intern_str("B"); 1213 let b = INTERNER.intern_str("B");
1033 1214
1034 assert_eq!(first(builder.cache.all::<dist::Docs>()), &[ 1215 assert_eq!(
1035 dist::Docs { stage: 2, host: a }, 1216 first(builder.cache.all::<dist::Docs>()),
1036 dist::Docs { stage: 2, host: b }, 1217 &[
1037 ]); 1218 dist::Docs { stage: 2, host: a },
1038 assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[ 1219 dist::Docs { stage: 2, host: b },
1039 dist::Mingw { host: a }, 1220 ]
1040 dist::Mingw { host: b }, 1221 );
1041 ]); 1222 assert_eq!(
1042 assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[ 1223 first(builder.cache.all::<dist::Mingw>()),
1043 dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, 1224 &[dist::Mingw { host: a }, dist::Mingw { host: b },]
1044 ]); 1225 );
1045 assert_eq!(first(builder.cache.all::<dist::Std>()), &[ 1226 assert_eq!(
1046 dist::Std { 1227 first(builder.cache.all::<dist::Rustc>()),
1047 compiler: Compiler { host: a, stage: 2 }, 1228 &[dist::Rustc {
1048 target: a, 1229 compiler: Compiler { host: a, stage: 2 }
1049 }, 1230 },]
1050 dist::Std { 1231 );
1051 compiler: Compiler { host: a, stage: 2 }, 1232 assert_eq!(
1052 target: b, 1233 first(builder.cache.all::<dist::Std>()),
1053 }, 1234 &[
1054 ]); 1235 dist::Std {
1236 compiler: Compiler { host: a, stage: 2 },
1237 target: a,
1238 },
1239 dist::Std {
1240 compiler: Compiler { host: a, stage: 2 },
1241 target: b,
1242 },
1243 ]
1244 );
1055 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]); 1245 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
1056 } 1246 }
1057 1247
@@ -1064,28 +1254,41 @@ mod __test {
1064 let a = INTERNER.intern_str("A"); 1254 let a = INTERNER.intern_str("A");
1065 let b = INTERNER.intern_str("B"); 1255 let b = INTERNER.intern_str("B");
1066 1256
1067 assert_eq!(first(builder.cache.all::<dist::Docs>()), &[ 1257 assert_eq!(
1068 dist::Docs { stage: 2, host: a }, 1258 first(builder.cache.all::<dist::Docs>()),
1069 dist::Docs { stage: 2, host: b }, 1259 &[
1070 ]); 1260 dist::Docs { stage: 2, host: a },
1071 assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[ 1261 dist::Docs { stage: 2, host: b },
1072 dist::Mingw { host: a }, 1262 ]
1073 dist::Mingw { host: b }, 1263 );
1074 ]); 1264 assert_eq!(
1075 assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[ 1265 first(builder.cache.all::<dist::Mingw>()),
1076 dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, 1266 &[dist::Mingw { host: a }, dist::Mingw { host: b },]
1077 dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, 1267 );
1078 ]); 1268 assert_eq!(
1079 assert_eq!(first(builder.cache.all::<dist::Std>()), &[ 1269 first(builder.cache.all::<dist::Rustc>()),
1080 dist::Std { 1270 &[
1081 compiler: Compiler { host: a, stage: 2 }, 1271 dist::Rustc {
1082 target: a, 1272 compiler: Compiler { host: a, stage: 2 }
1083 }, 1273 },
1084 dist::Std { 1274 dist::Rustc {
1085 compiler: Compiler { host: a, stage: 2 }, 1275 compiler: Compiler { host: b, stage: 2 }
1086 target: b, 1276 },
1087 }, 1277 ]
1088 ]); 1278 );
1279 assert_eq!(
1280 first(builder.cache.all::<dist::Std>()),
1281 &[
1282 dist::Std {
1283 compiler: Compiler { host: a, stage: 2 },
1284 target: a,
1285 },
1286 dist::Std {
1287 compiler: Compiler { host: a, stage: 2 },
1288 target: b,
1289 },
1290 ]
1291 );
1089 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]); 1292 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
1090 } 1293 }
1091 1294
@@ -1099,34 +1302,50 @@ mod __test {
1099 let b = INTERNER.intern_str("B"); 1302 let b = INTERNER.intern_str("B");
1100 let c = INTERNER.intern_str("C"); 1303 let c = INTERNER.intern_str("C");
1101 1304
1102 assert_eq!(first(builder.cache.all::<dist::Docs>()), &[ 1305 assert_eq!(
1103 dist::Docs { stage: 2, host: a }, 1306 first(builder.cache.all::<dist::Docs>()),
1104 dist::Docs { stage: 2, host: b }, 1307 &[
1105 dist::Docs { stage: 2, host: c }, 1308 dist::Docs { stage: 2, host: a },
1106 ]); 1309 dist::Docs { stage: 2, host: b },
1107 assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[ 1310 dist::Docs { stage: 2, host: c },
1108 dist::Mingw { host: a }, 1311 ]
1109 dist::Mingw { host: b }, 1312 );
1110 dist::Mingw { host: c }, 1313 assert_eq!(
1111 ]); 1314 first(builder.cache.all::<dist::Mingw>()),
1112 assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[ 1315 &[
1113 dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, 1316 dist::Mingw { host: a },
1114 dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, 1317 dist::Mingw { host: b },
1115 ]); 1318 dist::Mingw { host: c },
1116 assert_eq!(first(builder.cache.all::<dist::Std>()), &[ 1319 ]
1117 dist::Std { 1320 );
1118 compiler: Compiler { host: a, stage: 2 }, 1321 assert_eq!(
1119 target: a, 1322 first(builder.cache.all::<dist::Rustc>()),
1120 }, 1323 &[
1121 dist::Std { 1324 dist::Rustc {
1122 compiler: Compiler { host: a, stage: 2 }, 1325 compiler: Compiler { host: a, stage: 2 }
1123 target: b, 1326 },
1124 }, 1327 dist::Rustc {
1125 dist::Std { 1328 compiler: Compiler { host: b, stage: 2 }
1126 compiler: Compiler { host: a, stage: 2 }, 1329 },
1127 target: c, 1330 ]
1128 }, 1331 );
1129 ]); 1332 assert_eq!(
1333 first(builder.cache.all::<dist::Std>()),
1334 &[
1335 dist::Std {
1336 compiler: Compiler { host: a, stage: 2 },
1337 target: a,
1338 },
1339 dist::Std {
1340 compiler: Compiler { host: a, stage: 2 },
1341 target: b,
1342 },
1343 dist::Std {
1344 compiler: Compiler { host: a, stage: 2 },
1345 target: c,
1346 },
1347 ]
1348 );
1130 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]); 1349 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
1131 } 1350 }
1132 1351
@@ -1142,31 +1361,40 @@ mod __test {
1142 let b = INTERNER.intern_str("B"); 1361 let b = INTERNER.intern_str("B");
1143 let c = INTERNER.intern_str("C"); 1362 let c = INTERNER.intern_str("C");
1144 1363
1145 assert_eq!(first(builder.cache.all::<dist::Docs>()), &[ 1364 assert_eq!(
1146 dist::Docs { stage: 2, host: a }, 1365 first(builder.cache.all::<dist::Docs>()),
1147 dist::Docs { stage: 2, host: b }, 1366 &[
1148 dist::Docs { stage: 2, host: c }, 1367 dist::Docs { stage: 2, host: a },
1149 ]); 1368 dist::Docs { stage: 2, host: b },
1150 assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[ 1369 dist::Docs { stage: 2, host: c },
1151 dist::Mingw { host: a }, 1370 ]
1152 dist::Mingw { host: b }, 1371 );
1153 dist::Mingw { host: c }, 1372 assert_eq!(
1154 ]); 1373 first(builder.cache.all::<dist::Mingw>()),
1374 &[
1375 dist::Mingw { host: a },
1376 dist::Mingw { host: b },
1377 dist::Mingw { host: c },
1378 ]
1379 );
1155 assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[]); 1380 assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[]);
1156 assert_eq!(first(builder.cache.all::<dist::Std>()), &[ 1381 assert_eq!(
1157 dist::Std { 1382 first(builder.cache.all::<dist::Std>()),
1158 compiler: Compiler { host: a, stage: 2 }, 1383 &[
1159 target: a, 1384 dist::Std {
1160 }, 1385 compiler: Compiler { host: a, stage: 2 },
1161 dist::Std { 1386 target: a,
1162 compiler: Compiler { host: a, stage: 2 }, 1387 },
1163 target: b, 1388 dist::Std {
1164 }, 1389 compiler: Compiler { host: a, stage: 2 },
1165 dist::Std { 1390 target: b,
1166 compiler: Compiler { host: a, stage: 2 }, 1391 },
1167 target: c, 1392 dist::Std {
1168 }, 1393 compiler: Compiler { host: a, stage: 2 },
1169 ]); 1394 target: c,
1395 },
1396 ]
1397 );
1170 assert_eq!(first(builder.cache.all::<dist::Src>()), &[]); 1398 assert_eq!(first(builder.cache.all::<dist::Src>()), &[]);
1171 } 1399 }
1172 1400
@@ -1179,87 +1407,109 @@ mod __test {
1179 let a = INTERNER.intern_str("A"); 1407 let a = INTERNER.intern_str("A");
1180 let b = INTERNER.intern_str("B"); 1408 let b = INTERNER.intern_str("B");
1181 1409
1182 assert_eq!(first(builder.cache.all::<dist::Docs>()), &[ 1410 assert_eq!(
1183 dist::Docs { stage: 2, host: a }, 1411 first(builder.cache.all::<dist::Docs>()),
1184 dist::Docs { stage: 2, host: b }, 1412 &[
1185 ]); 1413 dist::Docs { stage: 2, host: a },
1186 assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[ 1414 dist::Docs { stage: 2, host: b },
1187 dist::Mingw { host: a }, 1415 ]
1188 dist::Mingw { host: b }, 1416 );
1189 ]); 1417 assert_eq!(
1190 assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[ 1418 first(builder.cache.all::<dist::Mingw>()),
1191 dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, 1419 &[dist::Mingw { host: a }, dist::Mingw { host: b },]
1192 dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, 1420 );
1193 ]); 1421 assert_eq!(
1194 assert_eq!(first(builder.cache.all::<dist::Std>()), &[ 1422 first(builder.cache.all::<dist::Rustc>()),
1195 dist::Std { 1423 &[
1196 compiler: Compiler { host: a, stage: 2 }, 1424 dist::Rustc {
1197 target: a, 1425 compiler: Compiler { host: a, stage: 2 }
1198 }, 1426 },
1199 dist::Std { 1427 dist::Rustc {
1200 compiler: Compiler { host: a, stage: 2 }, 1428 compiler: Compiler { host: b, stage: 2 }
1201 target: b, 1429 },
1202 }, 1430 ]
1203 ]); 1431 );
1432 assert_eq!(
1433 first(builder.cache.all::<dist::Std>()),
1434 &[
1435 dist::Std {
1436 compiler: Compiler { host: a, stage: 2 },
1437 target: a,
1438 },
1439 dist::Std {
1440 compiler: Compiler { host: a, stage: 2 },
1441 target: b,
1442 },
1443 ]
1444 );
1204 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]); 1445 assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
1205 assert_eq!(first(builder.cache.all::<compile::Std>()), &[ 1446 assert_eq!(
1206 compile::Std { 1447 first(builder.cache.all::<compile::Std>()),
1207 compiler: Compiler { host: a, stage: 0 }, 1448 &[
1208 target: a, 1449 compile::Std {
1209 }, 1450 compiler: Compiler { host: a, stage: 0 },
1210 compile::Std { 1451 target: a,
1211 compiler: Compiler { host: a, stage: 1 }, 1452 },
1212 target: a, 1453 compile::Std {
1213 }, 1454 compiler: Compiler { host: a, stage: 1 },
1214 compile::Std { 1455 target: a,
1215 compiler: Compiler { host: a, stage: 2 }, 1456 },
1216 target: a, 1457 compile::Std {
1217 }, 1458 compiler: Compiler { host: a, stage: 2 },
1218 compile::Std { 1459 target: a,
1219 compiler: Compiler { host: a, stage: 1 }, 1460 },
1220 target: b, 1461 compile::Std {
1221 }, 1462 compiler: Compiler { host: a, stage: 1 },
1222 compile::Std { 1463 target: b,
1223 compiler: Compiler { host: a, stage: 2 }, 1464 },
1224 target: b, 1465 compile::Std {
1225 }, 1466 compiler: Compiler { host: a, stage: 2 },
1226 ]); 1467 target: b,
1227 assert_eq!(first(builder.cache.all::<compile::Test>()), &[ 1468 },
1228 compile::Test { 1469 ]
1229 compiler: Compiler { host: a, stage: 0 }, 1470 );
1230 target: a, 1471 assert_eq!(
1231 }, 1472 first(builder.cache.all::<compile::Test>()),
1232 compile::Test { 1473 &[
1233 compiler: Compiler { host: a, stage: 1 }, 1474 compile::Test {
1234 target: a, 1475 compiler: Compiler { host: a, stage: 0 },
1235 }, 1476 target: a,
1236 compile::Test { 1477 },
1237 compiler: Compiler { host: a, stage: 2 }, 1478 compile::Test {
1238 target: a, 1479 compiler: Compiler { host: a, stage: 1 },
1239 }, 1480 target: a,
1240 compile::Test { 1481 },
1241 compiler: Compiler { host: a, stage: 1 }, 1482 compile::Test {
1242 target: b, 1483 compiler: Compiler { host: a, stage: 2 },
1243 }, 1484 target: a,
1244 compile::Test { 1485 },
1245 compiler: Compiler { host: a, stage: 2 }, 1486 compile::Test {
1246 target: b, 1487 compiler: Compiler { host: a, stage: 1 },
1247 }, 1488 target: b,
1248 ]); 1489 },
1249 assert_eq!(first(builder.cache.all::<compile::Assemble>()), &[ 1490 compile::Test {
1250 compile::Assemble { 1491 compiler: Compiler { host: a, stage: 2 },
1251 target_compiler: Compiler { host: a, stage: 0 }, 1492 target: b,
1252 }, 1493 },
1253 compile::Assemble { 1494 ]
1254 target_compiler: Compiler { host: a, stage: 1 }, 1495 );
1255 }, 1496 assert_eq!(
1256 compile::Assemble { 1497 first(builder.cache.all::<compile::Assemble>()),
1257 target_compiler: Compiler { host: a, stage: 2 }, 1498 &[
1258 }, 1499 compile::Assemble {
1259 compile::Assemble { 1500 target_compiler: Compiler { host: a, stage: 0 },
1260 target_compiler: Compiler { host: b, stage: 2 }, 1501 },
1261 }, 1502 compile::Assemble {
1262 ]); 1503 target_compiler: Compiler { host: a, stage: 1 },
1504 },
1505 compile::Assemble {
1506 target_compiler: Compiler { host: a, stage: 2 },
1507 },
1508 compile::Assemble {
1509 target_compiler: Compiler { host: b, stage: 2 },
1510 },
1511 ]
1512 );
1263 } 1513 }
1264 1514
1265 #[test] 1515 #[test]
@@ -1274,83 +1524,89 @@ mod __test {
1274 1524
1275 assert!(!builder.cache.all::<compile::Std>().is_empty()); 1525 assert!(!builder.cache.all::<compile::Std>().is_empty());
1276 assert!(!builder.cache.all::<compile::Assemble>().is_empty()); 1526 assert!(!builder.cache.all::<compile::Assemble>().is_empty());
1277 assert_eq!(first(builder.cache.all::<compile::Rustc>()), &[ 1527 assert_eq!(
1278 compile::Rustc { 1528 first(builder.cache.all::<compile::Rustc>()),
1279 compiler: Compiler { host: a, stage: 0 }, 1529 &[
1280 target: a, 1530 compile::Rustc {
1281 }, 1531 compiler: Compiler { host: a, stage: 0 },
1282 compile::Rustc { 1532 target: a,
1283 compiler: Compiler { host: a, stage: 1 }, 1533 },
1284 target: a, 1534 compile::Rustc {
1285 }, 1535 compiler: Compiler { host: a, stage: 1 },
1286 compile::Rustc { 1536 target: a,
1287 compiler: Compiler { host: a, stage: 2 }, 1537 },
1288 target: a, 1538 compile::Rustc {
1289 }, 1539 compiler: Compiler { host: a, stage: 2 },
1290 compile::Rustc { 1540 target: a,
1291 compiler: Compiler { host: b, stage: 2 }, 1541 },
1292 target: a, 1542 compile::Rustc {
1293 }, 1543 compiler: Compiler { host: b, stage: 2 },
1294 compile::Rustc { 1544 target: a,
1295 compiler: Compiler { host: a, stage: 0 }, 1545 },
1296 target: b, 1546 compile::Rustc {
1297 }, 1547 compiler: Compiler { host: a, stage: 0 },
1298 compile::Rustc { 1548 target: b,
1299 compiler: Compiler { host: a, stage: 1 }, 1549 },
1300 target: b, 1550 compile::Rustc {
1301 }, 1551 compiler: Compiler { host: a, stage: 1 },
1302 compile::Rustc { 1552 target: b,
1303 compiler: Compiler { host: a, stage: 2 }, 1553 },
1304 target: b, 1554 compile::Rustc {
1305 }, 1555 compiler: Compiler { host: a, stage: 2 },
1306 compile::Rustc { 1556 target: b,
1307 compiler: Compiler { host: b, stage: 2 }, 1557 },
1308 target: b, 1558 compile::Rustc {
1309 }, 1559 compiler: Compiler { host: b, stage: 2 },
1310 ]); 1560 target: b,
1311 1561 },
1312 assert_eq!(first(builder.cache.all::<compile::Test>()), &[ 1562 ]
1313 compile::Test { 1563 );
1314 compiler: Compiler { host: a, stage: 0 }, 1564
1315 target: a, 1565 assert_eq!(
1316 }, 1566 first(builder.cache.all::<compile::Test>()),
1317 compile::Test { 1567 &[
1318 compiler: Compiler { host: a, stage: 1 }, 1568 compile::Test {
1319 target: a, 1569 compiler: Compiler { host: a, stage: 0 },
1320 }, 1570 target: a,
1321 compile::Test { 1571 },
1322 compiler: Compiler { host: a, stage: 2 }, 1572 compile::Test {
1323 target: a, 1573 compiler: Compiler { host: a, stage: 1 },
1324 }, 1574 target: a,
1325 compile::Test { 1575 },
1326 compiler: Compiler { host: b, stage: 2 }, 1576 compile::Test {
1327 target: a, 1577 compiler: Compiler { host: a, stage: 2 },
1328 }, 1578 target: a,
1329 compile::Test { 1579 },
1330 compiler: Compiler { host: a, stage: 0 }, 1580 compile::Test {
1331 target: b, 1581 compiler: Compiler { host: b, stage: 2 },
1332 }, 1582 target: a,
1333 compile::Test { 1583 },
1334 compiler: Compiler { host: a, stage: 1 }, 1584 compile::Test {
1335 target: b, 1585 compiler: Compiler { host: a, stage: 0 },
1336 }, 1586 target: b,
1337 compile::Test { 1587 },
1338 compiler: Compiler { host: a, stage: 2 }, 1588 compile::Test {
1339 target: b, 1589 compiler: Compiler { host: a, stage: 1 },
1340 }, 1590 target: b,
1341 compile::Test { 1591 },
1342 compiler: Compiler { host: b, stage: 2 }, 1592 compile::Test {
1343 target: b, 1593 compiler: Compiler { host: a, stage: 2 },
1344 }, 1594 target: b,
1345 compile::Test { 1595 },
1346 compiler: Compiler { host: a, stage: 2 }, 1596 compile::Test {
1347 target: c, 1597 compiler: Compiler { host: b, stage: 2 },
1348 }, 1598 target: b,
1349 compile::Test { 1599 },
1350 compiler: Compiler { host: b, stage: 2 }, 1600 compile::Test {
1351 target: c, 1601 compiler: Compiler { host: a, stage: 2 },
1352 }, 1602 target: c,
1353 ]); 1603 },
1604 compile::Test {
1605 compiler: Compiler { host: b, stage: 2 },
1606 target: c,
1607 },
1608 ]
1609 );
1354 } 1610 }
1355 1611
1356 #[test] 1612 #[test]
@@ -1366,84 +1622,93 @@ mod __test {
1366 let c = INTERNER.intern_str("C"); 1622 let c = INTERNER.intern_str("C");
1367 1623
1368 assert!(!builder.cache.all::<compile::Std>().is_empty()); 1624 assert!(!builder.cache.all::<compile::Std>().is_empty());
1369 assert_eq!(first(builder.cache.all::<compile::Assemble>()), &[ 1625 assert_eq!(
1370 compile::Assemble { 1626 first(builder.cache.all::<compile::Assemble>()),
1371 target_compiler: Compiler { host: a, stage: 0 }, 1627 &[
1372 }, 1628 compile::Assemble {
1373 compile::Assemble { 1629 target_compiler: Compiler { host: a, stage: 0 },
1374 target_compiler: Compiler { host: a, stage: 1 }, 1630 },
1375 }, 1631 compile::Assemble {
1376 compile::Assemble { 1632 target_compiler: Compiler { host: a, stage: 1 },
1377 target_compiler: Compiler { host: b, stage: 1 }, 1633 },
1378 }, 1634 compile::Assemble {
1379 compile::Assemble { 1635 target_compiler: Compiler { host: b, stage: 1 },
1380 target_compiler: Compiler { host: a, stage: 2 }, 1636 },
1381 }, 1637 compile::Assemble {
1382 compile::Assemble { 1638 target_compiler: Compiler { host: a, stage: 2 },
1383 target_compiler: Compiler { host: b, stage: 2 }, 1639 },
1384 }, 1640 compile::Assemble {
1385 ]); 1641 target_compiler: Compiler { host: b, stage: 2 },
1386 assert_eq!(first(builder.cache.all::<compile::Rustc>()), &[ 1642 },
1387 compile::Rustc { 1643 ]
1388 compiler: Compiler { host: a, stage: 0 }, 1644 );
1389 target: a, 1645 assert_eq!(
1390 }, 1646 first(builder.cache.all::<compile::Rustc>()),
1391 compile::Rustc { 1647 &[
1392 compiler: Compiler { host: a, stage: 1 }, 1648 compile::Rustc {
1393 target: a, 1649 compiler: Compiler { host: a, stage: 0 },
1394 }, 1650 target: a,
1395 compile::Rustc { 1651 },
1396 compiler: Compiler { host: a, stage: 0 }, 1652 compile::Rustc {
1397 target: b, 1653 compiler: Compiler { host: a, stage: 1 },
1398 }, 1654 target: a,
1399 compile::Rustc { 1655 },
1400 compiler: Compiler { host: a, stage: 1 }, 1656 compile::Rustc {
1401 target: b, 1657 compiler: Compiler { host: a, stage: 0 },
1402 }, 1658 target: b,
1403 ]); 1659 },
1404 1660 compile::Rustc {
1405 assert_eq!(first(builder.cache.all::<compile::Test>()), &[ 1661 compiler: Compiler { host: a, stage: 1 },
1406 compile::Test { 1662 target: b,
1407 compiler: Compiler { host: a, stage: 0 }, 1663 },
1408 target: a, 1664 ]
1409 }, 1665 );
1410 compile::Test { 1666
1411 compiler: Compiler { host: a, stage: 1 }, 1667 assert_eq!(
1412 target: a, 1668 first(builder.cache.all::<compile::Test>()),
1413 }, 1669 &[
1414 compile::Test { 1670 compile::Test {
1415 compiler: Compiler { host: a, stage: 2 }, 1671 compiler: Compiler { host: a, stage: 0 },
1416 target: a, 1672 target: a,
1417 }, 1673 },
1418 compile::Test { 1674 compile::Test {
1419 compiler: Compiler { host: b, stage: 2 }, 1675 compiler: Compiler { host: a, stage: 1 },
1420 target: a, 1676 target: a,
1421 }, 1677 },
1422 compile::Test { 1678 compile::Test {
1423 compiler: Compiler { host: a, stage: 0 }, 1679 compiler: Compiler { host: a, stage: 2 },
1424 target: b, 1680 target: a,
1425 }, 1681 },
1426 compile::Test { 1682 compile::Test {
1427 compiler: Compiler { host: a, stage: 1 }, 1683 compiler: Compiler { host: b, stage: 2 },
1428 target: b, 1684 target: a,
1429 }, 1685 },
1430 compile::Test { 1686 compile::Test {
1431 compiler: Compiler { host: a, stage: 2 }, 1687 compiler: Compiler { host: a, stage: 0 },
1432 target: b, 1688 target: b,
1433 }, 1689 },
1434 compile::Test { 1690 compile::Test {
1435 compiler: Compiler { host: b, stage: 2 }, 1691 compiler: Compiler { host: a, stage: 1 },
1436 target: b, 1692 target: b,
1437 }, 1693 },
1438 compile::Test { 1694 compile::Test {
1439 compiler: Compiler { host: a, stage: 2 }, 1695 compiler: Compiler { host: a, stage: 2 },
1440 target: c, 1696 target: b,
1441 }, 1697 },
1442 compile::Test { 1698 compile::Test {
1443 compiler: Compiler { host: b, stage: 2 }, 1699 compiler: Compiler { host: b, stage: 2 },
1444 target: c, 1700 target: b,
1445 }, 1701 },
1446 ]); 1702 compile::Test {
1703 compiler: Compiler { host: a, stage: 2 },
1704 target: c,
1705 },
1706 compile::Test {
1707 compiler: Compiler { host: b, stage: 2 },
1708 target: c,
1709 },
1710 ]
1711 );
1447 } 1712 }
1448 1713
1449 #[test] 1714 #[test]
@@ -1472,14 +1737,15 @@ mod __test {
1472 1737
1473 // Ensure we don't build any compiler artifacts. 1738 // Ensure we don't build any compiler artifacts.
1474 assert!(builder.cache.all::<compile::Rustc>().is_empty()); 1739 assert!(builder.cache.all::<compile::Rustc>().is_empty());
1475 assert_eq!(first(builder.cache.all::<test::Crate>()), &[ 1740 assert_eq!(
1476 test::Crate { 1741 first(builder.cache.all::<test::Crate>()),
1742 &[test::Crate {
1477 compiler: Compiler { host, stage: 0 }, 1743 compiler: Compiler { host, stage: 0 },
1478 target: host, 1744 target: host,
1479 mode: Mode::Libstd, 1745 mode: Mode::Libstd,
1480 test_kind: test::TestKind::Test, 1746 test_kind: test::TestKind::Test,
1481 krate: INTERNER.intern_str("std"), 1747 krate: INTERNER.intern_str("std"),
1482 }, 1748 },]
1483 ]); 1749 );
1484 } 1750 }
1485} 1751}
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs
index f1473d1939..e5dceccdf8 100644
--- a/src/bootstrap/flags.rs
+++ b/src/bootstrap/flags.rs
@@ -19,10 +19,10 @@ use std::process;
19 19
20use getopts::Options; 20use getopts::Options;
21 21
22use {Build, DocTests}; 22use builder::Builder;
23use config::Config; 23use config::Config;
24use metadata; 24use metadata;
25use builder::Builder; 25use {Build, DocTests};
26 26
27use cache::{Interned, INTERNER}; 27use cache::{Interned, INTERNER};
28 28
@@ -93,7 +93,8 @@ impl Default for Subcommand {
93impl Flags { 93impl Flags {
94 pub fn parse(args: &[String]) -> Flags { 94 pub fn parse(args: &[String]) -> Flags {
95 let mut extra_help = String::new(); 95 let mut extra_help = String::new();
96 let mut subcommand_help = format!("\ 96 let mut subcommand_help = format!(
97 "\
97Usage: x.py <subcommand> [options] [<paths>...] 98Usage: x.py <subcommand> [options] [<paths>...]
98 99
99Subcommands: 100Subcommands:
@@ -106,7 +107,8 @@ Subcommands:
106 dist Build distribution artifacts 107 dist Build distribution artifacts
107 install Install distribution artifacts 108 install Install distribution artifacts
108 109
109To learn more about a subcommand, run `./x.py <subcommand> -h`"); 110To learn more about a subcommand, run `./x.py <subcommand> -h`"
111 );
110 112
111 let mut opts = Options::new(); 113 let mut opts = Options::new();
112 // Options common to all subcommands 114 // Options common to all subcommands
@@ -124,33 +126,39 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
124 opts.optopt("", "src", "path to the root of the rust checkout", "DIR"); 126 opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
125 opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS"); 127 opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
126 opts.optflag("h", "help", "print this help message"); 128 opts.optflag("h", "help", "print this help message");
127 opts.optopt("", "warnings", "if value is deny, will deny warnings, otherwise use default", 129 opts.optopt(
128 "VALUE"); 130 "",
131 "warnings",
132 "if value is deny, will deny warnings, otherwise use default",
133 "VALUE",
134 );
129 opts.optopt("", "error-format", "rustc error format", "FORMAT"); 135 opts.optopt("", "error-format", "rustc error format", "FORMAT");
130 136
131 // fn usage() 137 // fn usage()
132 let usage = |exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! { 138 let usage =
133 println!("{}", opts.usage(subcommand_help)); 139 |exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! {
134 if !extra_help.is_empty() { 140 println!("{}", opts.usage(subcommand_help));
135 println!("{}", extra_help); 141 if !extra_help.is_empty() {
136 } 142 println!("{}", extra_help);
137 process::exit(exit_code); 143 }
138 }; 144 process::exit(exit_code);
145 };
139 146
140 // We can't use getopt to parse the options until we have completed specifying which 147 // We can't use getopt to parse the options until we have completed specifying which
141 // options are valid, but under the current implementation, some options are conditional on 148 // options are valid, but under the current implementation, some options are conditional on
142 // the subcommand. Therefore we must manually identify the subcommand first, so that we can 149 // the subcommand. Therefore we must manually identify the subcommand first, so that we can
143 // complete the definition of the options. Then we can use the getopt::Matches object from 150 // complete the definition of the options. Then we can use the getopt::Matches object from
144 // there on out. 151 // there on out.
145 let subcommand = args.iter().find(|&s| 152 let subcommand = args.iter().find(|&s| {
146 (s == "build") 153 (s == "build")
147 || (s == "check") 154 || (s == "check")
148 || (s == "test") 155 || (s == "test")
149 || (s == "bench") 156 || (s == "bench")
150 || (s == "doc") 157 || (s == "doc")
151 || (s == "clean") 158 || (s == "clean")
152 || (s == "dist") 159 || (s == "dist")
153 || (s == "install")); 160 || (s == "install")
161 });
154 let subcommand = match subcommand { 162 let subcommand = match subcommand {
155 Some(s) => s, 163 Some(s) => s,
156 None => { 164 None => {
@@ -165,7 +173,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
165 173
166 // Some subcommands get extra options 174 // Some subcommands get extra options
167 match subcommand.as_str() { 175 match subcommand.as_str() {
168 "test" => { 176 "test" => {
169 opts.optflag("", "no-fail-fast", "Run all tests regardless of failure"); 177 opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
170 opts.optmulti("", "test-args", "extra arguments", "ARGS"); 178 opts.optmulti("", "test-args", "extra arguments", "ARGS");
171 opts.optmulti( 179 opts.optmulti(
@@ -176,12 +184,25 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
176 ); 184 );
177 opts.optflag("", "no-doc", "do not run doc tests"); 185 opts.optflag("", "no-doc", "do not run doc tests");
178 opts.optflag("", "doc", "only run doc tests"); 186 opts.optflag("", "doc", "only run doc tests");
179 opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests"); 187 opts.optflag(
180 opts.optopt("", "compare-mode", "mode describing what file the actual ui output will be compared to", "COMPARE MODE"); 188 "",
181 }, 189 "bless",
182 "bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); }, 190 "update all stderr/stdout files of failing ui tests",
183 "clean" => { opts.optflag("", "all", "clean all build artifacts"); }, 191 );
184 _ => { }, 192 opts.optopt(
193 "",
194 "compare-mode",
195 "mode describing what file the actual ui output will be compared to",
196 "COMPARE MODE",
197 );
198 }
199 "bench" => {
200 opts.optmulti("", "test-args", "extra arguments", "ARGS");
201 }
202 "clean" => {
203 opts.optflag("", "all", "clean all build artifacts");
204 }
205 _ => {}
185 }; 206 };
186 207
187 // Done specifying what options are possible, so do the getopts parsing 208 // Done specifying what options are possible, so do the getopts parsing
@@ -201,21 +222,24 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
201 if check_subcommand != subcommand { 222 if check_subcommand != subcommand {
202 pass_sanity_check = false; 223 pass_sanity_check = false;
203 } 224 }
204 }, 225 }
205 None => { 226 None => {
206 pass_sanity_check = false; 227 pass_sanity_check = false;
207 } 228 }
208 } 229 }
209 if !pass_sanity_check { 230 if !pass_sanity_check {
210 println!("{}\n", subcommand_help); 231 println!("{}\n", subcommand_help);
211 println!("Sorry, I couldn't figure out which subcommand you were trying to specify.\n\ 232 println!(
212 You may need to move some options to after the subcommand.\n"); 233 "Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
234 You may need to move some options to after the subcommand.\n"
235 );
213 process::exit(1); 236 process::exit(1);
214 } 237 }
215 // Extra help text for some commands 238 // Extra help text for some commands
216 match subcommand.as_str() { 239 match subcommand.as_str() {
217 "build" => { 240 "build" => {
218 subcommand_help.push_str("\n 241 subcommand_help.push_str(
242 "\n
219Arguments: 243Arguments:
220 This subcommand accepts a number of paths to directories to the crates 244 This subcommand accepts a number of paths to directories to the crates
221 and/or artifacts to compile. For example: 245 and/or artifacts to compile. For example:
@@ -237,10 +261,12 @@ Arguments:
237 This will first build everything once (like --stage 0 without further 261 This will first build everything once (like --stage 0 without further
238 arguments would), and then use the compiler built in stage 0 to build 262 arguments would), and then use the compiler built in stage 0 to build
239 src/libtest and its dependencies. 263 src/libtest and its dependencies.
240 Once this is done, build/$ARCH/stage1 contains a usable compiler."); 264 Once this is done, build/$ARCH/stage1 contains a usable compiler.",
265 );
241 } 266 }
242 "check" => { 267 "check" => {
243 subcommand_help.push_str("\n 268 subcommand_help.push_str(
269 "\n
244Arguments: 270Arguments:
245 This subcommand accepts a number of paths to directories to the crates 271 This subcommand accepts a number of paths to directories to the crates
246 and/or artifacts to compile. For example: 272 and/or artifacts to compile. For example:
@@ -252,10 +278,12 @@ Arguments:
252 also that since we use `cargo check`, by default this will automatically enable incremental 278 also that since we use `cargo check`, by default this will automatically enable incremental
253 compilation, so there's no need to pass it separately, though it won't hurt. We also completely 279 compilation, so there's no need to pass it separately, though it won't hurt. We also completely
254 ignore the stage passed, as there's no way to compile in non-stage 0 without actually building 280 ignore the stage passed, as there's no way to compile in non-stage 0 without actually building
255 the compiler."); 281 the compiler.",
282 );
256 } 283 }
257 "test" => { 284 "test" => {
258 subcommand_help.push_str("\n 285 subcommand_help.push_str(
286 "\n
259Arguments: 287Arguments:
260 This subcommand accepts a number of paths to directories to tests that 288 This subcommand accepts a number of paths to directories to tests that
261 should be compiled and run. For example: 289 should be compiled and run. For example:
@@ -270,10 +298,12 @@ Arguments:
270 compiled and tested. 298 compiled and tested.
271 299
272 ./x.py test 300 ./x.py test
273 ./x.py test --stage 1"); 301 ./x.py test --stage 1",
302 );
274 } 303 }
275 "doc" => { 304 "doc" => {
276 subcommand_help.push_str("\n 305 subcommand_help.push_str(
306 "\n
277Arguments: 307Arguments:
278 This subcommand accepts a number of paths to directories of documentation 308 This subcommand accepts a number of paths to directories of documentation
279 to build. For example: 309 to build. For example:
@@ -285,12 +315,16 @@ Arguments:
285 If no arguments are passed then everything is documented: 315 If no arguments are passed then everything is documented:
286 316
287 ./x.py doc 317 ./x.py doc
288 ./x.py doc --stage 1"); 318 ./x.py doc --stage 1",
319 );
289 } 320 }
290 _ => { } 321 _ => {}
291 }; 322 };
292 // Get any optional paths which occur after the subcommand 323 // Get any optional paths which occur after the subcommand
293 let paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>(); 324 let paths = matches.free[1..]
325 .iter()
326 .map(|p| p.into())
327 .collect::<Vec<PathBuf>>();
294 328
295 let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| { 329 let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
296 if fs::metadata("config.toml").is_ok() { 330 if fs::metadata("config.toml").is_ok() {
@@ -309,9 +343,12 @@ Arguments:
309 let maybe_rules_help = Builder::get_help(&build, subcommand.as_str()); 343 let maybe_rules_help = Builder::get_help(&build, subcommand.as_str());
310 extra_help.push_str(maybe_rules_help.unwrap_or_default().as_str()); 344 extra_help.push_str(maybe_rules_help.unwrap_or_default().as_str());
311 } else if subcommand.as_str() != "clean" { 345 } else if subcommand.as_str() != "clean" {
312 extra_help.push_str(format!( 346 extra_help.push_str(
313 "Run `./x.py {} -h -v` to see a list of available paths.", 347 format!(
314 subcommand).as_str()); 348 "Run `./x.py {} -h -v` to see a list of available paths.",
349 subcommand
350 ).as_str(),
351 );
315 } 352 }
316 353
317 // User passed in -h/--help? 354 // User passed in -h/--help?
@@ -320,38 +357,28 @@ Arguments:
320 } 357 }
321 358
322 let cmd = match subcommand.as_str() { 359 let cmd = match subcommand.as_str() {
323 "build" => { 360 "build" => Subcommand::Build { paths: paths },
324 Subcommand::Build { paths: paths } 361 "check" => Subcommand::Check { paths: paths },
325 } 362 "test" => Subcommand::Test {
326 "check" => { 363 paths,
327 Subcommand::Check { paths: paths } 364 bless: matches.opt_present("bless"),
328 } 365 compare_mode: matches.opt_str("compare-mode"),
329 "test" => { 366 test_args: matches.opt_strs("test-args"),
330 Subcommand::Test { 367 rustc_args: matches.opt_strs("rustc-args"),
331 paths, 368 fail_fast: !matches.opt_present("no-fail-fast"),
332 bless: matches.opt_present("bless"), 369 doc_tests: if matches.opt_present("doc") {
333 compare_mode: matches.opt_str("compare-mode"), 370 DocTests::Only
334 test_args: matches.opt_strs("test-args"), 371 } else if matches.opt_present("no-doc") {
335 rustc_args: matches.opt_strs("rustc-args"), 372 DocTests::No
336 fail_fast: !matches.opt_present("no-fail-fast"), 373 } else {
337 doc_tests: if matches.opt_present("doc") { 374 DocTests::Yes
338 DocTests::Only 375 },
339 } else if matches.opt_present("no-doc") { 376 },
340 DocTests::No 377 "bench" => Subcommand::Bench {
341 } else { 378 paths,
342 DocTests::Yes 379 test_args: matches.opt_strs("test-args"),
343 } 380 },
344 } 381 "doc" => Subcommand::Doc { paths: paths },
345 }
346 "bench" => {
347 Subcommand::Bench {
348 paths,
349 test_args: matches.opt_strs("test-args"),
350 }
351 }
352 "doc" => {
353 Subcommand::Doc { paths: paths }
354 }
355 "clean" => { 382 "clean" => {
356 if paths.len() > 0 { 383 if paths.len() > 0 {
357 println!("\nclean does not take a path argument\n"); 384 println!("\nclean does not take a path argument\n");
@@ -362,22 +389,13 @@ Arguments:
362 all: matches.opt_present("all"), 389 all: matches.opt_present("all"),
363 } 390 }
364 } 391 }
365 "dist" => { 392 "dist" => Subcommand::Dist { paths },
366 Subcommand::Dist { 393 "install" => Subcommand::Install { paths },
367 paths,
368 }
369 }
370 "install" => {
371 Subcommand::Install {
372 paths,
373 }
374 }
375 _ => { 394 _ => {
376 usage(1, &opts, &subcommand_help, &extra_help); 395 usage(1, &opts, &subcommand_help, &extra_help);
377 } 396 }
378 }; 397 };
379 398
380
381 Flags { 399 Flags {
382 verbose: matches.opt_count("verbose"), 400 verbose: matches.opt_count("verbose"),
383 stage: matches.opt_str("stage").map(|j| j.parse().unwrap()), 401 stage: matches.opt_str("stage").map(|j| j.parse().unwrap()),
@@ -386,15 +404,21 @@ Arguments:
386 rustc_error_format: matches.opt_str("error-format"), 404 rustc_error_format: matches.opt_str("error-format"),
387 keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()), 405 keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()),
388 host: split(matches.opt_strs("host")) 406 host: split(matches.opt_strs("host"))
389 .into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(), 407 .into_iter()
408 .map(|x| INTERNER.intern_string(x))
409 .collect::<Vec<_>>(),
390 target: split(matches.opt_strs("target")) 410 target: split(matches.opt_strs("target"))
391 .into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(), 411 .into_iter()
412 .map(|x| INTERNER.intern_string(x))
413 .collect::<Vec<_>>(),
392 config: cfg_file, 414 config: cfg_file,
393 jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()), 415 jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()),
394 cmd, 416 cmd,
395 incremental: matches.opt_present("incremental"), 417 incremental: matches.opt_present("incremental"),
396 exclude: split(matches.opt_strs("exclude")) 418 exclude: split(matches.opt_strs("exclude"))
397 .into_iter().map(|p| p.into()).collect::<Vec<_>>(), 419 .into_iter()
420 .map(|p| p.into())
421 .collect::<Vec<_>>(),
398 warnings: matches.opt_str("warnings").map(|v| v == "deny"), 422 warnings: matches.opt_str("warnings").map(|v| v == "deny"),
399 } 423 }
400 } 424 }
@@ -403,9 +427,11 @@ Arguments:
403impl Subcommand { 427impl Subcommand {
404 pub fn test_args(&self) -> Vec<&str> { 428 pub fn test_args(&self) -> Vec<&str> {
405 match *self { 429 match *self {
406 Subcommand::Test { ref test_args, .. } | 430 Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => {
407 Subcommand::Bench { ref test_args, .. } => { 431 test_args
408 test_args.iter().flat_map(|s| s.split_whitespace()).collect() 432 .iter()
433 .flat_map(|s| s.split_whitespace())
434 .collect()
409 } 435 }
410 _ => Vec::new(), 436 _ => Vec::new(),
411 } 437 }
@@ -413,9 +439,10 @@ impl Subcommand {
413 439
414 pub fn rustc_args(&self) -> Vec<&str> { 440 pub fn rustc_args(&self) -> Vec<&str> {
415 match *self { 441 match *self {
416 Subcommand::Test { ref rustc_args, .. } => { 442 Subcommand::Test { ref rustc_args, .. } => rustc_args
417 rustc_args.iter().flat_map(|s| s.split_whitespace()).collect() 443 .iter()
418 } 444 .flat_map(|s| s.split_whitespace())
445 .collect(),
419 _ => Vec::new(), 446 _ => Vec::new(),
420 } 447 }
421 } 448 }
@@ -443,12 +470,17 @@ impl Subcommand {
443 470
444 pub fn compare_mode(&self) -> Option<&str> { 471 pub fn compare_mode(&self) -> Option<&str> {
445 match *self { 472 match *self {
446 Subcommand::Test { ref compare_mode, .. } => compare_mode.as_ref().map(|s| &s[..]), 473 Subcommand::Test {
474 ref compare_mode, ..
475 } => compare_mode.as_ref().map(|s| &s[..]),
447 _ => None, 476 _ => None,
448 } 477 }
449 } 478 }
450} 479}
451 480
452fn split(s: Vec<String>) -> Vec<String> { 481fn split(s: Vec<String>) -> Vec<String> {
453 s.iter().flat_map(|s| s.split(',')).map(|s| s.to_string()).collect() 482 s.iter()
483 .flat_map(|s| s.split(','))
484 .map(|s| s.to_string())
485 .collect()
454} 486}
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index a0a51659ba..9284778679 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -15,26 +15,26 @@
15 15
16use std::env; 16use std::env;
17use std::ffi::OsString; 17use std::ffi::OsString;
18use std::iter;
19use std::fmt; 18use std::fmt;
20use std::fs::{self, File}; 19use std::fs::{self, File};
21use std::path::{PathBuf, Path};
22use std::process::Command;
23use std::io::Read; 20use std::io::Read;
21use std::iter;
22use std::path::{Path, PathBuf};
23use std::process::Command;
24 24
25use build_helper::{self, output}; 25use build_helper::{self, output};
26 26
27use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step}; 27use builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
28use Crate as CargoCrate; 28use cache::{Interned, INTERNER};
29use cache::{INTERNER, Interned};
30use compile; 29use compile;
31use dist; 30use dist;
31use flags::Subcommand;
32use native; 32use native;
33use tool::{self, Tool}; 33use tool::{self, Tool};
34use util::{self, dylib_path, dylib_path_var};
35use {Mode, DocTests};
36use toolstate::ToolState; 34use toolstate::ToolState;
37use flags::Subcommand; 35use util::{self, dylib_path, dylib_path_var};
36use Crate as CargoCrate;
37use {DocTests, Mode};
38 38
39const ADB_TEST_DIR: &str = "/data/tmp/work"; 39const ADB_TEST_DIR: &str = "/data/tmp/work";
40 40
@@ -52,7 +52,7 @@ impl From<Kind> for TestKind {
52 match kind { 52 match kind {
53 Kind::Test => TestKind::Test, 53 Kind::Test => TestKind::Test,
54 Kind::Bench => TestKind::Bench, 54 Kind::Bench => TestKind::Bench,
55 _ => panic!("unexpected kind in crate: {:?}", kind) 55 _ => panic!("unexpected kind in crate: {:?}", kind),
56 } 56 }
57 } 57 }
58} 58}
@@ -124,13 +124,18 @@ impl Step for Linkcheck {
124 builder.default_doc(None); 124 builder.default_doc(None);
125 125
126 let _time = util::timeit(&builder); 126 let _time = util::timeit(&builder);
127 try_run(builder, builder.tool_cmd(Tool::Linkchecker) 127 try_run(
128 .arg(builder.out.join(host).join("doc"))); 128 builder,
129 builder
130 .tool_cmd(Tool::Linkchecker)
131 .arg(builder.out.join(host).join("doc")),
132 );
129 } 133 }
130 134
131 fn should_run(run: ShouldRun) -> ShouldRun { 135 fn should_run(run: ShouldRun) -> ShouldRun {
132 let builder = run.builder; 136 let builder = run.builder;
133 run.path("src/tools/linkchecker").default_condition(builder.config.docs) 137 run.path("src/tools/linkchecker")
138 .default_condition(builder.config.docs)
134 } 139 }
135 140
136 fn make_run(run: RunConfig) { 141 fn make_run(run: RunConfig) {
@@ -165,7 +170,10 @@ impl Step for Cargotest {
165 /// test` to ensure that we don't regress the test suites there. 170 /// test` to ensure that we don't regress the test suites there.
166 fn run(self, builder: &Builder) { 171 fn run(self, builder: &Builder) {
167 let compiler = builder.compiler(self.stage, self.host); 172 let compiler = builder.compiler(self.stage, self.host);
168 builder.ensure(compile::Rustc { compiler, target: compiler.host }); 173 builder.ensure(compile::Rustc {
174 compiler,
175 target: compiler.host,
176 });
169 177
170 // Note that this is a short, cryptic, and not scoped directory name. This 178 // Note that this is a short, cryptic, and not scoped directory name. This
171 // is currently to minimize the length of path on Windows where we otherwise 179 // is currently to minimize the length of path on Windows where we otherwise
@@ -175,10 +183,13 @@ impl Step for Cargotest {
175 183
176 let _time = util::timeit(&builder); 184 let _time = util::timeit(&builder);
177 let mut cmd = builder.tool_cmd(Tool::CargoTest); 185 let mut cmd = builder.tool_cmd(Tool::CargoTest);
178 try_run(builder, cmd.arg(&builder.initial_cargo) 186 try_run(
179 .arg(&out_dir) 187 builder,
180 .env("RUSTC", builder.rustc(compiler)) 188 cmd.arg(&builder.initial_cargo)
181 .env("RUSTDOC", builder.rustdoc(compiler.host))); 189 .arg(&out_dir)
190 .env("RUSTC", builder.rustc(compiler))
191 .env("RUSTDOC", builder.rustdoc(compiler.host)),
192 );
182 } 193 }
183} 194}
184 195
@@ -207,9 +218,14 @@ impl Step for Cargo {
207 fn run(self, builder: &Builder) { 218 fn run(self, builder: &Builder) {
208 let compiler = builder.compiler(self.stage, self.host); 219 let compiler = builder.compiler(self.stage, self.host);
209 220
210 builder.ensure(tool::Cargo { compiler, target: self.host }); 221 builder.ensure(tool::Cargo {
222 compiler,
223 target: self.host,
224 });
211 let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test"); 225 let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
212 cargo.arg("--manifest-path").arg(builder.src.join("src/tools/cargo/Cargo.toml")); 226 cargo
227 .arg("--manifest-path")
228 .arg(builder.src.join("src/tools/cargo/Cargo.toml"));
213 if !builder.fail_fast { 229 if !builder.fail_fast {
214 cargo.arg("--no-fail-fast"); 230 cargo.arg("--no-fail-fast");
215 } 231 }
@@ -221,7 +237,10 @@ impl Step for Cargo {
221 // available. 237 // available.
222 cargo.env("CFG_DISABLE_CROSS_TESTS", "1"); 238 cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
223 239
224 try_run(builder, cargo.env("PATH", &path_for_cargo(builder, compiler))); 240 try_run(
241 builder,
242 cargo.env("PATH", &path_for_cargo(builder, compiler)),
243 );
225 } 244 }
226} 245}
227 246
@@ -262,11 +281,7 @@ impl Step for Rls {
262 return; 281 return;
263 } 282 }
264 283
265 let mut cargo = tool::prepare_tool_cargo(builder, 284 let mut cargo = tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rls");
266 compiler,
267 host,
268 "test",
269 "src/tools/rls");
270 285
271 // Don't build tests dynamically, just a pain to work with 286 // Don't build tests dynamically, just a pain to work with
272 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); 287 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -316,11 +331,8 @@ impl Step for Rustfmt {
316 return; 331 return;
317 } 332 }
318 333
319 let mut cargo = tool::prepare_tool_cargo(builder, 334 let mut cargo =
320 compiler, 335 tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rustfmt");
321 host,
322 "test",
323 "src/tools/rustfmt");
324 336
325 // Don't build tests dynamically, just a pain to work with 337 // Don't build tests dynamically, just a pain to work with
326 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); 338 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -372,7 +384,9 @@ impl Step for Miri {
372 }); 384 });
373 if let Some(miri) = miri { 385 if let Some(miri) = miri {
374 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test"); 386 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
375 cargo.arg("--manifest-path").arg(builder.src.join("src/tools/miri/Cargo.toml")); 387 cargo
388 .arg("--manifest-path")
389 .arg(builder.src.join("src/tools/miri/Cargo.toml"));
376 390
377 // Don't build tests dynamically, just a pain to work with 391 // Don't build tests dynamically, just a pain to work with
378 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); 392 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -428,7 +442,9 @@ impl Step for Clippy {
428 }); 442 });
429 if let Some(clippy) = clippy { 443 if let Some(clippy) = clippy {
430 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test"); 444 let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
431 cargo.arg("--manifest-path").arg(builder.src.join("src/tools/clippy/Cargo.toml")); 445 cargo
446 .arg("--manifest-path")
447 .arg(builder.src.join("src/tools/clippy/Cargo.toml"));
432 448
433 // Don't build tests dynamically, just a pain to work with 449 // Don't build tests dynamically, just a pain to work with
434 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); 450 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -436,7 +452,9 @@ impl Step for Clippy {
436 cargo.env("SYSROOT", builder.sysroot(compiler)); 452 cargo.env("SYSROOT", builder.sysroot(compiler));
437 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler)); 453 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
438 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler)); 454 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
439 let host_libs = builder.stage_out(compiler, Mode::Tool).join(builder.cargo_dir()); 455 let host_libs = builder
456 .stage_out(compiler, Mode::Tool)
457 .join(builder.cargo_dir());
440 cargo.env("HOST_LIBS", host_libs); 458 cargo.env("HOST_LIBS", host_libs);
441 // clippy tests need to find the driver 459 // clippy tests need to find the driver
442 cargo.env("CLIPPY_DRIVER_PATH", clippy); 460 cargo.env("CLIPPY_DRIVER_PATH", clippy);
@@ -478,23 +496,30 @@ impl Step for RustdocTheme {
478 fn make_run(run: RunConfig) { 496 fn make_run(run: RunConfig) {
479 let compiler = run.builder.compiler(run.builder.top_stage, run.host); 497 let compiler = run.builder.compiler(run.builder.top_stage, run.host);
480 498
481 run.builder.ensure(RustdocTheme { 499 run.builder.ensure(RustdocTheme { compiler: compiler });
482 compiler: compiler,
483 });
484 } 500 }
485 501
486 fn run(self, builder: &Builder) { 502 fn run(self, builder: &Builder) {
487 let rustdoc = builder.out.join("bootstrap/debug/rustdoc"); 503 let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
488 let mut cmd = builder.tool_cmd(Tool::RustdocTheme); 504 let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
489 cmd.arg(rustdoc.to_str().unwrap()) 505 cmd.arg(rustdoc.to_str().unwrap())
490 .arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()) 506 .arg(
491 .env("RUSTC_STAGE", self.compiler.stage.to_string()) 507 builder
492 .env("RUSTC_SYSROOT", builder.sysroot(self.compiler)) 508 .src
493 .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host)) 509 .join("src/librustdoc/html/static/themes")
494 .env("CFG_RELEASE_CHANNEL", &builder.config.channel) 510 .to_str()
495 .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host)) 511 .unwrap(),
496 .env("RUSTDOC_CRATE_VERSION", builder.rust_version()) 512 )
497 .env("RUSTC_BOOTSTRAP", "1"); 513 .env("RUSTC_STAGE", self.compiler.stage.to_string())
514 .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
515 .env(
516 "RUSTDOC_LIBDIR",
517 builder.sysroot_libdir(self.compiler, self.compiler.host),
518 )
519 .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
520 .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
521 .env("RUSTDOC_CRATE_VERSION", builder.rust_version())
522 .env("RUSTC_BOOTSTRAP", "1");
498 if let Some(linker) = builder.linker(self.compiler.host) { 523 if let Some(linker) = builder.linker(self.compiler.host) {
499 cmd.env("RUSTC_TARGET_LINKER", linker); 524 cmd.env("RUSTC_TARGET_LINKER", linker);
500 } 525 }
@@ -534,7 +559,9 @@ impl Step for RustdocJS {
534 }); 559 });
535 builder.run(&mut command); 560 builder.run(&mut command);
536 } else { 561 } else {
537 builder.info(&format!("No nodejs found, skipping \"src/test/rustdoc-js\" tests")); 562 builder.info(&format!(
563 "No nodejs found, skipping \"src/test/rustdoc-js\" tests"
564 ));
538 } 565 }
539 } 566 }
540} 567}
@@ -918,7 +945,7 @@ impl Step for Compiletest {
918 945
919 builder.ensure(dist::DebuggerScripts { 946 builder.ensure(dist::DebuggerScripts {
920 sysroot: builder.sysroot(compiler), 947 sysroot: builder.sysroot(compiler),
921 host: target 948 host: target,
922 }); 949 });
923 } 950 }
924 951
@@ -926,7 +953,8 @@ impl Step for Compiletest {
926 // FIXME: Does pretty need librustc compiled? Note that there are 953 // FIXME: Does pretty need librustc compiled? Note that there are
927 // fulldeps test suites with mode = pretty as well. 954 // fulldeps test suites with mode = pretty as well.
928 mode == "pretty" || 955 mode == "pretty" ||
929 mode == "rustdoc" { 956 mode == "rustdoc"
957 {
930 builder.ensure(compile::Rustc { compiler, target }); 958 builder.ensure(compile::Rustc { compiler, target });
931 } 959 }
932 960
@@ -939,26 +967,34 @@ impl Step for Compiletest {
939 // compiletest currently has... a lot of arguments, so let's just pass all 967 // compiletest currently has... a lot of arguments, so let's just pass all
940 // of them! 968 // of them!
941 969
942 cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler)); 970 cmd.arg("--compile-lib-path")
943 cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target)); 971 .arg(builder.rustc_libdir(compiler));
972 cmd.arg("--run-lib-path")
973 .arg(builder.sysroot_libdir(compiler, target));
944 cmd.arg("--rustc-path").arg(builder.rustc(compiler)); 974 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
945 975
946 let is_rustdoc_ui = suite.ends_with("rustdoc-ui"); 976 let is_rustdoc_ui = suite.ends_with("rustdoc-ui");
947 977
948 // Avoid depending on rustdoc when we don't need it. 978 // Avoid depending on rustdoc when we don't need it.
949 if mode == "rustdoc" || 979 if mode == "rustdoc"
950 (mode == "run-make" && suite.ends_with("fulldeps")) || 980 || (mode == "run-make" && suite.ends_with("fulldeps"))
951 (mode == "ui" && is_rustdoc_ui) { 981 || (mode == "ui" && is_rustdoc_ui)
952 cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host)); 982 {
983 cmd.arg("--rustdoc-path")
984 .arg(builder.rustdoc(compiler.host));
953 } 985 }
954 986
955 cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite)); 987 cmd.arg("--src-base")
956 cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite)); 988 .arg(builder.src.join("src/test").join(suite));
957 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target)); 989 cmd.arg("--build-base")
990 .arg(testdir(builder, compiler.host).join(suite));
991 cmd.arg("--stage-id")
992 .arg(format!("stage{}-{}", compiler.stage, target));
958 cmd.arg("--mode").arg(mode); 993 cmd.arg("--mode").arg(mode);
959 cmd.arg("--target").arg(target); 994 cmd.arg("--target").arg(target);
960 cmd.arg("--host").arg(&*compiler.host); 995 cmd.arg("--host").arg(&*compiler.host);
961 cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build)); 996 cmd.arg("--llvm-filecheck")
997 .arg(builder.llvm_filecheck(builder.config.build));
962 998
963 if builder.config.cmd.bless() { 999 if builder.config.cmd.bless() {
964 cmd.arg("--bless"); 1000 cmd.arg("--bless");
@@ -994,8 +1030,10 @@ impl Step for Compiletest {
994 cmd.arg("--host-rustcflags").arg(hostflags.join(" ")); 1030 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
995 1031
996 let mut targetflags = flags.clone(); 1032 let mut targetflags = flags.clone();
997 targetflags.push(format!("-Lnative={}", 1033 targetflags.push(format!(
998 builder.test_helpers_out(target).display())); 1034 "-Lnative={}",
1035 builder.test_helpers_out(target).display()
1036 ));
999 cmd.arg("--target-rustcflags").arg(targetflags.join(" ")); 1037 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
1000 1038
1001 cmd.arg("--docck-python").arg(builder.python()); 1039 cmd.arg("--docck-python").arg(builder.python());
@@ -1021,13 +1059,16 @@ impl Step for Compiletest {
1021 1059
1022 // Get paths from cmd args 1060 // Get paths from cmd args
1023 let paths = match &builder.config.cmd { 1061 let paths = match &builder.config.cmd {
1024 Subcommand::Test { ref paths, ..} => &paths[..], 1062 Subcommand::Test { ref paths, .. } => &paths[..],
1025 _ => &[] 1063 _ => &[],
1026 }; 1064 };
1027 1065
1028 // Get test-args by striping suite path 1066 // Get test-args by striping suite path
1029 let mut test_args: Vec<&str> = paths.iter().filter(|p| p.starts_with(suite_path) && 1067 let mut test_args: Vec<&str> = paths
1030 p.is_file()).map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap()).collect(); 1068 .iter()
1069 .filter(|p| p.starts_with(suite_path) && p.is_file())
1070 .map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
1071 .collect();
1031 1072
1032 test_args.append(&mut builder.config.cmd.test_args()); 1073 test_args.append(&mut builder.config.cmd.test_args());
1033 1074
@@ -1059,32 +1100,44 @@ impl Step for Compiletest {
1059 if !builder.config.dry_run && suite == "run-make-fulldeps" { 1100 if !builder.config.dry_run && suite == "run-make-fulldeps" {
1060 let llvm_components = output(Command::new(&llvm_config).arg("--components")); 1101 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
1061 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags")); 1102 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
1062 cmd.arg("--cc").arg(builder.cc(target)) 1103 cmd.arg("--cc")
1063 .arg("--cxx").arg(builder.cxx(target).unwrap()) 1104 .arg(builder.cc(target))
1064 .arg("--cflags").arg(builder.cflags(target).join(" ")) 1105 .arg("--cxx")
1065 .arg("--llvm-components").arg(llvm_components.trim()) 1106 .arg(builder.cxx(target).unwrap())
1066 .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim()); 1107 .arg("--cflags")
1108 .arg(builder.cflags(target).join(" "))
1109 .arg("--llvm-components")
1110 .arg(llvm_components.trim())
1111 .arg("--llvm-cxxflags")
1112 .arg(llvm_cxxflags.trim());
1067 if let Some(ar) = builder.ar(target) { 1113 if let Some(ar) = builder.ar(target) {
1068 cmd.arg("--ar").arg(ar); 1114 cmd.arg("--ar").arg(ar);
1069 } 1115 }
1070 } 1116 }
1071 } 1117 }
1072 if suite == "run-make-fulldeps" && !builder.config.llvm_enabled { 1118 if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
1073 builder.info( 1119 builder.info(&format!(
1074 &format!("Ignoring run-make test suite as they generally don't work without LLVM")); 1120 "Ignoring run-make test suite as they generally don't work without LLVM"
1121 ));
1075 return; 1122 return;
1076 } 1123 }
1077 1124
1078 if suite != "run-make-fulldeps" { 1125 if suite != "run-make-fulldeps" {
1079 cmd.arg("--cc").arg("") 1126 cmd.arg("--cc")
1080 .arg("--cxx").arg("") 1127 .arg("")
1081 .arg("--cflags").arg("") 1128 .arg("--cxx")
1082 .arg("--llvm-components").arg("") 1129 .arg("")
1083 .arg("--llvm-cxxflags").arg(""); 1130 .arg("--cflags")
1131 .arg("")
1132 .arg("--llvm-components")
1133 .arg("")
1134 .arg("--llvm-cxxflags")
1135 .arg("");
1084 } 1136 }
1085 1137
1086 if builder.remote_tested(target) { 1138 if builder.remote_tested(target) {
1087 cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient)); 1139 cmd.arg("--remote-test-client")
1140 .arg(builder.tool_exe(Tool::RemoteTestClient));
1088 } 1141 }
1089 1142
1090 // Running a C compiler on MSVC requires a few env vars to be set, to be 1143 // Running a C compiler on MSVC requires a few env vars to be set, to be
@@ -1117,7 +1170,7 @@ impl Step for Compiletest {
1117 if target.contains("android") { 1170 if target.contains("android") {
1118 // Assume that cc for this target comes from the android sysroot 1171 // Assume that cc for this target comes from the android sysroot
1119 cmd.arg("--android-cross-path") 1172 cmd.arg("--android-cross-path")
1120 .arg(builder.cc(target).parent().unwrap().parent().unwrap()); 1173 .arg(builder.cc(target).parent().unwrap().parent().unwrap());
1121 } else { 1174 } else {
1122 cmd.arg("--android-cross-path").arg(""); 1175 cmd.arg("--android-cross-path").arg("");
1123 } 1176 }
@@ -1125,16 +1178,20 @@ impl Step for Compiletest {
1125 builder.ci_env.force_coloring_in_ci(&mut cmd); 1178 builder.ci_env.force_coloring_in_ci(&mut cmd);
1126 1179
1127 let _folder = builder.fold_output(|| format!("test_{}", suite)); 1180 let _folder = builder.fold_output(|| format!("test_{}", suite));
1128 builder.info(&format!("Check compiletest suite={} mode={} ({} -> {})", 1181 builder.info(&format!(
1129 suite, mode, &compiler.host, target)); 1182 "Check compiletest suite={} mode={} ({} -> {})",
1183 suite, mode, &compiler.host, target
1184 ));
1130 let _time = util::timeit(&builder); 1185 let _time = util::timeit(&builder);
1131 try_run(builder, &mut cmd); 1186 try_run(builder, &mut cmd);
1132 1187
1133 if let Some(compare_mode) = compare_mode { 1188 if let Some(compare_mode) = compare_mode {
1134 cmd.arg("--compare-mode").arg(compare_mode); 1189 cmd.arg("--compare-mode").arg(compare_mode);
1135 let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode)); 1190 let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode));
1136 builder.info(&format!("Check compiletest suite={} mode={} compare_mode={} ({} -> {})", 1191 builder.info(&format!(
1137 suite, mode, compare_mode, &compiler.host, target)); 1192 "Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
1193 suite, mode, compare_mode, &compiler.host, target
1194 ));
1138 let _time = util::timeit(&builder); 1195 let _time = util::timeit(&builder);
1139 try_run(builder, &mut cmd); 1196 try_run(builder, &mut cmd);
1140 } 1197 }
@@ -1165,7 +1222,10 @@ impl Step for DocTest {
1165 fn run(self, builder: &Builder) { 1222 fn run(self, builder: &Builder) {
1166 let compiler = self.compiler; 1223 let compiler = self.compiler;
1167 1224
1168 builder.ensure(compile::Test { compiler, target: compiler.host }); 1225 builder.ensure(compile::Test {
1226 compiler,
1227 target: compiler.host,
1228 });
1169 1229
1170 // Do a breadth-first traversal of the `src/doc` directory and just run 1230 // Do a breadth-first traversal of the `src/doc` directory and just run
1171 // tests for all files that end in `*.md` 1231 // tests for all files that end in `*.md`
@@ -1177,7 +1237,7 @@ impl Step for DocTest {
1177 while let Some(p) = stack.pop() { 1237 while let Some(p) = stack.pop() {
1178 if p.is_dir() { 1238 if p.is_dir() {
1179 stack.extend(t!(p.read_dir()).map(|p| t!(p).path())); 1239 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
1180 continue 1240 continue;
1181 } 1241 }
1182 1242
1183 if p.extension().and_then(|s| s.to_str()) != Some("md") { 1243 if p.extension().and_then(|s| s.to_str()) != Some("md") {
@@ -1284,7 +1344,10 @@ impl Step for ErrorIndex {
1284 fn run(self, builder: &Builder) { 1344 fn run(self, builder: &Builder) {
1285 let compiler = self.compiler; 1345 let compiler = self.compiler;
1286 1346
1287 builder.ensure(compile::Std { compiler, target: compiler.host }); 1347 builder.ensure(compile::Std {
1348 compiler,
1349 target: compiler.host,
1350 });
1288 1351
1289 let dir = testdir(builder, compiler.host); 1352 let dir = testdir(builder, compiler.host);
1290 t!(fs::create_dir_all(&dir)); 1353 t!(fs::create_dir_all(&dir));
@@ -1296,7 +1359,6 @@ impl Step for ErrorIndex {
1296 .env("CFG_BUILD", &builder.config.build) 1359 .env("CFG_BUILD", &builder.config.build)
1297 .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir()); 1360 .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
1298 1361
1299
1300 let _folder = builder.fold_output(|| "test_error_index"); 1362 let _folder = builder.fold_output(|| "test_error_index");
1301 builder.info(&format!("Testing error-index stage{}", compiler.stage)); 1363 builder.info(&format!("Testing error-index stage{}", compiler.stage));
1302 let _time = util::timeit(&builder); 1364 let _time = util::timeit(&builder);
@@ -1314,7 +1376,7 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool
1314 return true; 1376 return true;
1315 } 1377 }
1316 } 1378 }
1317 Err(_) => {}, 1379 Err(_) => {}
1318 } 1380 }
1319 1381
1320 builder.info(&format!("doc tests for: {}", markdown.display())); 1382 builder.info(&format!("doc tests for: {}", markdown.display()));
@@ -1431,7 +1493,6 @@ impl Step for CrateNotDefault {
1431 } 1493 }
1432} 1494}
1433 1495
1434
1435#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] 1496#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1436pub struct Crate { 1497pub struct Crate {
1437 pub compiler: Compiler, 1498 pub compiler: Compiler,
@@ -1449,10 +1510,11 @@ impl Step for Crate {
1449 let builder = run.builder; 1510 let builder = run.builder;
1450 run = run.krate("test"); 1511 run = run.krate("test");
1451 for krate in run.builder.in_tree_crates("std") { 1512 for krate in run.builder.in_tree_crates("std") {
1452 if krate.is_local(&run.builder) && 1513 if krate.is_local(&run.builder)
1453 !krate.name.contains("jemalloc") && 1514 && !krate.name.contains("jemalloc")
1454 !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) && 1515 && !(krate.name.starts_with("rustc_") && krate.name.ends_with("san"))
1455 krate.name != "dlmalloc" { 1516 && krate.name != "dlmalloc"
1517 {
1456 run = run.path(krate.local_path(&builder).to_str().unwrap()); 1518 run = run.path(krate.local_path(&builder).to_str().unwrap());
1457 } 1519 }
1458 } 1520 }
@@ -1567,38 +1629,59 @@ impl Step for Crate {
1567 } 1629 }
1568 1630
1569 if target.contains("emscripten") { 1631 if target.contains("emscripten") {
1570 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), 1632 cargo.env(
1571 builder.config.nodejs.as_ref().expect("nodejs not configured")); 1633 format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1634 builder
1635 .config
1636 .nodejs
1637 .as_ref()
1638 .expect("nodejs not configured"),
1639 );
1572 } else if target.starts_with("wasm32") { 1640 } else if target.starts_with("wasm32") {
1573 // Warn about running tests without the `wasm_syscall` feature enabled. 1641 // Warn about running tests without the `wasm_syscall` feature enabled.
1574 // The javascript shim implements the syscall interface so that test 1642 // The javascript shim implements the syscall interface so that test
1575 // output can be correctly reported. 1643 // output can be correctly reported.
1576 if !builder.config.wasm_syscall { 1644 if !builder.config.wasm_syscall {
1577 builder.info(&format!("Libstd was built without `wasm_syscall` feature enabled: \ 1645 builder.info(&format!(
1578 test output may not be visible.")); 1646 "Libstd was built without `wasm_syscall` feature enabled: \
1647 test output may not be visible."
1648 ));
1579 } 1649 }
1580 1650
1581 // On the wasm32-unknown-unknown target we're using LTO which is 1651 // On the wasm32-unknown-unknown target we're using LTO which is
1582 // incompatible with `-C prefer-dynamic`, so disable that here 1652 // incompatible with `-C prefer-dynamic`, so disable that here
1583 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); 1653 cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
1584 1654
1585 let node = builder.config.nodejs.as_ref() 1655 let node = builder
1656 .config
1657 .nodejs
1658 .as_ref()
1586 .expect("nodejs not configured"); 1659 .expect("nodejs not configured");
1587 let runner = format!("{} {}/src/etc/wasm32-shim.js", 1660 let runner = format!(
1588 node.display(), 1661 "{} {}/src/etc/wasm32-shim.js",
1589 builder.src.display()); 1662 node.display(),
1663 builder.src.display()
1664 );
1590 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner); 1665 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner);
1591 } else if builder.remote_tested(target) { 1666 } else if builder.remote_tested(target) {
1592 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), 1667 cargo.env(
1593 format!("{} run", 1668 format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
1594 builder.tool_exe(Tool::RemoteTestClient).display())); 1669 format!("{} run", builder.tool_exe(Tool::RemoteTestClient).display()),
1670 );
1595 } 1671 }
1596 1672
1597 let _folder = builder.fold_output(|| { 1673 let _folder = builder.fold_output(|| {
1598 format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate) 1674 format!(
1675 "{}_stage{}-{}",
1676 test_kind.subcommand(),
1677 compiler.stage,
1678 krate
1679 )
1599 }); 1680 });
1600 builder.info(&format!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage, 1681 builder.info(&format!(
1601 &compiler.host, target)); 1682 "{} {} stage{} ({} -> {})",
1683 test_kind, krate, compiler.stage, &compiler.host, target
1684 ));
1602 let _time = util::timeit(&builder); 1685 let _time = util::timeit(&builder);
1603 try_run(builder, &mut cargo); 1686 try_run(builder, &mut cargo);
1604 } 1687 }
@@ -1636,11 +1719,13 @@ impl Step for CrateRustdoc {
1636 let compiler = builder.compiler(builder.top_stage, self.host); 1719 let compiler = builder.compiler(builder.top_stage, self.host);
1637 let target = compiler.host; 1720 let target = compiler.host;
1638 1721
1639 let mut cargo = tool::prepare_tool_cargo(builder, 1722 let mut cargo = tool::prepare_tool_cargo(
1640 compiler, 1723 builder,
1641 target, 1724 compiler,
1642 test_kind.subcommand(), 1725 target,
1643 "src/tools/rustdoc"); 1726 test_kind.subcommand(),
1727 "src/tools/rustdoc",
1728 );
1644 if test_kind.subcommand() == "test" && !builder.fail_fast { 1729 if test_kind.subcommand() == "test" && !builder.fail_fast {
1645 cargo.arg("--no-fail-fast"); 1730 cargo.arg("--no-fail-fast");
1646 } 1731 }
@@ -1654,11 +1739,12 @@ impl Step for CrateRustdoc {
1654 cargo.arg("--quiet"); 1739 cargo.arg("--quiet");
1655 } 1740 }
1656 1741
1657 let _folder = builder.fold_output(|| { 1742 let _folder = builder
1658 format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage) 1743 .fold_output(|| format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage));
1659 }); 1744 builder.info(&format!(
1660 builder.info(&format!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage, 1745 "{} rustdoc stage{} ({} -> {})",
1661 &compiler.host, target)); 1746 test_kind, compiler.stage, &compiler.host, target
1747 ));
1662 let _time = util::timeit(&builder); 1748 let _time = util::timeit(&builder);
1663 1749
1664 try_run(builder, &mut cargo); 1750 try_run(builder, &mut cargo);
@@ -1666,12 +1752,13 @@ impl Step for CrateRustdoc {
1666} 1752}
1667 1753
1668fn envify(s: &str) -> String { 1754fn envify(s: &str) -> String {
1669 s.chars().map(|c| { 1755 s.chars()
1670 match c { 1756 .map(|c| match c {
1671 '-' => '_', 1757 '-' => '_',
1672 c => c, 1758 c => c,
1673 } 1759 })
1674 }).flat_map(|c| c.to_uppercase()).collect() 1760 .flat_map(|c| c.to_uppercase())
1761 .collect()
1675} 1762}
1676 1763
1677/// Some test suites are run inside emulators or on remote devices, and most 1764/// Some test suites are run inside emulators or on remote devices, and most
@@ -1700,7 +1787,7 @@ impl Step for RemoteCopyLibs {
1700 let compiler = self.compiler; 1787 let compiler = self.compiler;
1701 let target = self.target; 1788 let target = self.target;
1702 if !builder.remote_tested(target) { 1789 if !builder.remote_tested(target) {
1703 return 1790 return;
1704 } 1791 }
1705 1792
1706 builder.ensure(compile::Test { compiler, target }); 1793 builder.ensure(compile::Test { compiler, target });
@@ -1714,9 +1801,9 @@ impl Step for RemoteCopyLibs {
1714 let tool = builder.tool_exe(Tool::RemoteTestClient); 1801 let tool = builder.tool_exe(Tool::RemoteTestClient);
1715 let mut cmd = Command::new(&tool); 1802 let mut cmd = Command::new(&tool);
1716 cmd.arg("spawn-emulator") 1803 cmd.arg("spawn-emulator")
1717 .arg(target) 1804 .arg(target)
1718 .arg(&server) 1805 .arg(&server)
1719 .arg(builder.out.join("tmp")); 1806 .arg(builder.out.join("tmp"));
1720 if let Some(rootfs) = builder.qemu_rootfs(target) { 1807 if let Some(rootfs) = builder.qemu_rootfs(target) {
1721 cmd.arg(rootfs); 1808 cmd.arg(rootfs);
1722 } 1809 }
@@ -1727,9 +1814,7 @@ impl Step for RemoteCopyLibs {
1727 let f = t!(f); 1814 let f = t!(f);
1728 let name = f.file_name().into_string().unwrap(); 1815 let name = f.file_name().into_string().unwrap();
1729 if util::is_dylib(&name) { 1816 if util::is_dylib(&name) {
1730 builder.run(Command::new(&tool) 1817 builder.run(Command::new(&tool).arg("push").arg(f.path()));
1731 .arg("push")
1732 .arg(f.path()));
1733 } 1818 }
1734 } 1819 }
1735 } 1820 }
@@ -1762,17 +1847,21 @@ impl Step for Distcheck {
1762 1847
1763 let mut cmd = Command::new("tar"); 1848 let mut cmd = Command::new("tar");
1764 cmd.arg("-xzf") 1849 cmd.arg("-xzf")
1765 .arg(builder.ensure(dist::PlainSourceTarball)) 1850 .arg(builder.ensure(dist::PlainSourceTarball))
1766 .arg("--strip-components=1") 1851 .arg("--strip-components=1")
1767 .current_dir(&dir); 1852 .current_dir(&dir);
1768 builder.run(&mut cmd); 1853 builder.run(&mut cmd);
1769 builder.run(Command::new("./configure") 1854 builder.run(
1770 .args(&builder.config.configure_args) 1855 Command::new("./configure")
1771 .arg("--enable-vendor") 1856 .args(&builder.config.configure_args)
1772 .current_dir(&dir)); 1857 .arg("--enable-vendor")
1773 builder.run(Command::new(build_helper::make(&builder.config.build)) 1858 .current_dir(&dir),
1774 .arg("check") 1859 );
1775 .current_dir(&dir)); 1860 builder.run(
1861 Command::new(build_helper::make(&builder.config.build))
1862 .arg("check")
1863 .current_dir(&dir),
1864 );
1776 1865
1777 // Now make sure that rust-src has all of libstd's dependencies 1866 // Now make sure that rust-src has all of libstd's dependencies
1778 builder.info(&format!("Distcheck rust-src")); 1867 builder.info(&format!("Distcheck rust-src"));
@@ -1782,17 +1871,19 @@ impl Step for Distcheck {
1782 1871
1783 let mut cmd = Command::new("tar"); 1872 let mut cmd = Command::new("tar");
1784 cmd.arg("-xzf") 1873 cmd.arg("-xzf")
1785 .arg(builder.ensure(dist::Src)) 1874 .arg(builder.ensure(dist::Src))
1786 .arg("--strip-components=1") 1875 .arg("--strip-components=1")
1787 .current_dir(&dir); 1876 .current_dir(&dir);
1788 builder.run(&mut cmd); 1877 builder.run(&mut cmd);
1789 1878
1790 let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml"); 1879 let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
1791 builder.run(Command::new(&builder.initial_cargo) 1880 builder.run(
1792 .arg("generate-lockfile") 1881 Command::new(&builder.initial_cargo)
1793 .arg("--manifest-path") 1882 .arg("generate-lockfile")
1794 .arg(&toml) 1883 .arg("--manifest-path")
1795 .current_dir(&dir)); 1884 .arg(&toml)
1885 .current_dir(&dir),
1886 );
1796 } 1887 }
1797} 1888}
1798 1889
@@ -1808,11 +1899,11 @@ impl Step for Bootstrap {
1808 fn run(self, builder: &Builder) { 1899 fn run(self, builder: &Builder) {
1809 let mut cmd = Command::new(&builder.initial_cargo); 1900 let mut cmd = Command::new(&builder.initial_cargo);
1810 cmd.arg("test") 1901 cmd.arg("test")
1811 .current_dir(builder.src.join("src/bootstrap")) 1902 .current_dir(builder.src.join("src/bootstrap"))
1812 .env("RUSTFLAGS", "-Cdebuginfo=2") 1903 .env("RUSTFLAGS", "-Cdebuginfo=2")
1813 .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) 1904 .env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
1814 .env("RUSTC_BOOTSTRAP", "1") 1905 .env("RUSTC_BOOTSTRAP", "1")
1815 .env("RUSTC", &builder.initial_rustc); 1906 .env("RUSTC", &builder.initial_rustc);
1816 if let Some(flags) = option_env!("RUSTFLAGS") { 1907 if let Some(flags) = option_env!("RUSTFLAGS") {
1817 // Use the same rustc flags for testing as for "normal" compilation, 1908 // Use the same rustc flags for testing as for "normal" compilation,
1818 // so that Cargo doesn’t recompile the entire dependency graph every time: 1909 // so that Cargo doesn’t recompile the entire dependency graph every time:
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index f1e0c2bea0..5daf192e2d 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -9,7 +9,7 @@
9// except according to those terms. 9// except according to those terms.
10 10
11use common::CompareMode; 11use common::CompareMode;
12use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED}; 12use common::{expected_output_path, UI_FIXED, UI_STDERR, UI_STDOUT};
13use common::{output_base_dir, output_base_name, output_testname_unique}; 13use common::{output_base_dir, output_base_name, output_testname_unique};
14use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; 14use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
15use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; 15use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
@@ -24,8 +24,8 @@ use regex::Regex;
24use rustfix::{apply_suggestions, get_suggestions_from_json}; 24use rustfix::{apply_suggestions, get_suggestions_from_json};
25use util::{logv, PathBufExt}; 25use util::{logv, PathBufExt};
26 26
27use std::collections::{HashMap, HashSet, VecDeque};
28use std::collections::hash_map::DefaultHasher; 27use std::collections::hash_map::DefaultHasher;
28use std::collections::{HashMap, HashSet, VecDeque};
29use std::env; 29use std::env;
30use std::ffi::OsString; 30use std::ffi::OsString;
31use std::fmt; 31use std::fmt;
@@ -48,9 +48,7 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
48 } 48 }
49 49
50 lazy_static! { 50 lazy_static! {
51 static ref LOCK: Mutex<()> = { 51 static ref LOCK: Mutex<()> = { Mutex::new(()) };
52 Mutex::new(())
53 };
54 } 52 }
55 // Error mode is a global variable, so lock it so only one thread will change it 53 // Error mode is a global variable, so lock it so only one thread will change it
56 let _lock = LOCK.lock().unwrap(); 54 let _lock = LOCK.lock().unwrap();
@@ -743,7 +741,8 @@ impl<'test> TestCx<'test> {
743 } 741 }
744 742
745 _ => { 743 _ => {
746 let rust_src_root = self.config 744 let rust_src_root = self
745 .config
747 .find_rust_src_root() 746 .find_rust_src_root()
748 .expect("Could not find Rust source root"); 747 .expect("Could not find Rust source root");
749 let rust_pp_module_rel_path = Path::new("./src/etc"); 748 let rust_pp_module_rel_path = Path::new("./src/etc");
@@ -905,7 +904,8 @@ impl<'test> TestCx<'test> {
905 script_str.push_str("version\n"); 904 script_str.push_str("version\n");
906 905
907 // Switch LLDB into "Rust mode" 906 // Switch LLDB into "Rust mode"
908 let rust_src_root = self.config 907 let rust_src_root = self
908 .config
909 .find_rust_src_root() 909 .find_rust_src_root()
910 .expect("Could not find Rust source root"); 910 .expect("Could not find Rust source root");
911 let rust_pp_module_rel_path = Path::new("./src/etc/lldb_rust_formatters.py"); 911 let rust_pp_module_rel_path = Path::new("./src/etc/lldb_rust_formatters.py");
@@ -1052,7 +1052,8 @@ impl<'test> TestCx<'test> {
1052 1052
1053 // Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS. 1053 // Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS.
1054 let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()]; 1054 let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()];
1055 let new_options = self.split_maybe_args(options) 1055 let new_options = self
1056 .split_maybe_args(options)
1056 .into_iter() 1057 .into_iter()
1057 .filter(|x| !options_to_remove.contains(x)) 1058 .filter(|x| !options_to_remove.contains(x))
1058 .collect::<Vec<String>>(); 1059 .collect::<Vec<String>>();
@@ -1351,7 +1352,8 @@ impl<'test> TestCx<'test> {
1351 1352
1352 let aux_dir = self.aux_output_dir_name(); 1353 let aux_dir = self.aux_output_dir_name();
1353 1354
1354 let rustdoc_path = self.config 1355 let rustdoc_path = self
1356 .config
1355 .rustdoc_path 1357 .rustdoc_path
1356 .as_ref() 1358 .as_ref()
1357 .expect("--rustdoc-path passed"); 1359 .expect("--rustdoc-path passed");
@@ -1449,7 +1451,8 @@ impl<'test> TestCx<'test> {
1449 /// For each `aux-build: foo/bar` annotation, we check to find the 1451 /// For each `aux-build: foo/bar` annotation, we check to find the
1450 /// file in a `auxiliary` directory relative to the test itself. 1452 /// file in a `auxiliary` directory relative to the test itself.
1451 fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths { 1453 fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths {
1452 let test_ab = self.testpaths 1454 let test_ab = self
1455 .testpaths
1453 .file 1456 .file
1454 .parent() 1457 .parent()
1455 .expect("test file path has no parent") 1458 .expect("test file path has no parent")
@@ -1464,7 +1467,8 @@ impl<'test> TestCx<'test> {
1464 1467
1465 TestPaths { 1468 TestPaths {
1466 file: test_ab, 1469 file: test_ab,
1467 relative_dir: self.testpaths 1470 relative_dir: self
1471 .testpaths
1468 .relative_dir 1472 .relative_dir
1469 .join(self.output_testname_unique()) 1473 .join(self.output_testname_unique())
1470 .join("auxiliary") 1474 .join("auxiliary")
@@ -1617,16 +1621,20 @@ impl<'test> TestCx<'test> {
1617 let mut rustc = if !is_rustdoc { 1621 let mut rustc = if !is_rustdoc {
1618 Command::new(&self.config.rustc_path) 1622 Command::new(&self.config.rustc_path)
1619 } else { 1623 } else {
1620 Command::new(&self.config 1624 Command::new(
1621 .rustdoc_path 1625 &self
1622 .clone() 1626 .config
1623 .expect("no rustdoc built yet")) 1627 .rustdoc_path
1628 .clone()
1629 .expect("no rustdoc built yet"),
1630 )
1624 }; 1631 };
1625 // FIXME Why is -L here? 1632 // FIXME Why is -L here?
1626 rustc.arg(input_file);//.arg("-L").arg(&self.config.build_base); 1633 rustc.arg(input_file); //.arg("-L").arg(&self.config.build_base);
1627 1634
1628 // Optionally prevent default --target if specified in test compile-flags. 1635 // Optionally prevent default --target if specified in test compile-flags.
1629 let custom_target = self.props 1636 let custom_target = self
1637 .props
1630 .compile_flags 1638 .compile_flags
1631 .iter() 1639 .iter()
1632 .any(|x| x.starts_with("--target")); 1640 .any(|x| x.starts_with("--target"));
@@ -1670,7 +1678,8 @@ impl<'test> TestCx<'test> {
1670 } 1678 }
1671 } 1679 }
1672 Ui => { 1680 Ui => {
1673 if !self.props 1681 if !self
1682 .props
1674 .compile_flags 1683 .compile_flags
1675 .iter() 1684 .iter()
1676 .any(|s| s.starts_with("--error-format")) 1685 .any(|s| s.starts_with("--error-format"))
@@ -1704,7 +1713,13 @@ impl<'test> TestCx<'test> {
1704 } 1713 }
1705 1714
1706 if self.props.skip_codegen { 1715 if self.props.skip_codegen {
1707 assert!(!self.props.compile_flags.iter().any(|s| s.starts_with("--emit"))); 1716 assert!(
1717 !self
1718 .props
1719 .compile_flags
1720 .iter()
1721 .any(|s| s.starts_with("--emit"))
1722 );
1708 rustc.args(&["--emit", "metadata"]); 1723 rustc.args(&["--emit", "metadata"]);
1709 } 1724 }
1710 1725
@@ -1812,7 +1827,8 @@ impl<'test> TestCx<'test> {
1812 1827
1813 fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<String> { 1828 fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<String> {
1814 match *argstr { 1829 match *argstr {
1815 Some(ref s) => s.split(' ') 1830 Some(ref s) => s
1831 .split(' ')
1816 .filter_map(|s| { 1832 .filter_map(|s| {
1817 if s.chars().all(|c| c.is_whitespace()) { 1833 if s.chars().all(|c| c.is_whitespace()) {
1818 None 1834 None
@@ -2125,7 +2141,8 @@ impl<'test> TestCx<'test> {
2125 } 2141 }
2126 2142
2127 let mut tested = 0; 2143 let mut tested = 0;
2128 for _ in res.stdout 2144 for _ in res
2145 .stdout
2129 .split('\n') 2146 .split('\n')
2130 .filter(|s| s.starts_with("test ")) 2147 .filter(|s| s.starts_with("test "))
2131 .inspect(|s| { 2148 .inspect(|s| {
@@ -2136,7 +2153,8 @@ impl<'test> TestCx<'test> {
2136 tested += 1; 2153 tested += 1;
2137 let mut iter = tmp[1].split("(line "); 2154 let mut iter = tmp[1].split("(line ");
2138 iter.next(); 2155 iter.next();
2139 let line = iter.next() 2156 let line = iter
2157 .next()
2140 .unwrap_or(")") 2158 .unwrap_or(")")
2141 .split(')') 2159 .split(')')
2142 .next() 2160 .next()
@@ -2290,7 +2308,8 @@ impl<'test> TestCx<'test> {
2290 2308
2291 let full_string = format!("{}{}", PREFIX, s.trim().to_owned()); 2309 let full_string = format!("{}{}", PREFIX, s.trim().to_owned());
2292 2310
2293 let parts: Vec<&str> = s.split(CGU_MARKER) 2311 let parts: Vec<&str> = s
2312 .split(CGU_MARKER)
2294 .map(str::trim) 2313 .map(str::trim)
2295 .filter(|s| !s.is_empty()) 2314 .filter(|s| !s.is_empty())
2296 .collect(); 2315 .collect();
@@ -2375,7 +2394,8 @@ impl<'test> TestCx<'test> {
2375 // FIXME -- use non-incremental mode as an oracle? That doesn't apply 2394 // FIXME -- use non-incremental mode as an oracle? That doesn't apply
2376 // to #[rustc_dirty] and clean tests I guess 2395 // to #[rustc_dirty] and clean tests I guess
2377 2396
2378 let revision = self.revision 2397 let revision = self
2398 .revision
2379 .expect("incremental tests require a list of revisions"); 2399 .expect("incremental tests require a list of revisions");
2380 2400
2381 // Incremental workproduct directory should have already been created. 2401 // Incremental workproduct directory should have already been created.
@@ -2421,7 +2441,8 @@ impl<'test> TestCx<'test> {
2421 2441
2422 fn run_rmake_test(&self) { 2442 fn run_rmake_test(&self) {
2423 let cwd = env::current_dir().unwrap(); 2443 let cwd = env::current_dir().unwrap();
2424 let src_root = self.config 2444 let src_root = self
2445 .config
2425 .src_base 2446 .src_base
2426 .parent() 2447 .parent()
2427 .unwrap() 2448 .unwrap()
@@ -2438,8 +2459,10 @@ impl<'test> TestCx<'test> {
2438 create_dir_all(&tmpdir).unwrap(); 2459 create_dir_all(&tmpdir).unwrap();
2439 2460
2440 let host = &self.config.host; 2461 let host = &self.config.host;
2441 let make = if host.contains("bitrig") || host.contains("dragonfly") 2462 let make = if host.contains("bitrig")
2442 || host.contains("freebsd") || host.contains("netbsd") 2463 || host.contains("dragonfly")
2464 || host.contains("freebsd")
2465 || host.contains("netbsd")
2443 || host.contains("openbsd") 2466 || host.contains("openbsd")
2444 { 2467 {
2445 "gmake" 2468 "gmake"
@@ -2494,7 +2517,8 @@ impl<'test> TestCx<'test> {
2494 // MSYS doesn't like passing flags of the form `/foo` as it thinks it's 2517 // MSYS doesn't like passing flags of the form `/foo` as it thinks it's
2495 // a path and instead passes `C:\msys64\foo`, so convert all 2518 // a path and instead passes `C:\msys64\foo`, so convert all
2496 // `/`-arguments to MSVC here to `-` arguments. 2519 // `/`-arguments to MSVC here to `-` arguments.
2497 let cflags = self.config 2520 let cflags = self
2521 .config
2498 .cflags 2522 .cflags
2499 .split(' ') 2523 .split(' ')
2500 .map(|s| s.replace("/", "-")) 2524 .map(|s| s.replace("/", "-"))
@@ -2516,7 +2540,8 @@ impl<'test> TestCx<'test> {
2516 } 2540 }
2517 } 2541 }
2518 2542
2519 let output = cmd.spawn() 2543 let output = cmd
2544 .spawn()
2520 .and_then(read2_abbreviated) 2545 .and_then(read2_abbreviated)
2521 .expect("failed to spawn `make`"); 2546 .expect("failed to spawn `make`");
2522 if !output.status.success() { 2547 if !output.status.success() {
@@ -2557,7 +2582,8 @@ impl<'test> TestCx<'test> {
2557 // if the user specified a format in the ui test 2582 // if the user specified a format in the ui test
2558 // print the output to the stderr file, otherwise extract 2583 // print the output to the stderr file, otherwise extract
2559 // the rendered error messages from json and print them 2584 // the rendered error messages from json and print them
2560 let explicit = self.props 2585 let explicit = self
2586 .props
2561 .compile_flags 2587 .compile_flags
2562 .iter() 2588 .iter()
2563 .any(|s| s.contains("--error-format")); 2589 .any(|s| s.contains("--error-format"));
@@ -2587,22 +2613,27 @@ impl<'test> TestCx<'test> {
2587 // don't test rustfix with nll right now 2613 // don't test rustfix with nll right now
2588 } else if self.props.run_rustfix { 2614 } else if self.props.run_rustfix {
2589 // Apply suggestions from rustc to the code itself 2615 // Apply suggestions from rustc to the code itself
2590 let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file) 2616 let unfixed_code = self
2617 .load_expected_output_from_path(&self.testpaths.file)
2591 .unwrap(); 2618 .unwrap();
2592 let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap(); 2619 let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap();
2593 let fixed_code = apply_suggestions(&unfixed_code, &suggestions).expect( 2620 let fixed_code = apply_suggestions(&unfixed_code, &suggestions).expect(&format!(
2594 &format!("failed to apply suggestions for {:?} with rustfix", self.testpaths.file) 2621 "failed to apply suggestions for {:?} with rustfix",
2595 ); 2622 self.testpaths.file
2623 ));
2596 2624
2597 errors += self.compare_output("fixed", &fixed_code, &expected_fixed); 2625 errors += self.compare_output("fixed", &fixed_code, &expected_fixed);
2598 } else if !expected_fixed.is_empty() { 2626 } else if !expected_fixed.is_empty() {
2599 panic!("the `// run-rustfix` directive wasn't found but a `*.fixed` \ 2627 panic!(
2600 file was found"); 2628 "the `// run-rustfix` directive wasn't found but a `*.fixed` \
2629 file was found"
2630 );
2601 } 2631 }
2602 2632
2603 if errors > 0 { 2633 if errors > 0 {
2604 println!("To update references, rerun the tests and pass the `--bless` flag"); 2634 println!("To update references, rerun the tests and pass the `--bless` flag");
2605 let relative_path_to_file = self.testpaths 2635 let relative_path_to_file = self
2636 .testpaths
2606 .relative_dir 2637 .relative_dir
2607 .join(self.testpaths.file.file_name().unwrap()); 2638 .join(self.testpaths.file.file_name().unwrap());
2608 println!( 2639 println!(
@@ -2784,11 +2815,7 @@ impl<'test> TestCx<'test> {
2784 Test Name: {}\n\ 2815 Test Name: {}\n\
2785 Expected:\n{}\n\ 2816 Expected:\n{}\n\
2786 Actual:\n{}", 2817 Actual:\n{}",
2787 extra_msg, 2818 extra_msg, expected_line, test_name, expected_content, normalize_all
2788 expected_line,
2789 test_name,
2790 expected_content,
2791 normalize_all
2792 ); 2819 );
2793 }; 2820 };
2794 2821
@@ -2904,7 +2931,12 @@ impl<'test> TestCx<'test> {
2904 2931
2905 if !path.exists() { 2932 if !path.exists() {
2906 if let Some(CompareMode::Polonius) = self.config.compare_mode { 2933 if let Some(CompareMode::Polonius) = self.config.compare_mode {
2907 path = expected_output_path(&self.testpaths, self.revision, &Some(CompareMode::Nll), kind); 2934 path = expected_output_path(
2935 &self.testpaths,
2936 self.revision,
2937 &Some(CompareMode::Nll),
2938 kind,
2939 );
2908 } 2940 }
2909 } 2941 }
2910 2942
@@ -2973,7 +3005,8 @@ impl<'test> TestCx<'test> {
2973 } 3005 }
2974 3006
2975 let mode = self.config.compare_mode.as_ref().map_or("", |m| m.to_str()); 3007 let mode = self.config.compare_mode.as_ref().map_or("", |m| m.to_str());
2976 let output_file = self.output_base_name() 3008 let output_file = self
3009 .output_base_name()
2977 .with_extra_extension(self.revision.unwrap_or("")) 3010 .with_extra_extension(self.revision.unwrap_or(""))
2978 .with_extra_extension(mode) 3011 .with_extra_extension(mode)
2979 .with_extra_extension(kind); 3012 .with_extra_extension(kind);
@@ -3023,7 +3056,8 @@ impl<'test> TestCx<'test> {
3023 3056
3024 fn create_stamp(&self) { 3057 fn create_stamp(&self) {
3025 let mut f = File::create(::stamp(&self.config, self.testpaths, self.revision)).unwrap(); 3058 let mut f = File::create(::stamp(&self.config, self.testpaths, self.revision)).unwrap();
3026 f.write_all(compute_stamp_hash(&self.config).as_bytes()).unwrap(); 3059 f.write_all(compute_stamp_hash(&self.config).as_bytes())
3060 .unwrap();
3027 } 3061 }
3028} 3062}
3029 3063