diff options
author | bors <bors@rust-lang.org> | 2018-05-30 22:59:21 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2018-05-30 22:59:21 +0000 |
commit | e1eed38fed677017cc504f4f01a7f2b2b52b6718 (patch) | |
tree | 01948ccafea9a40632758805847ce7ec9ea1bbcf | |
parent | Auto merge of #51215 - eddyb:visit-for-a-lifetime, r=nikomatsakis (diff) | |
parent | Run rustfmt (diff) | |
download | grust-e1eed38fed677017cc504f4f01a7f2b2b52b6718.tar.gz grust-e1eed38fed677017cc504f4f01a7f2b2b52b6718.tar.bz2 grust-e1eed38fed677017cc504f4f01a7f2b2b52b6718.tar.xz |
Auto merge of #51138 - spastorino:add-polonius-compare-mode, r=pnkfelix
Add polonius compare mode
**This is now ready to review/merge**
-rw-r--r-- | src/bootstrap/builder.rs | 1247 | ||||
-rw-r--r-- | src/bootstrap/flags.rs | 233 | ||||
-rw-r--r-- | src/bootstrap/test.rs | 394 | ||||
-rw-r--r-- | src/tools/compiletest/src/common.rs | 3 | ||||
-rw-r--r-- | src/tools/compiletest/src/runtest.rs | 135 |
5 files changed, 1230 insertions, 782 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index f84ddf8a17..4fdb36b3f6 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs | |||
@@ -11,6 +11,7 @@ | |||
11 | use std::any::Any; | 11 | use std::any::Any; |
12 | use std::cell::{Cell, RefCell}; | 12 | use std::cell::{Cell, RefCell}; |
13 | use std::collections::BTreeSet; | 13 | use std::collections::BTreeSet; |
14 | use std::collections::HashMap; | ||
14 | use std::env; | 15 | use std::env; |
15 | use std::fmt::Debug; | 16 | use std::fmt::Debug; |
16 | use std::fs; | 17 | use std::fs; |
@@ -18,26 +19,25 @@ use std::hash::Hash; | |||
18 | use std::ops::Deref; | 19 | use std::ops::Deref; |
19 | use std::path::{Path, PathBuf}; | 20 | use std::path::{Path, PathBuf}; |
20 | use std::process::Command; | 21 | use std::process::Command; |
21 | use std::time::{Instant, Duration}; | 22 | use std::time::{Duration, Instant}; |
22 | use std::collections::HashMap; | ||
23 | 23 | ||
24 | use cache::{Cache, Interned, INTERNER}; | ||
25 | use check; | ||
24 | use compile; | 26 | use compile; |
25 | use install; | ||
26 | use dist; | 27 | use dist; |
27 | use util::{exe, libdir, add_lib_path}; | ||
28 | use {Build, Mode, DocTests}; | ||
29 | use cache::{INTERNER, Interned, Cache}; | ||
30 | use check; | ||
31 | use test; | ||
32 | use flags::Subcommand; | ||
33 | use doc; | 28 | use doc; |
34 | use tool; | 29 | use flags::Subcommand; |
30 | use install; | ||
35 | use native; | 31 | use native; |
32 | use test; | ||
33 | use tool; | ||
34 | use util::{add_lib_path, exe, libdir}; | ||
35 | use {Build, DocTests, Mode}; | ||
36 | 36 | ||
37 | pub use Compiler; | 37 | pub use Compiler; |
38 | 38 | ||
39 | use petgraph::Graph; | ||
40 | use petgraph::graph::NodeIndex; | 39 | use petgraph::graph::NodeIndex; |
40 | use petgraph::Graph; | ||
41 | 41 | ||
42 | pub struct Builder<'a> { | 42 | pub 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)] |
114 | pub enum PathSet { | 114 | pub enum PathSet { |
115 | Set (BTreeSet<PathBuf>), | 115 | Set(BTreeSet<PathBuf>), |
116 | Suite (PathBuf) | 116 | Suite(PathBuf), |
117 | } | 117 | } |
118 | 118 | ||
119 | impl PathSet { | 119 | impl 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)] |
971 | mod __test { | 1135 | mod __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] |
@@ -1457,6 +1722,7 @@ mod __test { | |||
1457 | fail_fast: true, | 1722 | fail_fast: true, |
1458 | doc_tests: DocTests::No, | 1723 | doc_tests: DocTests::No, |
1459 | bless: false, | 1724 | bless: false, |
1725 | compare_mode: None, | ||
1460 | }; | 1726 | }; |
1461 | 1727 | ||
1462 | let build = Build::new(config); | 1728 | let build = Build::new(config); |
@@ -1471,14 +1737,15 @@ mod __test { | |||
1471 | 1737 | ||
1472 | // Ensure we don't build any compiler artifacts. | 1738 | // Ensure we don't build any compiler artifacts. |
1473 | assert!(builder.cache.all::<compile::Rustc>().is_empty()); | 1739 | assert!(builder.cache.all::<compile::Rustc>().is_empty()); |
1474 | assert_eq!(first(builder.cache.all::<test::Crate>()), &[ | 1740 | assert_eq!( |
1475 | test::Crate { | 1741 | first(builder.cache.all::<test::Crate>()), |
1742 | &[test::Crate { | ||
1476 | compiler: Compiler { host, stage: 0 }, | 1743 | compiler: Compiler { host, stage: 0 }, |
1477 | target: host, | 1744 | target: host, |
1478 | mode: Mode::Libstd, | 1745 | mode: Mode::Libstd, |
1479 | test_kind: test::TestKind::Test, | 1746 | test_kind: test::TestKind::Test, |
1480 | krate: INTERNER.intern_str("std"), | 1747 | krate: INTERNER.intern_str("std"), |
1481 | }, | 1748 | },] |
1482 | ]); | 1749 | ); |
1483 | } | 1750 | } |
1484 | } | 1751 | } |
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 90dd5d819b..e5dceccdf8 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs | |||
@@ -19,10 +19,10 @@ use std::process; | |||
19 | 19 | ||
20 | use getopts::Options; | 20 | use getopts::Options; |
21 | 21 | ||
22 | use {Build, DocTests}; | 22 | use builder::Builder; |
23 | use config::Config; | 23 | use config::Config; |
24 | use metadata; | 24 | use metadata; |
25 | use builder::Builder; | 25 | use {Build, DocTests}; |
26 | 26 | ||
27 | use cache::{Interned, INTERNER}; | 27 | use cache::{Interned, INTERNER}; |
28 | 28 | ||
@@ -61,6 +61,7 @@ pub enum Subcommand { | |||
61 | paths: Vec<PathBuf>, | 61 | paths: Vec<PathBuf>, |
62 | /// Whether to automatically update stderr/stdout files | 62 | /// Whether to automatically update stderr/stdout files |
63 | bless: bool, | 63 | bless: bool, |
64 | compare_mode: Option<String>, | ||
64 | test_args: Vec<String>, | 65 | test_args: Vec<String>, |
65 | rustc_args: Vec<String>, | 66 | rustc_args: Vec<String>, |
66 | fail_fast: bool, | 67 | fail_fast: bool, |
@@ -92,7 +93,8 @@ impl Default for Subcommand { | |||
92 | impl Flags { | 93 | impl Flags { |
93 | pub fn parse(args: &[String]) -> Flags { | 94 | pub fn parse(args: &[String]) -> Flags { |
94 | let mut extra_help = String::new(); | 95 | let mut extra_help = String::new(); |
95 | let mut subcommand_help = format!("\ | 96 | let mut subcommand_help = format!( |
97 | "\ | ||
96 | Usage: x.py <subcommand> [options] [<paths>...] | 98 | Usage: x.py <subcommand> [options] [<paths>...] |
97 | 99 | ||
98 | Subcommands: | 100 | Subcommands: |
@@ -105,7 +107,8 @@ Subcommands: | |||
105 | dist Build distribution artifacts | 107 | dist Build distribution artifacts |
106 | install Install distribution artifacts | 108 | install Install distribution artifacts |
107 | 109 | ||
108 | To learn more about a subcommand, run `./x.py <subcommand> -h`"); | 110 | To learn more about a subcommand, run `./x.py <subcommand> -h`" |
111 | ); | ||
109 | 112 | ||
110 | let mut opts = Options::new(); | 113 | let mut opts = Options::new(); |
111 | // Options common to all subcommands | 114 | // Options common to all subcommands |
@@ -123,33 +126,39 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"); | |||
123 | 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"); |
124 | 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"); |
125 | opts.optflag("h", "help", "print this help message"); | 128 | opts.optflag("h", "help", "print this help message"); |
126 | opts.optopt("", "warnings", "if value is deny, will deny warnings, otherwise use default", | 129 | opts.optopt( |
127 | "VALUE"); | 130 | "", |
131 | "warnings", | ||
132 | "if value is deny, will deny warnings, otherwise use default", | ||
133 | "VALUE", | ||
134 | ); | ||
128 | opts.optopt("", "error-format", "rustc error format", "FORMAT"); | 135 | opts.optopt("", "error-format", "rustc error format", "FORMAT"); |
129 | 136 | ||
130 | // fn usage() | 137 | // fn usage() |
131 | let usage = |exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! { | 138 | let usage = |
132 | println!("{}", opts.usage(subcommand_help)); | 139 | |exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! { |
133 | if !extra_help.is_empty() { | 140 | println!("{}", opts.usage(subcommand_help)); |
134 | println!("{}", extra_help); | 141 | if !extra_help.is_empty() { |
135 | } | 142 | println!("{}", extra_help); |
136 | process::exit(exit_code); | 143 | } |
137 | }; | 144 | process::exit(exit_code); |
145 | }; | ||
138 | 146 | ||
139 | // 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 |
140 | // 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 |
141 | // 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 |
142 | // 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 |
143 | // there on out. | 151 | // there on out. |
144 | let subcommand = args.iter().find(|&s| | 152 | let subcommand = args.iter().find(|&s| { |
145 | (s == "build") | 153 | (s == "build") |
146 | || (s == "check") | 154 | || (s == "check") |
147 | || (s == "test") | 155 | || (s == "test") |
148 | || (s == "bench") | 156 | || (s == "bench") |
149 | || (s == "doc") | 157 | || (s == "doc") |
150 | || (s == "clean") | 158 | || (s == "clean") |
151 | || (s == "dist") | 159 | || (s == "dist") |
152 | || (s == "install")); | 160 | || (s == "install") |
161 | }); | ||
153 | let subcommand = match subcommand { | 162 | let subcommand = match subcommand { |
154 | Some(s) => s, | 163 | Some(s) => s, |
155 | None => { | 164 | None => { |
@@ -164,7 +173,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"); | |||
164 | 173 | ||
165 | // Some subcommands get extra options | 174 | // Some subcommands get extra options |
166 | match subcommand.as_str() { | 175 | match subcommand.as_str() { |
167 | "test" => { | 176 | "test" => { |
168 | opts.optflag("", "no-fail-fast", "Run all tests regardless of failure"); | 177 | opts.optflag("", "no-fail-fast", "Run all tests regardless of failure"); |
169 | opts.optmulti("", "test-args", "extra arguments", "ARGS"); | 178 | opts.optmulti("", "test-args", "extra arguments", "ARGS"); |
170 | opts.optmulti( | 179 | opts.optmulti( |
@@ -175,11 +184,25 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"); | |||
175 | ); | 184 | ); |
176 | opts.optflag("", "no-doc", "do not run doc tests"); | 185 | opts.optflag("", "no-doc", "do not run doc tests"); |
177 | opts.optflag("", "doc", "only run doc tests"); | 186 | opts.optflag("", "doc", "only run doc tests"); |
178 | opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests"); | 187 | opts.optflag( |
179 | }, | 188 | "", |
180 | "bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); }, | 189 | "bless", |
181 | "clean" => { opts.optflag("", "all", "clean all build artifacts"); }, | 190 | "update all stderr/stdout files of failing ui tests", |
182 | _ => { }, | 191 | ); |
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 | _ => {} | ||
183 | }; | 206 | }; |
184 | 207 | ||
185 | // Done specifying what options are possible, so do the getopts parsing | 208 | // Done specifying what options are possible, so do the getopts parsing |
@@ -199,21 +222,24 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"); | |||
199 | if check_subcommand != subcommand { | 222 | if check_subcommand != subcommand { |
200 | pass_sanity_check = false; | 223 | pass_sanity_check = false; |
201 | } | 224 | } |
202 | }, | 225 | } |
203 | None => { | 226 | None => { |
204 | pass_sanity_check = false; | 227 | pass_sanity_check = false; |
205 | } | 228 | } |
206 | } | 229 | } |
207 | if !pass_sanity_check { | 230 | if !pass_sanity_check { |
208 | println!("{}\n", subcommand_help); | 231 | println!("{}\n", subcommand_help); |
209 | println!("Sorry, I couldn't figure out which subcommand you were trying to specify.\n\ | 232 | println!( |
210 | 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 | ); | ||
211 | process::exit(1); | 236 | process::exit(1); |
212 | } | 237 | } |
213 | // Extra help text for some commands | 238 | // Extra help text for some commands |
214 | match subcommand.as_str() { | 239 | match subcommand.as_str() { |
215 | "build" => { | 240 | "build" => { |
216 | subcommand_help.push_str("\n | 241 | subcommand_help.push_str( |
242 | "\n | ||
217 | Arguments: | 243 | Arguments: |
218 | 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 |
219 | and/or artifacts to compile. For example: | 245 | and/or artifacts to compile. For example: |
@@ -235,10 +261,12 @@ Arguments: | |||
235 | This will first build everything once (like --stage 0 without further | 261 | This will first build everything once (like --stage 0 without further |
236 | 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 |
237 | src/libtest and its dependencies. | 263 | src/libtest and its dependencies. |
238 | Once this is done, build/$ARCH/stage1 contains a usable compiler."); | 264 | Once this is done, build/$ARCH/stage1 contains a usable compiler.", |
265 | ); | ||
239 | } | 266 | } |
240 | "check" => { | 267 | "check" => { |
241 | subcommand_help.push_str("\n | 268 | subcommand_help.push_str( |
269 | "\n | ||
242 | Arguments: | 270 | Arguments: |
243 | 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 |
244 | and/or artifacts to compile. For example: | 272 | and/or artifacts to compile. For example: |
@@ -250,10 +278,12 @@ Arguments: | |||
250 | 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 |
251 | 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 |
252 | 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 |
253 | the compiler."); | 281 | the compiler.", |
282 | ); | ||
254 | } | 283 | } |
255 | "test" => { | 284 | "test" => { |
256 | subcommand_help.push_str("\n | 285 | subcommand_help.push_str( |
286 | "\n | ||
257 | Arguments: | 287 | Arguments: |
258 | 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 |
259 | should be compiled and run. For example: | 289 | should be compiled and run. For example: |
@@ -262,15 +292,18 @@ Arguments: | |||
262 | ./x.py test src/libstd --test-args hash_map | 292 | ./x.py test src/libstd --test-args hash_map |
263 | ./x.py test src/libstd --stage 0 | 293 | ./x.py test src/libstd --stage 0 |
264 | ./x.py test src/test/ui --bless | 294 | ./x.py test src/test/ui --bless |
295 | ./x.py test src/test/ui --compare-mode nll | ||
265 | 296 | ||
266 | If no arguments are passed then the complete artifacts for that stage are | 297 | If no arguments are passed then the complete artifacts for that stage are |
267 | compiled and tested. | 298 | compiled and tested. |
268 | 299 | ||
269 | ./x.py test | 300 | ./x.py test |
270 | ./x.py test --stage 1"); | 301 | ./x.py test --stage 1", |
302 | ); | ||
271 | } | 303 | } |
272 | "doc" => { | 304 | "doc" => { |
273 | subcommand_help.push_str("\n | 305 | subcommand_help.push_str( |
306 | "\n | ||
274 | Arguments: | 307 | Arguments: |
275 | This subcommand accepts a number of paths to directories of documentation | 308 | This subcommand accepts a number of paths to directories of documentation |
276 | to build. For example: | 309 | to build. For example: |
@@ -282,12 +315,16 @@ Arguments: | |||
282 | If no arguments are passed then everything is documented: | 315 | If no arguments are passed then everything is documented: |
283 | 316 | ||
284 | ./x.py doc | 317 | ./x.py doc |
285 | ./x.py doc --stage 1"); | 318 | ./x.py doc --stage 1", |
319 | ); | ||
286 | } | 320 | } |
287 | _ => { } | 321 | _ => {} |
288 | }; | 322 | }; |
289 | // Get any optional paths which occur after the subcommand | 323 | // Get any optional paths which occur after the subcommand |
290 | 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>>(); | ||
291 | 328 | ||
292 | 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(|| { |
293 | if fs::metadata("config.toml").is_ok() { | 330 | if fs::metadata("config.toml").is_ok() { |
@@ -306,9 +343,12 @@ Arguments: | |||
306 | let maybe_rules_help = Builder::get_help(&build, subcommand.as_str()); | 343 | let maybe_rules_help = Builder::get_help(&build, subcommand.as_str()); |
307 | 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()); |
308 | } else if subcommand.as_str() != "clean" { | 345 | } else if subcommand.as_str() != "clean" { |
309 | extra_help.push_str(format!( | 346 | extra_help.push_str( |
310 | "Run `./x.py {} -h -v` to see a list of available paths.", | 347 | format!( |
311 | subcommand).as_str()); | 348 | "Run `./x.py {} -h -v` to see a list of available paths.", |
349 | subcommand | ||
350 | ).as_str(), | ||
351 | ); | ||
312 | } | 352 | } |
313 | 353 | ||
314 | // User passed in -h/--help? | 354 | // User passed in -h/--help? |
@@ -317,37 +357,28 @@ Arguments: | |||
317 | } | 357 | } |
318 | 358 | ||
319 | let cmd = match subcommand.as_str() { | 359 | let cmd = match subcommand.as_str() { |
320 | "build" => { | 360 | "build" => Subcommand::Build { paths: paths }, |
321 | Subcommand::Build { paths: paths } | 361 | "check" => Subcommand::Check { paths: paths }, |
322 | } | 362 | "test" => Subcommand::Test { |
323 | "check" => { | 363 | paths, |
324 | Subcommand::Check { paths: paths } | 364 | bless: matches.opt_present("bless"), |
325 | } | 365 | compare_mode: matches.opt_str("compare-mode"), |
326 | "test" => { | 366 | test_args: matches.opt_strs("test-args"), |
327 | Subcommand::Test { | 367 | rustc_args: matches.opt_strs("rustc-args"), |
328 | paths, | 368 | fail_fast: !matches.opt_present("no-fail-fast"), |
329 | bless: matches.opt_present("bless"), | 369 | doc_tests: if matches.opt_present("doc") { |
330 | test_args: matches.opt_strs("test-args"), | 370 | DocTests::Only |
331 | rustc_args: matches.opt_strs("rustc-args"), | 371 | } else if matches.opt_present("no-doc") { |
332 | fail_fast: !matches.opt_present("no-fail-fast"), | 372 | DocTests::No |
333 | doc_tests: if matches.opt_present("doc") { | 373 | } else { |
334 | DocTests::Only | 374 | DocTests::Yes |
335 | } else if matches.opt_present("no-doc") { | 375 | }, |
336 | DocTests::No | 376 | }, |
337 | } else { | 377 | "bench" => Subcommand::Bench { |
338 | DocTests::Yes | 378 | paths, |
339 | } | 379 | test_args: matches.opt_strs("test-args"), |
340 | } | 380 | }, |
341 | } | 381 | "doc" => Subcommand::Doc { paths: paths }, |
342 | "bench" => { | ||
343 | Subcommand::Bench { | ||
344 | paths, | ||
345 | test_args: matches.opt_strs("test-args"), | ||
346 | } | ||
347 | } | ||
348 | "doc" => { | ||
349 | Subcommand::Doc { paths: paths } | ||
350 | } | ||
351 | "clean" => { | 382 | "clean" => { |
352 | if paths.len() > 0 { | 383 | if paths.len() > 0 { |
353 | println!("\nclean does not take a path argument\n"); | 384 | println!("\nclean does not take a path argument\n"); |
@@ -358,22 +389,13 @@ Arguments: | |||
358 | all: matches.opt_present("all"), | 389 | all: matches.opt_present("all"), |
359 | } | 390 | } |
360 | } | 391 | } |
361 | "dist" => { | 392 | "dist" => Subcommand::Dist { paths }, |
362 | Subcommand::Dist { | 393 | "install" => Subcommand::Install { paths }, |
363 | paths, | ||
364 | } | ||
365 | } | ||
366 | "install" => { | ||
367 | Subcommand::Install { | ||
368 | paths, | ||
369 | } | ||
370 | } | ||
371 | _ => { | 394 | _ => { |
372 | usage(1, &opts, &subcommand_help, &extra_help); | 395 | usage(1, &opts, &subcommand_help, &extra_help); |
373 | } | 396 | } |
374 | }; | 397 | }; |
375 | 398 | ||
376 | |||
377 | Flags { | 399 | Flags { |
378 | verbose: matches.opt_count("verbose"), | 400 | verbose: matches.opt_count("verbose"), |
379 | stage: matches.opt_str("stage").map(|j| j.parse().unwrap()), | 401 | stage: matches.opt_str("stage").map(|j| j.parse().unwrap()), |
@@ -382,15 +404,21 @@ Arguments: | |||
382 | rustc_error_format: matches.opt_str("error-format"), | 404 | rustc_error_format: matches.opt_str("error-format"), |
383 | 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()), |
384 | host: split(matches.opt_strs("host")) | 406 | host: split(matches.opt_strs("host")) |
385 | .into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(), | 407 | .into_iter() |
408 | .map(|x| INTERNER.intern_string(x)) | ||
409 | .collect::<Vec<_>>(), | ||
386 | target: split(matches.opt_strs("target")) | 410 | target: split(matches.opt_strs("target")) |
387 | .into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(), | 411 | .into_iter() |
412 | .map(|x| INTERNER.intern_string(x)) | ||
413 | .collect::<Vec<_>>(), | ||
388 | config: cfg_file, | 414 | config: cfg_file, |
389 | jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()), | 415 | jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()), |
390 | cmd, | 416 | cmd, |
391 | incremental: matches.opt_present("incremental"), | 417 | incremental: matches.opt_present("incremental"), |
392 | exclude: split(matches.opt_strs("exclude")) | 418 | exclude: split(matches.opt_strs("exclude")) |
393 | .into_iter().map(|p| p.into()).collect::<Vec<_>>(), | 419 | .into_iter() |
420 | .map(|p| p.into()) | ||
421 | .collect::<Vec<_>>(), | ||
394 | warnings: matches.opt_str("warnings").map(|v| v == "deny"), | 422 | warnings: matches.opt_str("warnings").map(|v| v == "deny"), |
395 | } | 423 | } |
396 | } | 424 | } |
@@ -399,9 +427,11 @@ Arguments: | |||
399 | impl Subcommand { | 427 | impl Subcommand { |
400 | pub fn test_args(&self) -> Vec<&str> { | 428 | pub fn test_args(&self) -> Vec<&str> { |
401 | match *self { | 429 | match *self { |
402 | Subcommand::Test { ref test_args, .. } | | 430 | Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => { |
403 | Subcommand::Bench { ref test_args, .. } => { | 431 | test_args |
404 | test_args.iter().flat_map(|s| s.split_whitespace()).collect() | 432 | .iter() |
433 | .flat_map(|s| s.split_whitespace()) | ||
434 | .collect() | ||
405 | } | 435 | } |
406 | _ => Vec::new(), | 436 | _ => Vec::new(), |
407 | } | 437 | } |
@@ -409,9 +439,10 @@ impl Subcommand { | |||
409 | 439 | ||
410 | pub fn rustc_args(&self) -> Vec<&str> { | 440 | pub fn rustc_args(&self) -> Vec<&str> { |
411 | match *self { | 441 | match *self { |
412 | Subcommand::Test { ref rustc_args, .. } => { | 442 | Subcommand::Test { ref rustc_args, .. } => rustc_args |
413 | rustc_args.iter().flat_map(|s| s.split_whitespace()).collect() | 443 | .iter() |
414 | } | 444 | .flat_map(|s| s.split_whitespace()) |
445 | .collect(), | ||
415 | _ => Vec::new(), | 446 | _ => Vec::new(), |
416 | } | 447 | } |
417 | } | 448 | } |
@@ -436,8 +467,20 @@ impl Subcommand { | |||
436 | _ => false, | 467 | _ => false, |
437 | } | 468 | } |
438 | } | 469 | } |
470 | |||
471 | pub fn compare_mode(&self) -> Option<&str> { | ||
472 | match *self { | ||
473 | Subcommand::Test { | ||
474 | ref compare_mode, .. | ||
475 | } => compare_mode.as_ref().map(|s| &s[..]), | ||
476 | _ => None, | ||
477 | } | ||
478 | } | ||
439 | } | 479 | } |
440 | 480 | ||
441 | fn split(s: Vec<String>) -> Vec<String> { | 481 | fn split(s: Vec<String>) -> Vec<String> { |
442 | 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() | ||
443 | } | 486 | } |
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 7a4924f03c..9284778679 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs | |||
@@ -15,26 +15,26 @@ | |||
15 | 15 | ||
16 | use std::env; | 16 | use std::env; |
17 | use std::ffi::OsString; | 17 | use std::ffi::OsString; |
18 | use std::iter; | ||
19 | use std::fmt; | 18 | use std::fmt; |
20 | use std::fs::{self, File}; | 19 | use std::fs::{self, File}; |
21 | use std::path::{PathBuf, Path}; | ||
22 | use std::process::Command; | ||
23 | use std::io::Read; | 20 | use std::io::Read; |
21 | use std::iter; | ||
22 | use std::path::{Path, PathBuf}; | ||
23 | use std::process::Command; | ||
24 | 24 | ||
25 | use build_helper::{self, output}; | 25 | use build_helper::{self, output}; |
26 | 26 | ||
27 | use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step}; | 27 | use builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; |
28 | use Crate as CargoCrate; | 28 | use cache::{Interned, INTERNER}; |
29 | use cache::{INTERNER, Interned}; | ||
30 | use compile; | 29 | use compile; |
31 | use dist; | 30 | use dist; |
31 | use flags::Subcommand; | ||
32 | use native; | 32 | use native; |
33 | use tool::{self, Tool}; | 33 | use tool::{self, Tool}; |
34 | use util::{self, dylib_path, dylib_path_var}; | ||
35 | use {Mode, DocTests}; | ||
36 | use toolstate::ToolState; | 34 | use toolstate::ToolState; |
37 | use flags::Subcommand; | 35 | use util::{self, dylib_path, dylib_path_var}; |
36 | use Crate as CargoCrate; | ||
37 | use {DocTests, Mode}; | ||
38 | 38 | ||
39 | const ADB_TEST_DIR: &str = "/data/tmp/work"; | 39 | const 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 | } |
@@ -887,7 +914,6 @@ impl Step for Compiletest { | |||
887 | let target = self.target; | 914 | let target = self.target; |
888 | let mode = self.mode; | 915 | let mode = self.mode; |
889 | let suite = self.suite; | 916 | let suite = self.suite; |
890 | let compare_mode = self.compare_mode; | ||
891 | 917 | ||
892 | // Path for test suite | 918 | // Path for test suite |
893 | let suite_path = self.path.unwrap_or(""); | 919 | let suite_path = self.path.unwrap_or(""); |
@@ -919,7 +945,7 @@ impl Step for Compiletest { | |||
919 | 945 | ||
920 | builder.ensure(dist::DebuggerScripts { | 946 | builder.ensure(dist::DebuggerScripts { |
921 | sysroot: builder.sysroot(compiler), | 947 | sysroot: builder.sysroot(compiler), |
922 | host: target | 948 | host: target, |
923 | }); | 949 | }); |
924 | } | 950 | } |
925 | 951 | ||
@@ -927,7 +953,8 @@ impl Step for Compiletest { | |||
927 | // FIXME: Does pretty need librustc compiled? Note that there are | 953 | // FIXME: Does pretty need librustc compiled? Note that there are |
928 | // fulldeps test suites with mode = pretty as well. | 954 | // fulldeps test suites with mode = pretty as well. |
929 | mode == "pretty" || | 955 | mode == "pretty" || |
930 | mode == "rustdoc" { | 956 | mode == "rustdoc" |
957 | { | ||
931 | builder.ensure(compile::Rustc { compiler, target }); | 958 | builder.ensure(compile::Rustc { compiler, target }); |
932 | } | 959 | } |
933 | 960 | ||
@@ -940,31 +967,41 @@ impl Step for Compiletest { | |||
940 | // 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 |
941 | // of them! | 968 | // of them! |
942 | 969 | ||
943 | cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler)); | 970 | cmd.arg("--compile-lib-path") |
944 | 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)); | ||
945 | cmd.arg("--rustc-path").arg(builder.rustc(compiler)); | 974 | cmd.arg("--rustc-path").arg(builder.rustc(compiler)); |
946 | 975 | ||
947 | let is_rustdoc_ui = suite.ends_with("rustdoc-ui"); | 976 | let is_rustdoc_ui = suite.ends_with("rustdoc-ui"); |
948 | 977 | ||
949 | // Avoid depending on rustdoc when we don't need it. | 978 | // Avoid depending on rustdoc when we don't need it. |
950 | if mode == "rustdoc" || | 979 | if mode == "rustdoc" |
951 | (mode == "run-make" && suite.ends_with("fulldeps")) || | 980 | || (mode == "run-make" && suite.ends_with("fulldeps")) |
952 | (mode == "ui" && is_rustdoc_ui) { | 981 | || (mode == "ui" && is_rustdoc_ui) |
953 | cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host)); | 982 | { |
983 | cmd.arg("--rustdoc-path") | ||
984 | .arg(builder.rustdoc(compiler.host)); | ||
954 | } | 985 | } |
955 | 986 | ||
956 | cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite)); | 987 | cmd.arg("--src-base") |
957 | cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite)); | 988 | .arg(builder.src.join("src/test").join(suite)); |
958 | 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)); | ||
959 | cmd.arg("--mode").arg(mode); | 993 | cmd.arg("--mode").arg(mode); |
960 | cmd.arg("--target").arg(target); | 994 | cmd.arg("--target").arg(target); |
961 | cmd.arg("--host").arg(&*compiler.host); | 995 | cmd.arg("--host").arg(&*compiler.host); |
962 | cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build)); | 996 | cmd.arg("--llvm-filecheck") |
997 | .arg(builder.llvm_filecheck(builder.config.build)); | ||
963 | 998 | ||
964 | if builder.config.cmd.bless() { | 999 | if builder.config.cmd.bless() { |
965 | cmd.arg("--bless"); | 1000 | cmd.arg("--bless"); |
966 | } | 1001 | } |
967 | 1002 | ||
1003 | let compare_mode = builder.config.cmd.compare_mode().or(self.compare_mode); | ||
1004 | |||
968 | if let Some(ref nodejs) = builder.config.nodejs { | 1005 | if let Some(ref nodejs) = builder.config.nodejs { |
969 | cmd.arg("--nodejs").arg(nodejs); | 1006 | cmd.arg("--nodejs").arg(nodejs); |
970 | } | 1007 | } |
@@ -993,8 +1030,10 @@ impl Step for Compiletest { | |||
993 | cmd.arg("--host-rustcflags").arg(hostflags.join(" ")); | 1030 | cmd.arg("--host-rustcflags").arg(hostflags.join(" ")); |
994 | 1031 | ||
995 | let mut targetflags = flags.clone(); | 1032 | let mut targetflags = flags.clone(); |
996 | targetflags.push(format!("-Lnative={}", | 1033 | targetflags.push(format!( |
997 | builder.test_helpers_out(target).display())); | 1034 | "-Lnative={}", |
1035 | builder.test_helpers_out(target).display() | ||
1036 | )); | ||
998 | cmd.arg("--target-rustcflags").arg(targetflags.join(" ")); | 1037 | cmd.arg("--target-rustcflags").arg(targetflags.join(" ")); |
999 | 1038 | ||
1000 | cmd.arg("--docck-python").arg(builder.python()); | 1039 | cmd.arg("--docck-python").arg(builder.python()); |
@@ -1020,13 +1059,16 @@ impl Step for Compiletest { | |||
1020 | 1059 | ||
1021 | // Get paths from cmd args | 1060 | // Get paths from cmd args |
1022 | let paths = match &builder.config.cmd { | 1061 | let paths = match &builder.config.cmd { |
1023 | Subcommand::Test { ref paths, ..} => &paths[..], | 1062 | Subcommand::Test { ref paths, .. } => &paths[..], |
1024 | _ => &[] | 1063 | _ => &[], |
1025 | }; | 1064 | }; |
1026 | 1065 | ||
1027 | // Get test-args by striping suite path | 1066 | // Get test-args by striping suite path |
1028 | let mut test_args: Vec<&str> = paths.iter().filter(|p| p.starts_with(suite_path) && | 1067 | let mut test_args: Vec<&str> = paths |
1029 | 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(); | ||
1030 | 1072 | ||
1031 | test_args.append(&mut builder.config.cmd.test_args()); | 1073 | test_args.append(&mut builder.config.cmd.test_args()); |
1032 | 1074 | ||
@@ -1058,32 +1100,44 @@ impl Step for Compiletest { | |||
1058 | if !builder.config.dry_run && suite == "run-make-fulldeps" { | 1100 | if !builder.config.dry_run && suite == "run-make-fulldeps" { |
1059 | let llvm_components = output(Command::new(&llvm_config).arg("--components")); | 1101 | let llvm_components = output(Command::new(&llvm_config).arg("--components")); |
1060 | let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags")); | 1102 | let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags")); |
1061 | cmd.arg("--cc").arg(builder.cc(target)) | 1103 | cmd.arg("--cc") |
1062 | .arg("--cxx").arg(builder.cxx(target).unwrap()) | 1104 | .arg(builder.cc(target)) |
1063 | .arg("--cflags").arg(builder.cflags(target).join(" ")) | 1105 | .arg("--cxx") |
1064 | .arg("--llvm-components").arg(llvm_components.trim()) | 1106 | .arg(builder.cxx(target).unwrap()) |
1065 | .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()); | ||
1066 | if let Some(ar) = builder.ar(target) { | 1113 | if let Some(ar) = builder.ar(target) { |
1067 | cmd.arg("--ar").arg(ar); | 1114 | cmd.arg("--ar").arg(ar); |
1068 | } | 1115 | } |
1069 | } | 1116 | } |
1070 | } | 1117 | } |
1071 | if suite == "run-make-fulldeps" && !builder.config.llvm_enabled { | 1118 | if suite == "run-make-fulldeps" && !builder.config.llvm_enabled { |
1072 | builder.info( | 1119 | builder.info(&format!( |
1073 | &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 | )); | ||
1074 | return; | 1122 | return; |
1075 | } | 1123 | } |
1076 | 1124 | ||
1077 | if suite != "run-make-fulldeps" { | 1125 | if suite != "run-make-fulldeps" { |
1078 | cmd.arg("--cc").arg("") | 1126 | cmd.arg("--cc") |
1079 | .arg("--cxx").arg("") | 1127 | .arg("") |
1080 | .arg("--cflags").arg("") | 1128 | .arg("--cxx") |
1081 | .arg("--llvm-components").arg("") | 1129 | .arg("") |
1082 | .arg("--llvm-cxxflags").arg(""); | 1130 | .arg("--cflags") |
1131 | .arg("") | ||
1132 | .arg("--llvm-components") | ||
1133 | .arg("") | ||
1134 | .arg("--llvm-cxxflags") | ||
1135 | .arg(""); | ||
1083 | } | 1136 | } |
1084 | 1137 | ||
1085 | if builder.remote_tested(target) { | 1138 | if builder.remote_tested(target) { |
1086 | cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient)); | 1139 | cmd.arg("--remote-test-client") |
1140 | .arg(builder.tool_exe(Tool::RemoteTestClient)); | ||
1087 | } | 1141 | } |
1088 | 1142 | ||
1089 | // 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 |
@@ -1116,7 +1170,7 @@ impl Step for Compiletest { | |||
1116 | if target.contains("android") { | 1170 | if target.contains("android") { |
1117 | // Assume that cc for this target comes from the android sysroot | 1171 | // Assume that cc for this target comes from the android sysroot |
1118 | cmd.arg("--android-cross-path") | 1172 | cmd.arg("--android-cross-path") |
1119 | .arg(builder.cc(target).parent().unwrap().parent().unwrap()); | 1173 | .arg(builder.cc(target).parent().unwrap().parent().unwrap()); |
1120 | } else { | 1174 | } else { |
1121 | cmd.arg("--android-cross-path").arg(""); | 1175 | cmd.arg("--android-cross-path").arg(""); |
1122 | } | 1176 | } |
@@ -1124,16 +1178,20 @@ impl Step for Compiletest { | |||
1124 | builder.ci_env.force_coloring_in_ci(&mut cmd); | 1178 | builder.ci_env.force_coloring_in_ci(&mut cmd); |
1125 | 1179 | ||
1126 | let _folder = builder.fold_output(|| format!("test_{}", suite)); | 1180 | let _folder = builder.fold_output(|| format!("test_{}", suite)); |
1127 | builder.info(&format!("Check compiletest suite={} mode={} ({} -> {})", | 1181 | builder.info(&format!( |
1128 | suite, mode, &compiler.host, target)); | 1182 | "Check compiletest suite={} mode={} ({} -> {})", |
1183 | suite, mode, &compiler.host, target | ||
1184 | )); | ||
1129 | let _time = util::timeit(&builder); | 1185 | let _time = util::timeit(&builder); |
1130 | try_run(builder, &mut cmd); | 1186 | try_run(builder, &mut cmd); |
1131 | 1187 | ||
1132 | if let Some(compare_mode) = compare_mode { | 1188 | if let Some(compare_mode) = compare_mode { |
1133 | cmd.arg("--compare-mode").arg(compare_mode); | 1189 | cmd.arg("--compare-mode").arg(compare_mode); |
1134 | let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode)); | 1190 | let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode)); |
1135 | builder.info(&format!("Check compiletest suite={} mode={} compare_mode={} ({} -> {})", | 1191 | builder.info(&format!( |
1136 | suite, mode, compare_mode, &compiler.host, target)); | 1192 | "Check compiletest suite={} mode={} compare_mode={} ({} -> {})", |
1193 | suite, mode, compare_mode, &compiler.host, target | ||
1194 | )); | ||
1137 | let _time = util::timeit(&builder); | 1195 | let _time = util::timeit(&builder); |
1138 | try_run(builder, &mut cmd); | 1196 | try_run(builder, &mut cmd); |
1139 | } | 1197 | } |
@@ -1164,7 +1222,10 @@ impl Step for DocTest { | |||
1164 | fn run(self, builder: &Builder) { | 1222 | fn run(self, builder: &Builder) { |
1165 | let compiler = self.compiler; | 1223 | let compiler = self.compiler; |
1166 | 1224 | ||
1167 | builder.ensure(compile::Test { compiler, target: compiler.host }); | 1225 | builder.ensure(compile::Test { |
1226 | compiler, | ||
1227 | target: compiler.host, | ||
1228 | }); | ||
1168 | 1229 | ||
1169 | // 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 |
1170 | // tests for all files that end in `*.md` | 1231 | // tests for all files that end in `*.md` |
@@ -1176,7 +1237,7 @@ impl Step for DocTest { | |||
1176 | while let Some(p) = stack.pop() { | 1237 | while let Some(p) = stack.pop() { |
1177 | if p.is_dir() { | 1238 | if p.is_dir() { |
1178 | stack.extend(t!(p.read_dir()).map(|p| t!(p).path())); | 1239 | stack.extend(t!(p.read_dir()).map(|p| t!(p).path())); |
1179 | continue | 1240 | continue; |
1180 | } | 1241 | } |
1181 | 1242 | ||
1182 | if p.extension().and_then(|s| s.to_str()) != Some("md") { | 1243 | if p.extension().and_then(|s| s.to_str()) != Some("md") { |
@@ -1283,7 +1344,10 @@ impl Step for ErrorIndex { | |||
1283 | fn run(self, builder: &Builder) { | 1344 | fn run(self, builder: &Builder) { |
1284 | let compiler = self.compiler; | 1345 | let compiler = self.compiler; |
1285 | 1346 | ||
1286 | builder.ensure(compile::Std { compiler, target: compiler.host }); | 1347 | builder.ensure(compile::Std { |
1348 | compiler, | ||
1349 | target: compiler.host, | ||
1350 | }); | ||
1287 | 1351 | ||
1288 | let dir = testdir(builder, compiler.host); | 1352 | let dir = testdir(builder, compiler.host); |
1289 | t!(fs::create_dir_all(&dir)); | 1353 | t!(fs::create_dir_all(&dir)); |
@@ -1295,7 +1359,6 @@ impl Step for ErrorIndex { | |||
1295 | .env("CFG_BUILD", &builder.config.build) | 1359 | .env("CFG_BUILD", &builder.config.build) |
1296 | .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir()); | 1360 | .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir()); |
1297 | 1361 | ||
1298 | |||
1299 | let _folder = builder.fold_output(|| "test_error_index"); | 1362 | let _folder = builder.fold_output(|| "test_error_index"); |
1300 | builder.info(&format!("Testing error-index stage{}", compiler.stage)); | 1363 | builder.info(&format!("Testing error-index stage{}", compiler.stage)); |
1301 | let _time = util::timeit(&builder); | 1364 | let _time = util::timeit(&builder); |
@@ -1313,7 +1376,7 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool | |||
1313 | return true; | 1376 | return true; |
1314 | } | 1377 | } |
1315 | } | 1378 | } |
1316 | Err(_) => {}, | 1379 | Err(_) => {} |
1317 | } | 1380 | } |
1318 | 1381 | ||
1319 | builder.info(&format!("doc tests for: {}", markdown.display())); | 1382 | builder.info(&format!("doc tests for: {}", markdown.display())); |
@@ -1430,7 +1493,6 @@ impl Step for CrateNotDefault { | |||
1430 | } | 1493 | } |
1431 | } | 1494 | } |
1432 | 1495 | ||
1433 | |||
1434 | #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | 1496 | #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] |
1435 | pub struct Crate { | 1497 | pub struct Crate { |
1436 | pub compiler: Compiler, | 1498 | pub compiler: Compiler, |
@@ -1448,10 +1510,11 @@ impl Step for Crate { | |||
1448 | let builder = run.builder; | 1510 | let builder = run.builder; |
1449 | run = run.krate("test"); | 1511 | run = run.krate("test"); |
1450 | for krate in run.builder.in_tree_crates("std") { | 1512 | for krate in run.builder.in_tree_crates("std") { |
1451 | if krate.is_local(&run.builder) && | 1513 | if krate.is_local(&run.builder) |
1452 | !krate.name.contains("jemalloc") && | 1514 | && !krate.name.contains("jemalloc") |
1453 | !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) && | 1515 | && !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) |
1454 | krate.name != "dlmalloc" { | 1516 | && krate.name != "dlmalloc" |
1517 | { | ||
1455 | run = run.path(krate.local_path(&builder).to_str().unwrap()); | 1518 | run = run.path(krate.local_path(&builder).to_str().unwrap()); |
1456 | } | 1519 | } |
1457 | } | 1520 | } |
@@ -1566,38 +1629,59 @@ impl Step for Crate { | |||
1566 | } | 1629 | } |
1567 | 1630 | ||
1568 | if target.contains("emscripten") { | 1631 | if target.contains("emscripten") { |
1569 | cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), | 1632 | cargo.env( |
1570 | 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 | ); | ||
1571 | } else if target.starts_with("wasm32") { | 1640 | } else if target.starts_with("wasm32") { |
1572 | // Warn about running tests without the `wasm_syscall` feature enabled. | 1641 | // Warn about running tests without the `wasm_syscall` feature enabled. |
1573 | // The javascript shim implements the syscall interface so that test | 1642 | // The javascript shim implements the syscall interface so that test |
1574 | // output can be correctly reported. | 1643 | // output can be correctly reported. |
1575 | if !builder.config.wasm_syscall { | 1644 | if !builder.config.wasm_syscall { |
1576 | builder.info(&format!("Libstd was built without `wasm_syscall` feature enabled: \ | 1645 | builder.info(&format!( |
1577 | test output may not be visible.")); | 1646 | "Libstd was built without `wasm_syscall` feature enabled: \ |
1647 | test output may not be visible." | ||
1648 | )); | ||
1578 | } | 1649 | } |
1579 | 1650 | ||
1580 | // 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 |
1581 | // incompatible with `-C prefer-dynamic`, so disable that here | 1652 | // incompatible with `-C prefer-dynamic`, so disable that here |
1582 | cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); | 1653 | cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); |
1583 | 1654 | ||
1584 | let node = builder.config.nodejs.as_ref() | 1655 | let node = builder |
1656 | .config | ||
1657 | .nodejs | ||
1658 | .as_ref() | ||
1585 | .expect("nodejs not configured"); | 1659 | .expect("nodejs not configured"); |
1586 | let runner = format!("{} {}/src/etc/wasm32-shim.js", | 1660 | let runner = format!( |
1587 | node.display(), | 1661 | "{} {}/src/etc/wasm32-shim.js", |
1588 | builder.src.display()); | 1662 | node.display(), |
1663 | builder.src.display() | ||
1664 | ); | ||
1589 | cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner); | 1665 | cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner); |
1590 | } else if builder.remote_tested(target) { | 1666 | } else if builder.remote_tested(target) { |
1591 | cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), | 1667 | cargo.env( |
1592 | format!("{} run", | 1668 | format!("CARGO_TARGET_{}_RUNNER", envify(&target)), |
1593 | builder.tool_exe(Tool::RemoteTestClient).display())); | 1669 | format!("{} run", builder.tool_exe(Tool::RemoteTestClient).display()), |
1670 | ); | ||
1594 | } | 1671 | } |
1595 | 1672 | ||
1596 | let _folder = builder.fold_output(|| { | 1673 | let _folder = builder.fold_output(|| { |
1597 | format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate) | 1674 | format!( |
1675 | "{}_stage{}-{}", | ||
1676 | test_kind.subcommand(), | ||
1677 | compiler.stage, | ||
1678 | krate | ||
1679 | ) | ||
1598 | }); | 1680 | }); |
1599 | builder.info(&format!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage, | 1681 | builder.info(&format!( |
1600 | &compiler.host, target)); | 1682 | "{} {} stage{} ({} -> {})", |
1683 | test_kind, krate, compiler.stage, &compiler.host, target | ||
1684 | )); | ||
1601 | let _time = util::timeit(&builder); | 1685 | let _time = util::timeit(&builder); |
1602 | try_run(builder, &mut cargo); | 1686 | try_run(builder, &mut cargo); |
1603 | } | 1687 | } |
@@ -1635,11 +1719,13 @@ impl Step for CrateRustdoc { | |||
1635 | let compiler = builder.compiler(builder.top_stage, self.host); | 1719 | let compiler = builder.compiler(builder.top_stage, self.host); |
1636 | let target = compiler.host; | 1720 | let target = compiler.host; |
1637 | 1721 | ||
1638 | let mut cargo = tool::prepare_tool_cargo(builder, | 1722 | let mut cargo = tool::prepare_tool_cargo( |
1639 | compiler, | 1723 | builder, |
1640 | target, | 1724 | compiler, |
1641 | test_kind.subcommand(), | 1725 | target, |
1642 | "src/tools/rustdoc"); | 1726 | test_kind.subcommand(), |
1727 | "src/tools/rustdoc", | ||
1728 | ); | ||
1643 | if test_kind.subcommand() == "test" && !builder.fail_fast { | 1729 | if test_kind.subcommand() == "test" && !builder.fail_fast { |
1644 | cargo.arg("--no-fail-fast"); | 1730 | cargo.arg("--no-fail-fast"); |
1645 | } | 1731 | } |
@@ -1653,11 +1739,12 @@ impl Step for CrateRustdoc { | |||
1653 | cargo.arg("--quiet"); | 1739 | cargo.arg("--quiet"); |
1654 | } | 1740 | } |
1655 | 1741 | ||
1656 | let _folder = builder.fold_output(|| { | 1742 | let _folder = builder |
1657 | format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage) | 1743 | .fold_output(|| format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)); |
1658 | }); | 1744 | builder.info(&format!( |
1659 | builder.info(&format!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage, | 1745 | "{} rustdoc stage{} ({} -> {})", |
1660 | &compiler.host, target)); | 1746 | test_kind, compiler.stage, &compiler.host, target |
1747 | )); | ||
1661 | let _time = util::timeit(&builder); | 1748 | let _time = util::timeit(&builder); |
1662 | 1749 | ||
1663 | try_run(builder, &mut cargo); | 1750 | try_run(builder, &mut cargo); |
@@ -1665,12 +1752,13 @@ impl Step for CrateRustdoc { | |||
1665 | } | 1752 | } |
1666 | 1753 | ||
1667 | fn envify(s: &str) -> String { | 1754 | fn envify(s: &str) -> String { |
1668 | s.chars().map(|c| { | 1755 | s.chars() |
1669 | match c { | 1756 | .map(|c| match c { |
1670 | '-' => '_', | 1757 | '-' => '_', |
1671 | c => c, | 1758 | c => c, |
1672 | } | 1759 | }) |
1673 | }).flat_map(|c| c.to_uppercase()).collect() | 1760 | .flat_map(|c| c.to_uppercase()) |
1761 | .collect() | ||
1674 | } | 1762 | } |
1675 | 1763 | ||
1676 | /// 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 |
@@ -1699,7 +1787,7 @@ impl Step for RemoteCopyLibs { | |||
1699 | let compiler = self.compiler; | 1787 | let compiler = self.compiler; |
1700 | let target = self.target; | 1788 | let target = self.target; |
1701 | if !builder.remote_tested(target) { | 1789 | if !builder.remote_tested(target) { |
1702 | return | 1790 | return; |
1703 | } | 1791 | } |
1704 | 1792 | ||
1705 | builder.ensure(compile::Test { compiler, target }); | 1793 | builder.ensure(compile::Test { compiler, target }); |
@@ -1713,9 +1801,9 @@ impl Step for RemoteCopyLibs { | |||
1713 | let tool = builder.tool_exe(Tool::RemoteTestClient); | 1801 | let tool = builder.tool_exe(Tool::RemoteTestClient); |
1714 | let mut cmd = Command::new(&tool); | 1802 | let mut cmd = Command::new(&tool); |
1715 | cmd.arg("spawn-emulator") | 1803 | cmd.arg("spawn-emulator") |
1716 | .arg(target) | 1804 | .arg(target) |
1717 | .arg(&server) | 1805 | .arg(&server) |
1718 | .arg(builder.out.join("tmp")); | 1806 | .arg(builder.out.join("tmp")); |
1719 | if let Some(rootfs) = builder.qemu_rootfs(target) { | 1807 | if let Some(rootfs) = builder.qemu_rootfs(target) { |
1720 | cmd.arg(rootfs); | 1808 | cmd.arg(rootfs); |
1721 | } | 1809 | } |
@@ -1726,9 +1814,7 @@ impl Step for RemoteCopyLibs { | |||
1726 | let f = t!(f); | 1814 | let f = t!(f); |
1727 | let name = f.file_name().into_string().unwrap(); | 1815 | let name = f.file_name().into_string().unwrap(); |
1728 | if util::is_dylib(&name) { | 1816 | if util::is_dylib(&name) { |
1729 | builder.run(Command::new(&tool) | 1817 | builder.run(Command::new(&tool).arg("push").arg(f.path())); |
1730 | .arg("push") | ||
1731 | .arg(f.path())); | ||
1732 | } | 1818 | } |
1733 | } | 1819 | } |
1734 | } | 1820 | } |
@@ -1761,17 +1847,21 @@ impl Step for Distcheck { | |||
1761 | 1847 | ||
1762 | let mut cmd = Command::new("tar"); | 1848 | let mut cmd = Command::new("tar"); |
1763 | cmd.arg("-xzf") | 1849 | cmd.arg("-xzf") |
1764 | .arg(builder.ensure(dist::PlainSourceTarball)) | 1850 | .arg(builder.ensure(dist::PlainSourceTarball)) |
1765 | .arg("--strip-components=1") | 1851 | .arg("--strip-components=1") |
1766 | .current_dir(&dir); | 1852 | .current_dir(&dir); |
1767 | builder.run(&mut cmd); | 1853 | builder.run(&mut cmd); |
1768 | builder.run(Command::new("./configure") | 1854 | builder.run( |
1769 | .args(&builder.config.configure_args) | 1855 | Command::new("./configure") |
1770 | .arg("--enable-vendor") | 1856 | .args(&builder.config.configure_args) |
1771 | .current_dir(&dir)); | 1857 | .arg("--enable-vendor") |
1772 | builder.run(Command::new(build_helper::make(&builder.config.build)) | 1858 | .current_dir(&dir), |
1773 | .arg("check") | 1859 | ); |
1774 | .current_dir(&dir)); | 1860 | builder.run( |
1861 | Command::new(build_helper::make(&builder.config.build)) | ||
1862 | .arg("check") | ||
1863 | .current_dir(&dir), | ||
1864 | ); | ||
1775 | 1865 | ||
1776 | // 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 |
1777 | builder.info(&format!("Distcheck rust-src")); | 1867 | builder.info(&format!("Distcheck rust-src")); |
@@ -1781,17 +1871,19 @@ impl Step for Distcheck { | |||
1781 | 1871 | ||
1782 | let mut cmd = Command::new("tar"); | 1872 | let mut cmd = Command::new("tar"); |
1783 | cmd.arg("-xzf") | 1873 | cmd.arg("-xzf") |
1784 | .arg(builder.ensure(dist::Src)) | 1874 | .arg(builder.ensure(dist::Src)) |
1785 | .arg("--strip-components=1") | 1875 | .arg("--strip-components=1") |
1786 | .current_dir(&dir); | 1876 | .current_dir(&dir); |
1787 | builder.run(&mut cmd); | 1877 | builder.run(&mut cmd); |
1788 | 1878 | ||
1789 | 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"); |
1790 | builder.run(Command::new(&builder.initial_cargo) | 1880 | builder.run( |
1791 | .arg("generate-lockfile") | 1881 | Command::new(&builder.initial_cargo) |
1792 | .arg("--manifest-path") | 1882 | .arg("generate-lockfile") |
1793 | .arg(&toml) | 1883 | .arg("--manifest-path") |
1794 | .current_dir(&dir)); | 1884 | .arg(&toml) |
1885 | .current_dir(&dir), | ||
1886 | ); | ||
1795 | } | 1887 | } |
1796 | } | 1888 | } |
1797 | 1889 | ||
@@ -1807,11 +1899,11 @@ impl Step for Bootstrap { | |||
1807 | fn run(self, builder: &Builder) { | 1899 | fn run(self, builder: &Builder) { |
1808 | let mut cmd = Command::new(&builder.initial_cargo); | 1900 | let mut cmd = Command::new(&builder.initial_cargo); |
1809 | cmd.arg("test") | 1901 | cmd.arg("test") |
1810 | .current_dir(builder.src.join("src/bootstrap")) | 1902 | .current_dir(builder.src.join("src/bootstrap")) |
1811 | .env("RUSTFLAGS", "-Cdebuginfo=2") | 1903 | .env("RUSTFLAGS", "-Cdebuginfo=2") |
1812 | .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) | 1904 | .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) |
1813 | .env("RUSTC_BOOTSTRAP", "1") | 1905 | .env("RUSTC_BOOTSTRAP", "1") |
1814 | .env("RUSTC", &builder.initial_rustc); | 1906 | .env("RUSTC", &builder.initial_rustc); |
1815 | if let Some(flags) = option_env!("RUSTFLAGS") { | 1907 | if let Some(flags) = option_env!("RUSTFLAGS") { |
1816 | // Use the same rustc flags for testing as for "normal" compilation, | 1908 | // Use the same rustc flags for testing as for "normal" compilation, |
1817 | // 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/common.rs b/src/tools/compiletest/src/common.rs index b2ce5ce52f..951a72fec6 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs | |||
@@ -99,18 +99,21 @@ impl fmt::Display for Mode { | |||
99 | #[derive(Clone, PartialEq)] | 99 | #[derive(Clone, PartialEq)] |
100 | pub enum CompareMode { | 100 | pub enum CompareMode { |
101 | Nll, | 101 | Nll, |
102 | Polonius, | ||
102 | } | 103 | } |
103 | 104 | ||
104 | impl CompareMode { | 105 | impl CompareMode { |
105 | pub(crate) fn to_str(&self) -> &'static str { | 106 | pub(crate) fn to_str(&self) -> &'static str { |
106 | match *self { | 107 | match *self { |
107 | CompareMode::Nll => "nll", | 108 | CompareMode::Nll => "nll", |
109 | CompareMode::Polonius => "polonius", | ||
108 | } | 110 | } |
109 | } | 111 | } |
110 | 112 | ||
111 | pub fn parse(s: String) -> CompareMode { | 113 | pub fn parse(s: String) -> CompareMode { |
112 | match s.as_str() { | 114 | match s.as_str() { |
113 | "nll" => CompareMode::Nll, | 115 | "nll" => CompareMode::Nll, |
116 | "polonius" => CompareMode::Polonius, | ||
114 | x => panic!("unknown --compare-mode option: {}", x), | 117 | x => panic!("unknown --compare-mode option: {}", x), |
115 | } | 118 | } |
116 | } | 119 | } |
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9ff80cc1d3..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 | ||
11 | use common::CompareMode; | 11 | use common::CompareMode; |
12 | use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED}; | 12 | use common::{expected_output_path, UI_FIXED, UI_STDERR, UI_STDOUT}; |
13 | use common::{output_base_dir, output_base_name, output_testname_unique}; | 13 | use common::{output_base_dir, output_base_name, output_testname_unique}; |
14 | use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; | 14 | use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; |
15 | use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; | 15 | use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; |
@@ -24,8 +24,8 @@ use regex::Regex; | |||
24 | use rustfix::{apply_suggestions, get_suggestions_from_json}; | 24 | use rustfix::{apply_suggestions, get_suggestions_from_json}; |
25 | use util::{logv, PathBufExt}; | 25 | use util::{logv, PathBufExt}; |
26 | 26 | ||
27 | use std::collections::{HashMap, HashSet, VecDeque}; | ||
28 | use std::collections::hash_map::DefaultHasher; | 27 | use std::collections::hash_map::DefaultHasher; |
28 | use std::collections::{HashMap, HashSet, VecDeque}; | ||
29 | use std::env; | 29 | use std::env; |
30 | use std::ffi::OsString; | 30 | use std::ffi::OsString; |
31 | use std::fmt; | 31 | use 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 | ||
@@ -1729,6 +1744,9 @@ impl<'test> TestCx<'test> { | |||
1729 | Some(CompareMode::Nll) => { | 1744 | Some(CompareMode::Nll) => { |
1730 | rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]); | 1745 | rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]); |
1731 | } | 1746 | } |
1747 | Some(CompareMode::Polonius) => { | ||
1748 | rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]); | ||
1749 | } | ||
1732 | None => {} | 1750 | None => {} |
1733 | } | 1751 | } |
1734 | 1752 | ||
@@ -1809,7 +1827,8 @@ impl<'test> TestCx<'test> { | |||
1809 | 1827 | ||
1810 | fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<String> { | 1828 | fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<String> { |
1811 | match *argstr { | 1829 | match *argstr { |
1812 | Some(ref s) => s.split(' ') | 1830 | Some(ref s) => s |
1831 | .split(' ') | ||
1813 | .filter_map(|s| { | 1832 | .filter_map(|s| { |
1814 | if s.chars().all(|c| c.is_whitespace()) { | 1833 | if s.chars().all(|c| c.is_whitespace()) { |
1815 | None | 1834 | None |
@@ -2122,7 +2141,8 @@ impl<'test> TestCx<'test> { | |||
2122 | } | 2141 | } |
2123 | 2142 | ||
2124 | let mut tested = 0; | 2143 | let mut tested = 0; |
2125 | for _ in res.stdout | 2144 | for _ in res |
2145 | .stdout | ||
2126 | .split('\n') | 2146 | .split('\n') |
2127 | .filter(|s| s.starts_with("test ")) | 2147 | .filter(|s| s.starts_with("test ")) |
2128 | .inspect(|s| { | 2148 | .inspect(|s| { |
@@ -2133,7 +2153,8 @@ impl<'test> TestCx<'test> { | |||
2133 | tested += 1; | 2153 | tested += 1; |
2134 | let mut iter = tmp[1].split("(line "); | 2154 | let mut iter = tmp[1].split("(line "); |
2135 | iter.next(); | 2155 | iter.next(); |
2136 | let line = iter.next() | 2156 | let line = iter |
2157 | .next() | ||
2137 | .unwrap_or(")") | 2158 | .unwrap_or(")") |
2138 | .split(')') | 2159 | .split(')') |
2139 | .next() | 2160 | .next() |
@@ -2287,7 +2308,8 @@ impl<'test> TestCx<'test> { | |||
2287 | 2308 | ||
2288 | let full_string = format!("{}{}", PREFIX, s.trim().to_owned()); | 2309 | let full_string = format!("{}{}", PREFIX, s.trim().to_owned()); |
2289 | 2310 | ||
2290 | let parts: Vec<&str> = s.split(CGU_MARKER) | 2311 | let parts: Vec<&str> = s |
2312 | .split(CGU_MARKER) | ||
2291 | .map(str::trim) | 2313 | .map(str::trim) |
2292 | .filter(|s| !s.is_empty()) | 2314 | .filter(|s| !s.is_empty()) |
2293 | .collect(); | 2315 | .collect(); |
@@ -2372,7 +2394,8 @@ impl<'test> TestCx<'test> { | |||
2372 | // 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 |
2373 | // to #[rustc_dirty] and clean tests I guess | 2395 | // to #[rustc_dirty] and clean tests I guess |
2374 | 2396 | ||
2375 | let revision = self.revision | 2397 | let revision = self |
2398 | .revision | ||
2376 | .expect("incremental tests require a list of revisions"); | 2399 | .expect("incremental tests require a list of revisions"); |
2377 | 2400 | ||
2378 | // Incremental workproduct directory should have already been created. | 2401 | // Incremental workproduct directory should have already been created. |
@@ -2418,7 +2441,8 @@ impl<'test> TestCx<'test> { | |||
2418 | 2441 | ||
2419 | fn run_rmake_test(&self) { | 2442 | fn run_rmake_test(&self) { |
2420 | let cwd = env::current_dir().unwrap(); | 2443 | let cwd = env::current_dir().unwrap(); |
2421 | let src_root = self.config | 2444 | let src_root = self |
2445 | .config | ||
2422 | .src_base | 2446 | .src_base |
2423 | .parent() | 2447 | .parent() |
2424 | .unwrap() | 2448 | .unwrap() |
@@ -2435,8 +2459,10 @@ impl<'test> TestCx<'test> { | |||
2435 | create_dir_all(&tmpdir).unwrap(); | 2459 | create_dir_all(&tmpdir).unwrap(); |
2436 | 2460 | ||
2437 | let host = &self.config.host; | 2461 | let host = &self.config.host; |
2438 | let make = if host.contains("bitrig") || host.contains("dragonfly") | 2462 | let make = if host.contains("bitrig") |
2439 | || host.contains("freebsd") || host.contains("netbsd") | 2463 | || host.contains("dragonfly") |
2464 | || host.contains("freebsd") | ||
2465 | || host.contains("netbsd") | ||
2440 | || host.contains("openbsd") | 2466 | || host.contains("openbsd") |
2441 | { | 2467 | { |
2442 | "gmake" | 2468 | "gmake" |
@@ -2491,7 +2517,8 @@ impl<'test> TestCx<'test> { | |||
2491 | // 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 |
2492 | // a path and instead passes `C:\msys64\foo`, so convert all | 2518 | // a path and instead passes `C:\msys64\foo`, so convert all |
2493 | // `/`-arguments to MSVC here to `-` arguments. | 2519 | // `/`-arguments to MSVC here to `-` arguments. |
2494 | let cflags = self.config | 2520 | let cflags = self |
2521 | .config | ||
2495 | .cflags | 2522 | .cflags |
2496 | .split(' ') | 2523 | .split(' ') |
2497 | .map(|s| s.replace("/", "-")) | 2524 | .map(|s| s.replace("/", "-")) |
@@ -2513,7 +2540,8 @@ impl<'test> TestCx<'test> { | |||
2513 | } | 2540 | } |
2514 | } | 2541 | } |
2515 | 2542 | ||
2516 | let output = cmd.spawn() | 2543 | let output = cmd |
2544 | .spawn() | ||
2517 | .and_then(read2_abbreviated) | 2545 | .and_then(read2_abbreviated) |
2518 | .expect("failed to spawn `make`"); | 2546 | .expect("failed to spawn `make`"); |
2519 | if !output.status.success() { | 2547 | if !output.status.success() { |
@@ -2554,7 +2582,8 @@ impl<'test> TestCx<'test> { | |||
2554 | // if the user specified a format in the ui test | 2582 | // if the user specified a format in the ui test |
2555 | // print the output to the stderr file, otherwise extract | 2583 | // print the output to the stderr file, otherwise extract |
2556 | // the rendered error messages from json and print them | 2584 | // the rendered error messages from json and print them |
2557 | let explicit = self.props | 2585 | let explicit = self |
2586 | .props | ||
2558 | .compile_flags | 2587 | .compile_flags |
2559 | .iter() | 2588 | .iter() |
2560 | .any(|s| s.contains("--error-format")); | 2589 | .any(|s| s.contains("--error-format")); |
@@ -2584,22 +2613,27 @@ impl<'test> TestCx<'test> { | |||
2584 | // don't test rustfix with nll right now | 2613 | // don't test rustfix with nll right now |
2585 | } else if self.props.run_rustfix { | 2614 | } else if self.props.run_rustfix { |
2586 | // Apply suggestions from rustc to the code itself | 2615 | // Apply suggestions from rustc to the code itself |
2587 | 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) | ||
2588 | .unwrap(); | 2618 | .unwrap(); |
2589 | 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(); |
2590 | let fixed_code = apply_suggestions(&unfixed_code, &suggestions).expect( | 2620 | let fixed_code = apply_suggestions(&unfixed_code, &suggestions).expect(&format!( |
2591 | &format!("failed to apply suggestions for {:?} with rustfix", self.testpaths.file) | 2621 | "failed to apply suggestions for {:?} with rustfix", |
2592 | ); | 2622 | self.testpaths.file |
2623 | )); | ||
2593 | 2624 | ||
2594 | errors += self.compare_output("fixed", &fixed_code, &expected_fixed); | 2625 | errors += self.compare_output("fixed", &fixed_code, &expected_fixed); |
2595 | } else if !expected_fixed.is_empty() { | 2626 | } else if !expected_fixed.is_empty() { |
2596 | panic!("the `// run-rustfix` directive wasn't found but a `*.fixed` \ | 2627 | panic!( |
2597 | file was found"); | 2628 | "the `// run-rustfix` directive wasn't found but a `*.fixed` \ |
2629 | file was found" | ||
2630 | ); | ||
2598 | } | 2631 | } |
2599 | 2632 | ||
2600 | if errors > 0 { | 2633 | if errors > 0 { |
2601 | 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"); |
2602 | let relative_path_to_file = self.testpaths | 2635 | let relative_path_to_file = self |
2636 | .testpaths | ||
2603 | .relative_dir | 2637 | .relative_dir |
2604 | .join(self.testpaths.file.file_name().unwrap()); | 2638 | .join(self.testpaths.file.file_name().unwrap()); |
2605 | println!( | 2639 | println!( |
@@ -2781,11 +2815,7 @@ impl<'test> TestCx<'test> { | |||
2781 | Test Name: {}\n\ | 2815 | Test Name: {}\n\ |
2782 | Expected:\n{}\n\ | 2816 | Expected:\n{}\n\ |
2783 | Actual:\n{}", | 2817 | Actual:\n{}", |
2784 | extra_msg, | 2818 | extra_msg, expected_line, test_name, expected_content, normalize_all |
2785 | expected_line, | ||
2786 | test_name, | ||
2787 | expected_content, | ||
2788 | normalize_all | ||
2789 | ); | 2819 | ); |
2790 | }; | 2820 | }; |
2791 | 2821 | ||
@@ -2898,8 +2928,19 @@ impl<'test> TestCx<'test> { | |||
2898 | &self.config.compare_mode, | 2928 | &self.config.compare_mode, |
2899 | kind, | 2929 | kind, |
2900 | ); | 2930 | ); |
2901 | if !path.exists() && self.config.compare_mode.is_some() { | 2931 | |
2902 | // fallback! | 2932 | if !path.exists() { |
2933 | if let Some(CompareMode::Polonius) = self.config.compare_mode { | ||
2934 | path = expected_output_path( | ||
2935 | &self.testpaths, | ||
2936 | self.revision, | ||
2937 | &Some(CompareMode::Nll), | ||
2938 | kind, | ||
2939 | ); | ||
2940 | } | ||
2941 | } | ||
2942 | |||
2943 | if !path.exists() { | ||
2903 | path = expected_output_path(&self.testpaths, self.revision, &None, kind); | 2944 | path = expected_output_path(&self.testpaths, self.revision, &None, kind); |
2904 | } | 2945 | } |
2905 | 2946 | ||
@@ -2964,7 +3005,8 @@ impl<'test> TestCx<'test> { | |||
2964 | } | 3005 | } |
2965 | 3006 | ||
2966 | 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()); |
2967 | let output_file = self.output_base_name() | 3008 | let output_file = self |
3009 | .output_base_name() | ||
2968 | .with_extra_extension(self.revision.unwrap_or("")) | 3010 | .with_extra_extension(self.revision.unwrap_or("")) |
2969 | .with_extra_extension(mode) | 3011 | .with_extra_extension(mode) |
2970 | .with_extra_extension(kind); | 3012 | .with_extra_extension(kind); |
@@ -3014,7 +3056,8 @@ impl<'test> TestCx<'test> { | |||
3014 | 3056 | ||
3015 | fn create_stamp(&self) { | 3057 | fn create_stamp(&self) { |
3016 | 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(); |
3017 | f.write_all(compute_stamp_hash(&self.config).as_bytes()).unwrap(); | 3059 | f.write_all(compute_stamp_hash(&self.config).as_bytes()) |
3060 | .unwrap(); | ||
3018 | } | 3061 | } |
3019 | } | 3062 | } |
3020 | 3063 | ||