From 37dee69dacb0fc199d52d9baba3a3caf3018958a Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 16 May 2018 17:18:19 +0200 Subject: [PATCH 1/5] Add `bless` x.py subcommand for easy ui test replacement --- src/bootstrap/bin/rustc.rs | 7 ++- src/bootstrap/builder.rs | 5 ++ src/bootstrap/flags.rs | 12 ++++ src/bootstrap/test.rs | 52 ++++++++--------- src/tools/compiletest/src/common.rs | 3 + src/tools/compiletest/src/main.rs | 6 ++ src/tools/compiletest/src/runtest.rs | 85 ++++++++++++++++++---------- 7 files changed, 111 insertions(+), 59 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 76d0e6e28aeda..4607ca5cf9f48 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -297,7 +297,12 @@ fn main() { } if verbose > 1 { - eprintln!("rustc command: {:?}", cmd); + eprintln!( + "rustc command: {:?}={:?} {:?}", + bootstrap::util::dylib_path_var(), + env::join_paths(&dylib_path).unwrap(), + cmd, + ); eprintln!("sysroot: {:?}", sysroot); eprintln!("libdir: {:?}", libdir); } diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index e5824010ef2cc..d453e92289280 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -311,6 +311,8 @@ impl<'a> ShouldRun<'a> { pub enum Kind { Build, Check, + /// Run tests and replace any failing tests' output files (stderr/stout) with the correct ones + Bless, Test, Bench, Dist, @@ -334,6 +336,7 @@ impl<'a> Builder<'a> { native::Llvm, tool::Rustfmt, tool::Miri, native::Lld), Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend, check::Rustdoc), + Kind::Bless | Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass, test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind, test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo, @@ -367,6 +370,7 @@ impl<'a> Builder<'a> { let kind = match subcommand { "build" => Kind::Build, "doc" => Kind::Doc, + "bless" => Kind::Bless, "test" => Kind::Test, "bench" => Kind::Bench, "dist" => Kind::Dist, @@ -408,6 +412,7 @@ impl<'a> Builder<'a> { Subcommand::Build { ref paths } => (Kind::Build, &paths[..]), Subcommand::Check { ref paths } => (Kind::Check, &paths[..]), Subcommand::Doc { ref paths } => (Kind::Doc, &paths[..]), + Subcommand::Test { ref paths, bless: true, .. } => (Kind::Bless, &paths[..]), Subcommand::Test { ref paths, .. } => (Kind::Test, &paths[..]), Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]), Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]), diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 5315a3028ffa9..8753ccc93cf9a 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -59,6 +59,8 @@ pub enum Subcommand { }, Test { paths: Vec, + /// Whether to automatically update stderr/stdout files + bless: bool, test_args: Vec, rustc_args: Vec, fail_fast: bool, @@ -142,6 +144,7 @@ To learn more about a subcommand, run `./x.py -h`"); let subcommand = args.iter().find(|&s| (s == "build") || (s == "check") + || (s == "bless") || (s == "test") || (s == "bench") || (s == "doc") @@ -162,6 +165,7 @@ To learn more about a subcommand, run `./x.py -h`"); // Some subcommands get extra options match subcommand.as_str() { + "bless" | "test" => { opts.optflag("", "no-fail-fast", "Run all tests regardless of failure"); opts.optmulti("", "test-args", "extra arguments", "ARGS"); @@ -248,6 +252,12 @@ Arguments: compilation, so there's no need to pass it separately, though it won't hurt. We also completely ignore the stage passed, as there's no way to compile in non-stage 0 without actually building the compiler."); + } + "bless" => { + subcommand_help.push_str("\n +Arguments: + This subcommand works exactly like the `test` subcommand, but also updates stderr/stdout files + before they cause a test failure"); } "test" => { subcommand_help.push_str("\n @@ -319,9 +329,11 @@ Arguments: "check" => { Subcommand::Check { paths: paths } } + "bless" | "test" => { Subcommand::Test { paths, + bless: subcommand.as_str() == "bless", test_args: matches.opt_strs("test-args"), rustc_args: matches.opt_strs("rustc-args"), fail_fast: !matches.opt_present("no-fail-fast"), diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 1f81a617237cc..ecb463fda2804 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -41,16 +41,31 @@ const ADB_TEST_DIR: &str = "/data/tmp/work"; /// The two modes of the test runner; tests or benchmarks. #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)] pub enum TestKind { + /// Run `cargo bless` + Bless, /// Run `cargo test` Test, /// Run `cargo bench` Bench, } +impl From for TestKind { + fn from(kind: Kind) -> Self { + match kind { + Kind::Test => TestKind::Test, + Kind::Bless => TestKind::Bless, + Kind::Bench => TestKind::Bench, + _ => panic!("unexpected kind in crate: {:?}", kind) + } + } +} + impl TestKind { // Return the cargo subcommand for this test kind fn subcommand(self) -> &'static str { match self { + // bless and test are both `test` for folder names and cargo subcommands + TestKind::Bless | TestKind::Test => "test", TestKind::Bench => "bench", } @@ -60,6 +75,7 @@ impl TestKind { impl fmt::Display for TestKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(match *self { + TestKind::Bless => "Testing (bless)", TestKind::Test => "Testing", TestKind::Bench => "Benchmarking", }) @@ -951,6 +967,10 @@ impl Step for Compiletest { cmd.arg("--host").arg(&*compiler.host); cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build)); + if builder.kind == Kind::Bless { + cmd.arg("--bless"); + } + if let Some(ref nodejs) = builder.config.nodejs { cmd.arg("--nodejs").arg(nodejs); } @@ -1342,13 +1362,7 @@ impl Step for CrateLibrustc { for krate in builder.in_tree_crates("rustc-main") { if run.path.ends_with(&krate.path) { - let test_kind = if builder.kind == Kind::Test { - TestKind::Test - } else if builder.kind == Kind::Bench { - TestKind::Bench - } else { - panic!("unexpected builder.kind in crate: {:?}", builder.kind); - }; + let test_kind = builder.kind.into(); builder.ensure(CrateLibrustc { compiler, @@ -1394,13 +1408,7 @@ impl Step for CrateNotDefault { let builder = run.builder; let compiler = builder.compiler(builder.top_stage, run.host); - let test_kind = if builder.kind == Kind::Test { - TestKind::Test - } else if builder.kind == Kind::Bench { - TestKind::Bench - } else { - panic!("unexpected builder.kind in crate: {:?}", builder.kind); - }; + let test_kind = builder.kind.into(); builder.ensure(CrateNotDefault { compiler, @@ -1461,13 +1469,7 @@ impl Step for Crate { let compiler = builder.compiler(builder.top_stage, run.host); let make = |mode: Mode, krate: &CargoCrate| { - let test_kind = if builder.kind == Kind::Test { - TestKind::Test - } else if builder.kind == Kind::Bench { - TestKind::Bench - } else { - panic!("unexpected builder.kind in crate: {:?}", builder.kind); - }; + let test_kind = builder.kind.into(); builder.ensure(Crate { compiler, @@ -1625,13 +1627,7 @@ impl Step for CrateRustdoc { fn make_run(run: RunConfig) { let builder = run.builder; - let test_kind = if builder.kind == Kind::Test { - TestKind::Test - } else if builder.kind == Kind::Bench { - TestKind::Bench - } else { - panic!("unexpected builder.kind in crate: {:?}", builder.kind); - }; + let test_kind = builder.kind.into(); builder.ensure(CrateRustdoc { host: run.host, diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 812e9c5f39d87..b2ce5ce52f719 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -118,6 +118,9 @@ impl CompareMode { #[derive(Clone)] pub struct Config { + /// Whether to overwrite stderr/stdout files instead of complaining about changes in output + pub bless: bool, + /// The library paths required for running the compiler pub compile_lib_path: PathBuf, diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 42a2cdfa55b5a..2bfc1ece09590 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -166,6 +166,11 @@ pub fn parse_config(args: Vec) -> Config { "FLAGS", ) .optflag("", "verbose", "run tests verbosely, showing all output") + .optflag( + "", + "bless", + "overwrite stderr/stdout files instead of complaining about a mismatch", + ) .optflag( "", "quiet", @@ -290,6 +295,7 @@ pub fn parse_config(args: Vec) -> Config { let src_base = opt_path(matches, "src-base"); let run_ignored = matches.opt_present("ignored"); Config { + bless: matches.opt_present("bless"), compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")), run_lib_path: make_absolute(opt_path(matches, "run-lib-path")), rustc_path: opt_path(matches, "rustc-path"), diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 59d94e1fa51e1..743d7fa93c29b 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2926,29 +2926,31 @@ impl<'test> TestCx<'test> { 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!(""); } } @@ -2958,19 +2960,42 @@ impl<'test> TestCx<'test> { .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 `{}`: {}", - kind, - output_file.display(), - e - )), + let mut files = vec![output_file]; + if self.config.bless { + files.push(self.expected_output_path(kind)); + } + + 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) { From ceed8eb89cc50660e68ff2d4f15365698bd9104f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 16 May 2018 18:17:29 +0200 Subject: [PATCH 2/5] Make `bless` a flag instead of a subcommand --- src/bootstrap/builder.rs | 5 ----- src/bootstrap/flags.rs | 20 ++++++++++---------- src/bootstrap/test.rs | 8 +------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index d453e92289280..e5824010ef2cc 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -311,8 +311,6 @@ impl<'a> ShouldRun<'a> { pub enum Kind { Build, Check, - /// Run tests and replace any failing tests' output files (stderr/stout) with the correct ones - Bless, Test, Bench, Dist, @@ -336,7 +334,6 @@ impl<'a> Builder<'a> { native::Llvm, tool::Rustfmt, tool::Miri, native::Lld), Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend, check::Rustdoc), - Kind::Bless | Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass, test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind, test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo, @@ -370,7 +367,6 @@ impl<'a> Builder<'a> { let kind = match subcommand { "build" => Kind::Build, "doc" => Kind::Doc, - "bless" => Kind::Bless, "test" => Kind::Test, "bench" => Kind::Bench, "dist" => Kind::Dist, @@ -412,7 +408,6 @@ impl<'a> Builder<'a> { Subcommand::Build { ref paths } => (Kind::Build, &paths[..]), Subcommand::Check { ref paths } => (Kind::Check, &paths[..]), Subcommand::Doc { ref paths } => (Kind::Doc, &paths[..]), - Subcommand::Test { ref paths, bless: true, .. } => (Kind::Bless, &paths[..]), Subcommand::Test { ref paths, .. } => (Kind::Test, &paths[..]), Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]), Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]), diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 8753ccc93cf9a..90dd5d819b0da 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -144,7 +144,6 @@ To learn more about a subcommand, run `./x.py -h`"); let subcommand = args.iter().find(|&s| (s == "build") || (s == "check") - || (s == "bless") || (s == "test") || (s == "bench") || (s == "doc") @@ -165,7 +164,6 @@ To learn more about a subcommand, run `./x.py -h`"); // Some subcommands get extra options match subcommand.as_str() { - "bless" | "test" => { opts.optflag("", "no-fail-fast", "Run all tests regardless of failure"); opts.optmulti("", "test-args", "extra arguments", "ARGS"); @@ -177,6 +175,7 @@ To learn more about a subcommand, run `./x.py -h`"); ); opts.optflag("", "no-doc", "do not run doc tests"); opts.optflag("", "doc", "only run doc tests"); + opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests"); }, "bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); }, "clean" => { opts.optflag("", "all", "clean all build artifacts"); }, @@ -252,12 +251,6 @@ Arguments: compilation, so there's no need to pass it separately, though it won't hurt. We also completely ignore the stage passed, as there's no way to compile in non-stage 0 without actually building the compiler."); - } - "bless" => { - subcommand_help.push_str("\n -Arguments: - This subcommand works exactly like the `test` subcommand, but also updates stderr/stdout files - before they cause a test failure"); } "test" => { subcommand_help.push_str("\n @@ -268,6 +261,7 @@ Arguments: ./x.py test src/test/run-pass ./x.py test src/libstd --test-args hash_map ./x.py test src/libstd --stage 0 + ./x.py test src/test/ui --bless If no arguments are passed then the complete artifacts for that stage are compiled and tested. @@ -329,11 +323,10 @@ Arguments: "check" => { Subcommand::Check { paths: paths } } - "bless" | "test" => { Subcommand::Test { paths, - bless: subcommand.as_str() == "bless", + bless: matches.opt_present("bless"), test_args: matches.opt_strs("test-args"), rustc_args: matches.opt_strs("rustc-args"), fail_fast: !matches.opt_present("no-fail-fast"), @@ -436,6 +429,13 @@ impl Subcommand { _ => DocTests::Yes, } } + + pub fn bless(&self) -> bool { + match *self { + Subcommand::Test { bless, .. } => bless, + _ => false, + } + } } fn split(s: Vec) -> Vec { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index ecb463fda2804..7a4924f03c8d2 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -41,8 +41,6 @@ const ADB_TEST_DIR: &str = "/data/tmp/work"; /// The two modes of the test runner; tests or benchmarks. #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)] pub enum TestKind { - /// Run `cargo bless` - Bless, /// Run `cargo test` Test, /// Run `cargo bench` @@ -53,7 +51,6 @@ impl From for TestKind { fn from(kind: Kind) -> Self { match kind { Kind::Test => TestKind::Test, - Kind::Bless => TestKind::Bless, Kind::Bench => TestKind::Bench, _ => panic!("unexpected kind in crate: {:?}", kind) } @@ -64,8 +61,6 @@ impl TestKind { // Return the cargo subcommand for this test kind fn subcommand(self) -> &'static str { match self { - // bless and test are both `test` for folder names and cargo subcommands - TestKind::Bless | TestKind::Test => "test", TestKind::Bench => "bench", } @@ -75,7 +70,6 @@ impl TestKind { impl fmt::Display for TestKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(match *self { - TestKind::Bless => "Testing (bless)", TestKind::Test => "Testing", TestKind::Bench => "Benchmarking", }) @@ -967,7 +961,7 @@ impl Step for Compiletest { cmd.arg("--host").arg(&*compiler.host); cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build)); - if builder.kind == Kind::Bless { + if builder.config.cmd.bless() { cmd.arg("--bless"); } From 0356a61948915acab010316f523f734f3f34a37a Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 17 May 2018 09:47:25 +0200 Subject: [PATCH 3/5] Fix selftests --- src/bootstrap/builder.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index e5824010ef2cc..00b30a00b0356 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1461,6 +1461,7 @@ mod __test { rustc_args: vec![], fail_fast: true, doc_tests: DocTests::No, + bless: false, }; let build = Build::new(config); From 74bfd94ec55b9e26e47e597fbe0ba25cb75063ba Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 17 May 2018 10:17:06 +0200 Subject: [PATCH 4/5] `bless` also produces `.nll` files now --- src/test/ui/E0508.ast.nll.stderr | 9 +++++++++ src/test/ui/E0508.ast.stderr | 12 ++++++++++++ src/test/ui/E0508.mir.stderr | 9 +++++++++ src/test/ui/E0508.rs | 20 ++++++++++++++++++++ src/tools/compiletest/src/runtest.rs | 7 ++++++- 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/E0508.ast.nll.stderr create mode 100644 src/test/ui/E0508.ast.stderr create mode 100644 src/test/ui/E0508.mir.stderr create mode 100644 src/test/ui/E0508.rs diff --git a/src/test/ui/E0508.ast.nll.stderr b/src/test/ui/E0508.ast.nll.stderr new file mode 100644 index 0000000000000..28403644a234a --- /dev/null +++ b/src/test/ui/E0508.ast.nll.stderr @@ -0,0 +1,9 @@ +error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array + --> $DIR/E0508.rs:18:18 + | +LL | let _value = array[0]; //[ast]~ ERROR [E0508] + | ^^^^^^^^ cannot move out of here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508.ast.stderr b/src/test/ui/E0508.ast.stderr new file mode 100644 index 0000000000000..5878b795b771c --- /dev/null +++ b/src/test/ui/E0508.ast.stderr @@ -0,0 +1,12 @@ +error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array + --> $DIR/E0508.rs:18:18 + | +LL | let _value = array[0]; //[ast]~ ERROR [E0508] + | ^^^^^^^^ + | | + | cannot move out of here + | help: consider using a reference instead: `&array[0]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508.mir.stderr b/src/test/ui/E0508.mir.stderr new file mode 100644 index 0000000000000..28403644a234a --- /dev/null +++ b/src/test/ui/E0508.mir.stderr @@ -0,0 +1,9 @@ +error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array + --> $DIR/E0508.rs:18:18 + | +LL | let _value = array[0]; //[ast]~ ERROR [E0508] + | ^^^^^^^^ cannot move out of here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508.rs b/src/test/ui/E0508.rs new file mode 100644 index 0000000000000..0c3dce6b0346a --- /dev/null +++ b/src/test/ui/E0508.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +struct NonCopy; + +fn main() { + let array = [NonCopy; 1]; + let _value = array[0]; //[ast]~ ERROR [E0508] + //[mir]~^ ERROR [E0508] +} diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 743d7fa93c29b..d54bfa5f918c0 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2962,7 +2962,12 @@ impl<'test> TestCx<'test> { let mut files = vec![output_file]; if self.config.bless { - files.push(self.expected_output_path(kind)); + files.push(expected_output_path( + self.testpaths, + self.revision, + &self.config.compare_mode, + kind, + )); } for output_file in &files { From 0ac2fd1ce2917e3e5f1845ff8d319d03181b244b Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 17 May 2018 16:28:36 +0200 Subject: [PATCH 5/5] Update docs and diagnostics --- src/test/COMPILER_TESTS.md | 10 +++------- src/tools/compiletest/src/runtest.rs | 8 +++----- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/test/COMPILER_TESTS.md b/src/test/COMPILER_TESTS.md index 29f1e2e5b781e..7dabb1bddea77 100644 --- a/src/test/COMPILER_TESTS.md +++ b/src/test/COMPILER_TESTS.md @@ -140,13 +140,9 @@ check that the test compiles successfully. ### Editing and updating the reference files If you have changed the compiler's output intentionally, or you are -making a new test, you can use the script `ui/update-references.sh` to -update the references. When you run the test framework, it will report -various errors: in those errors is a command you can use to run the -`ui/update-references.sh` script, which will then copy over the files -from the build directory and use them as the new reference. You can -also just run `ui/update-all-references.sh`. In both cases, you can run -the script with `--help` to get a help message. +making a new test, you can pass `--bless` to the command you used to +run the tests. This will then copy over the files +from the build directory and use them as the new reference. ### Normalization diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index d54bfa5f918c0..9e5ae213568f2 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2596,15 +2596,13 @@ impl<'test> TestCx<'test> { } 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),