cargo.env("RUST_CHECK", "1");
}
- // If we were invoked from `make` then that's already got a jobserver
- // set up for us so no need to tell Cargo about jobs all over again.
- if env::var_os("MAKEFLAGS").is_none() && env::var_os("MFLAGS").is_none() {
- cargo.arg("-j").arg(self.jobs().to_string());
- }
+ cargo.arg("-j").arg(self.jobs().to_string());
+ // Remove make-related flags to ensure Cargo can correctly set things up
+ cargo.env_remove("MAKEFLAGS");
+ cargo.env_remove("MFLAGS");
// FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005
// Force cargo to output binaries with disambiguating hashes in the name
cargo.env("RUSTC_CRT_STATIC", x.to_string());
}
- if let Some(x) = self.crt_static(compiler.host) {
- cargo.env("RUSTC_HOST_CRT_STATIC", x.to_string());
- }
-
// Enable usage of unstable features
cargo.env("RUSTC_BOOTSTRAP", "1");
self.add_rust_test_threads(&mut cargo);
rustc_args: vec![],
fail_fast: true,
doc_tests: DocTests::No,
+ bless: false,
};
let build = Build::new(config);
.env("IS_WINDOWS", "1")
.env("MSVC_LIB", format!("'{}' -nologo", lib.display()))
.env("CC", format!("'{}' {}", self.config.cc, cflags))
- .env("CXX", format!("'{}'", &self.config.cxx));
+ .env("CXX", &self.config.cxx);
} else {
cmd.env("CC", format!("{} {}", self.config.cc, self.config.cflags))
.env("CXX", format!("{} {}", self.config.cxx, self.config.cflags))
}
if errors > 0 {
- println!("To update references, run this command from build directory:");
+ println!("To update references, rerun the tests and pass the `--bless` flag");
let relative_path_to_file = self.testpaths
.relative_dir
.join(self.testpaths.file.file_name().unwrap());
println!(
- "{}/update-references.sh '{}' '{}'",
- self.config.src_base.display(),
- self.config.build_base.display(),
- relative_path_to_file.display()
+ "To only update this specific test, also pass `--test-args {}`",
+ relative_path_to_file.display(),
);
self.fatal_proc_rec(
&format!("{} errors occurred comparing output.", errors),
return 0;
}
- if expected.is_empty() {
- println!("normalized {}:\n{}\n", kind, actual);
- } else {
- println!("diff of {}:\n", kind);
- let diff_results = make_diff(expected, actual, 3);
- for result in diff_results {
- let mut line_number = result.line_number;
- for line in result.lines {
- match line {
- DiffLine::Expected(e) => {
- println!("-\t{}", e);
- line_number += 1;
- }
- DiffLine::Context(c) => {
- println!("{}\t{}", line_number, c);
- line_number += 1;
- }
- DiffLine::Resulting(r) => {
- println!("+\t{}", r);
+ if !self.config.bless {
+ if expected.is_empty() {
+ println!("normalized {}:\n{}\n", kind, actual);
+ } else {
+ println!("diff of {}:\n", kind);
+ let diff_results = make_diff(expected, actual, 3);
+ for result in diff_results {
+ let mut line_number = result.line_number;
+ for line in result.lines {
+ match line {
+ DiffLine::Expected(e) => {
+ println!("-\t{}", e);
+ line_number += 1;
+ }
+ DiffLine::Context(c) => {
+ println!("{}\t{}", line_number, c);
+ line_number += 1;
+ }
+ DiffLine::Resulting(r) => {
+ println!("+\t{}", r);
+ }
}
}
+ println!("");
}
- println!("");
}
}
.with_extra_extension(mode)
.with_extra_extension(kind);
- match File::create(&output_file).and_then(|mut f| f.write_all(actual.as_bytes())) {
- Ok(()) => {}
- Err(e) => self.fatal(&format!(
- "failed to write {} to `{}`: {}",
+ let mut files = vec![output_file];
+ if self.config.bless {
+ files.push(expected_output_path(
+ self.testpaths,
+ self.revision,
+ &self.config.compare_mode,
kind,
- output_file.display(),
- e
- )),
+ ));
+ }
+
+ for output_file in &files {
+ if actual.is_empty() {
+ if let Err(e) = ::std::fs::remove_file(output_file) {
+ self.fatal(&format!(
+ "failed to delete `{}`: {}",
+ output_file.display(),
+ e,
+ ));
+ }
+ } else {
+ match File::create(&output_file).and_then(|mut f| f.write_all(actual.as_bytes())) {
+ Ok(()) => {}
+ Err(e) => self.fatal(&format!(
+ "failed to write {} to `{}`: {}",
+ kind,
+ output_file.display(),
+ e
+ )),
+ }
+ }
}
println!("\nThe actual {0} differed from the expected {0}.", kind);
- println!("Actual {} saved to {}", kind, output_file.display());
- 1
+ for output_file in files {
+ println!("Actual {} saved to {}", kind, output_file.display());
+ }
+ if self.config.bless {
+ 0
+ } else {
+ 1
+ }
}
fn create_stamp(&self) {