From 36656f812d123644fb24c16a721803fa92656af0 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 8 Jan 2016 12:26:09 +0100 Subject: [PATCH 1/3] Expect all help/note messages are specified in a cfail test if it contains help/note annotations, closes #21195 --- src/compiletest/runtest.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index c7561248eb7..4abc4cce727 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -929,6 +929,13 @@ fn check_expected_errors(expected_errors: Vec, format!("{}:{}:", testfile.display(), ee.line) }).collect::>(); + let (expect_help, expect_note) = + expected_errors.iter() + .fold((false, false), + |(acc_help, acc_note), ee| + (acc_help || ee.kind == "help:", acc_note || + ee.kind == "note:")); + fn prefix_matches(line: &str, prefix: &str) -> bool { use std::ascii::AsciiExt; // On windows just translate all '\' path separators to '/' @@ -992,8 +999,8 @@ fn check_expected_errors(expected_errors: Vec, was_expected = true; } - if !was_expected && is_compiler_error_or_warning(line) { - fatal_proc_rec(&format!("unexpected compiler error or warning: '{}'", + if !was_expected && is_unexpected_compiler_message(line, expect_help, expect_note) { + fatal_proc_rec(&format!("unexpected compiler message: '{}'", line), proc_res); } @@ -1009,7 +1016,7 @@ fn check_expected_errors(expected_errors: Vec, } } -fn is_compiler_error_or_warning(line: &str) -> bool { +fn is_unexpected_compiler_message(line: &str, expect_help: bool, expect_note: bool) -> bool { let mut c = Path::new(line).components(); let line = match c.next() { Some(Component::Prefix(_)) => c.as_path().to_str().unwrap(), @@ -1017,8 +1024,7 @@ fn is_compiler_error_or_warning(line: &str) -> bool { }; let mut i = 0; - return - scan_until_char(line, ':', &mut i) && + return scan_until_char(line, ':', &mut i) && scan_char(line, ':', &mut i) && scan_integer(line, &mut i) && scan_char(line, ':', &mut i) && @@ -1030,7 +1036,10 @@ fn is_compiler_error_or_warning(line: &str) -> bool { scan_integer(line, &mut i) && scan_char(line, ' ', &mut i) && (scan_string(line, "error", &mut i) || - scan_string(line, "warning", &mut i)); + scan_string(line, "warning", &mut i) || + (expect_help && scan_string(line, "help", &mut i)) || + (expect_note && scan_string(line, "note", &mut i)) + ); } fn scan_until_char(haystack: &str, needle: char, idx: &mut usize) -> bool { From efe56c883354fe476fe4c989bb34e68f825ecfdc Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 15 Jan 2016 11:57:57 +0100 Subject: [PATCH 2/3] Add missings NOTE and HELP annotations to tests --- src/test/compile-fail/changing-crates.rs | 4 +++- .../compile-fail/default_ty_param_conflict_cross_crate.rs | 1 + .../lifetime-inference-give-expl-lifetime-param.rs | 1 + src/test/compile-fail/privacy1.rs | 7 ++++++- src/test/compile-fail/svh-change-lit.rs | 4 +++- src/test/compile-fail/svh-change-significant-cfg.rs | 4 +++- src/test/compile-fail/svh-change-trait-bound.rs | 4 +++- src/test/compile-fail/svh-change-type-arg.rs | 4 +++- src/test/compile-fail/svh-change-type-ret.rs | 4 +++- src/test/compile-fail/svh-change-type-static.rs | 4 +++- src/test/compile-fail/svh-use-trait.rs | 4 +++- 11 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/test/compile-fail/changing-crates.rs b/src/test/compile-fail/changing-crates.rs index ae3ef760667..798f4ef74b8 100644 --- a/src/test/compile-fail/changing-crates.rs +++ b/src/test/compile-fail/changing-crates.rs @@ -15,6 +15,8 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() {} diff --git a/src/test/compile-fail/default_ty_param_conflict_cross_crate.rs b/src/test/compile-fail/default_ty_param_conflict_cross_crate.rs index 4d60724372a..fc2c49d65af 100644 --- a/src/test/compile-fail/default_ty_param_conflict_cross_crate.rs +++ b/src/test/compile-fail/default_ty_param_conflict_cross_crate.rs @@ -26,4 +26,5 @@ fn main() { meh(foo); //~^ ERROR: mismatched types: //~| NOTE: conflicting type parameter defaults `bool` and `char` + //~| NOTE: ...that was applied to an unconstrained type variable here } diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs index a85776a938b..e32ed1c42a0 100644 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs @@ -49,6 +49,7 @@ struct Baz<'x> { impl<'a> Baz<'a> { fn baz2<'b>(&self, x: &isize) -> (&'b isize, &'b isize) { + //~^ HELP: parameter as shown: fn baz2<'b>(&self, x: &'b isize) -> (&'a isize, &'a isize) // The lifetime that gets assigned to `x` seems somewhat random. // I have disabled this test for the time being. --pcwalton (self.bar, x) //~ ERROR: cannot infer diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs index 593068c2aea..495cdc3fe62 100644 --- a/src/test/compile-fail/privacy1.rs +++ b/src/test/compile-fail/privacy1.rs @@ -129,12 +129,17 @@ mod foo { ::bar::baz::foo(); //~ ERROR: function `foo` is inaccessible //~^ NOTE: module `baz` is private ::bar::baz::bar(); //~ ERROR: function `bar` is inaccessible + //~^ NOTE: module `baz` is private } fn test2() { use bar::baz::{foo, bar}; //~^ ERROR: function `foo` is inaccessible - //~^^ ERROR: function `bar` is inaccessible + //~| NOTE: module `baz` is private + //~| ERROR: function `bar` is inaccessible + //~| NOTE: module `baz` is private + + foo(); bar(); } diff --git a/src/test/compile-fail/svh-change-lit.rs b/src/test/compile-fail/svh-change-lit.rs index c839ade75cf..24627c4ef0f 100644 --- a/src/test/compile-fail/svh-change-lit.rs +++ b/src/test/compile-fail/svh-change-lit.rs @@ -15,7 +15,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-significant-cfg.rs b/src/test/compile-fail/svh-change-significant-cfg.rs index df0adf36ce2..fd3065ccb63 100644 --- a/src/test/compile-fail/svh-change-significant-cfg.rs +++ b/src/test/compile-fail/svh-change-significant-cfg.rs @@ -15,7 +15,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-trait-bound.rs b/src/test/compile-fail/svh-change-trait-bound.rs index 4774384fecd..aa8ec911a3b 100644 --- a/src/test/compile-fail/svh-change-trait-bound.rs +++ b/src/test/compile-fail/svh-change-trait-bound.rs @@ -15,7 +15,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-type-arg.rs b/src/test/compile-fail/svh-change-type-arg.rs index 51d3fd0a73a..953813a8422 100644 --- a/src/test/compile-fail/svh-change-type-arg.rs +++ b/src/test/compile-fail/svh-change-type-arg.rs @@ -15,7 +15,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-type-ret.rs b/src/test/compile-fail/svh-change-type-ret.rs index 609e0f3689e..114d82d68e6 100644 --- a/src/test/compile-fail/svh-change-type-ret.rs +++ b/src/test/compile-fail/svh-change-type-ret.rs @@ -15,7 +15,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-type-static.rs b/src/test/compile-fail/svh-change-type-static.rs index c42714609b6..80a9119095e 100644 --- a/src/test/compile-fail/svh-change-type-static.rs +++ b/src/test/compile-fail/svh-change-type-static.rs @@ -15,7 +15,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-use-trait.rs b/src/test/compile-fail/svh-use-trait.rs index 7fdbf35fc6d..c6c5b10bda3 100644 --- a/src/test/compile-fail/svh-use-trait.rs +++ b/src/test/compile-fail/svh-use-trait.rs @@ -20,7 +20,9 @@ extern crate uta; extern crate utb; //~ ERROR: found possibly newer version of crate `uta` which `utb` depends -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled? +//~| NOTE: crate `uta` path #1: +//~| NOTE: crate `utb` path #1: fn main() { utb::foo() From 526965aee54166dfba1b14b9bc475da8abcd66a3 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 30 Jan 2016 14:27:12 +0100 Subject: [PATCH 3/3] Mark test failing with msvc due to #31306 as ignore-msvc --- src/test/compile-fail/changing-crates.rs | 2 ++ src/test/compile-fail/svh-change-lit.rs | 2 ++ src/test/compile-fail/svh-change-significant-cfg.rs | 2 ++ src/test/compile-fail/svh-change-trait-bound.rs | 2 ++ src/test/compile-fail/svh-change-type-arg.rs | 2 ++ src/test/compile-fail/svh-change-type-ret.rs | 2 ++ src/test/compile-fail/svh-change-type-static.rs | 2 ++ src/test/compile-fail/svh-use-trait.rs | 2 ++ 8 files changed, 16 insertions(+) diff --git a/src/test/compile-fail/changing-crates.rs b/src/test/compile-fail/changing-crates.rs index 798f4ef74b8..0b420158488 100644 --- a/src/test/compile-fail/changing-crates.rs +++ b/src/test/compile-fail/changing-crates.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:changing-crates-a1.rs // aux-build:changing-crates-b.rs diff --git a/src/test/compile-fail/svh-change-lit.rs b/src/test/compile-fail/svh-change-lit.rs index 24627c4ef0f..eb92bcf065d 100644 --- a/src/test/compile-fail/svh-change-lit.rs +++ b/src/test/compile-fail/svh-change-lit.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs diff --git a/src/test/compile-fail/svh-change-significant-cfg.rs b/src/test/compile-fail/svh-change-significant-cfg.rs index fd3065ccb63..7c9e0d3a92c 100644 --- a/src/test/compile-fail/svh-change-significant-cfg.rs +++ b/src/test/compile-fail/svh-change-significant-cfg.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs diff --git a/src/test/compile-fail/svh-change-trait-bound.rs b/src/test/compile-fail/svh-change-trait-bound.rs index aa8ec911a3b..1e6a7232904 100644 --- a/src/test/compile-fail/svh-change-trait-bound.rs +++ b/src/test/compile-fail/svh-change-trait-bound.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs diff --git a/src/test/compile-fail/svh-change-type-arg.rs b/src/test/compile-fail/svh-change-type-arg.rs index 953813a8422..73c35ee6f82 100644 --- a/src/test/compile-fail/svh-change-type-arg.rs +++ b/src/test/compile-fail/svh-change-type-arg.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs diff --git a/src/test/compile-fail/svh-change-type-ret.rs b/src/test/compile-fail/svh-change-type-ret.rs index 114d82d68e6..b8908e2cbd1 100644 --- a/src/test/compile-fail/svh-change-type-ret.rs +++ b/src/test/compile-fail/svh-change-type-ret.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs diff --git a/src/test/compile-fail/svh-change-type-static.rs b/src/test/compile-fail/svh-change-type-static.rs index 80a9119095e..291e441aa5e 100644 --- a/src/test/compile-fail/svh-change-type-static.rs +++ b/src/test/compile-fail/svh-change-type-static.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs diff --git a/src/test/compile-fail/svh-use-trait.rs b/src/test/compile-fail/svh-use-trait.rs index c6c5b10bda3..ed816a93c52 100644 --- a/src/test/compile-fail/svh-use-trait.rs +++ b/src/test/compile-fail/svh-use-trait.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-uta-base.rs // aux-build:svh-utb.rs