@@ -765,12 +765,6 @@ impl<'test> TestCx<'test> {
765
765
}
766
766
767
767
if !unexpected. is_empty ( ) || !not_found. is_empty ( ) {
768
- self . error ( & format ! (
769
- "{} unexpected diagnostics reported, {} expected diagnostics not reported" ,
770
- unexpected. len( ) ,
771
- not_found. len( )
772
- ) ) ;
773
-
774
768
// Emit locations in a format that is short (relative paths) but "clickable" in editors.
775
769
// Also normalize path separators to `/`.
776
770
let file_name = self
@@ -794,19 +788,20 @@ impl<'test> TestCx<'test> {
794
788
|suggestions : & mut Vec < _ > , e : & Error , kind, line, msg, color, rank| {
795
789
let mut ret = String :: new ( ) ;
796
790
if kind {
797
- ret += & format ! ( "{} {}" , "with kind" . color( color) , e. kind) ;
791
+ ret += & format ! ( "{} {}" , "with different kind" . color( color) , e. kind) ;
798
792
}
799
793
if line {
800
794
if !ret. is_empty ( ) {
801
795
ret. push ( ' ' ) ;
802
796
}
803
- ret += & format ! ( "{} {}" , "on line" . color( color) , line_str( e) ) ;
797
+ ret += & format ! ( "{} {}" , "on different line" . color( color) , line_str( e) ) ;
804
798
}
805
799
if msg {
806
800
if !ret. is_empty ( ) {
807
801
ret. push ( ' ' ) ;
808
802
}
809
- ret += & format ! ( "{} {}" , "with message" . color( color) , e. msg. cyan( ) ) ;
803
+ ret +=
804
+ & format ! ( "{} {}" , "with different message" . color( color) , e. msg. cyan( ) ) ;
810
805
}
811
806
suggestions. push ( ( ret, rank) ) ;
812
807
} ;
@@ -829,17 +824,20 @@ impl<'test> TestCx<'test> {
829
824
// - only known line - meh, but suggested
830
825
// - others are not worth suggesting
831
826
if !unexpected. is_empty ( ) {
832
- let header = "--- reported in JSON output but not expected in test file ---" ;
833
- println ! ( "{}" , header. green( ) ) ;
827
+ self . error ( & format ! (
828
+ "{} diagnostics reported in JSON output but not expected in test file" ,
829
+ unexpected. len( ) ,
830
+ ) ) ;
834
831
for error in & unexpected {
835
832
print_error ( error) ;
836
833
let mut suggestions = Vec :: new ( ) ;
837
834
for candidate in & not_found {
835
+ let kind_mismatch = candidate. kind != error. kind ;
838
836
let mut push_red_suggestion = |line, msg, rank| {
839
837
push_suggestion (
840
838
& mut suggestions,
841
839
candidate,
842
- candidate . kind != error . kind ,
840
+ kind_mismatch ,
843
841
line,
844
842
msg,
845
843
Color :: Red ,
@@ -851,26 +849,28 @@ impl<'test> TestCx<'test> {
851
849
} else if candidate. line_num . is_some ( )
852
850
&& candidate. line_num == error. line_num
853
851
{
854
- push_red_suggestion ( false , true , 1 ) ;
852
+ push_red_suggestion ( false , true , if kind_mismatch { 2 } else { 1 } ) ;
855
853
}
856
854
}
857
855
858
856
show_suggestions ( suggestions, "expected" , Color :: Red ) ;
859
857
}
860
- println ! ( "{}" , "---" . green( ) ) ;
861
858
}
862
859
if !not_found. is_empty ( ) {
863
- let header = "--- expected in test file but not reported in JSON output ---" ;
864
- println ! ( "{}" , header. red( ) ) ;
860
+ self . error ( & format ! (
861
+ "{} diagnostics expected in test file but not reported in JSON output" ,
862
+ not_found. len( )
863
+ ) ) ;
865
864
for error in & not_found {
866
865
print_error ( error) ;
867
866
let mut suggestions = Vec :: new ( ) ;
868
867
for candidate in unexpected. iter ( ) . chain ( & unimportant) {
868
+ let kind_mismatch = candidate. kind != error. kind ;
869
869
let mut push_green_suggestion = |line, msg, rank| {
870
870
push_suggestion (
871
871
& mut suggestions,
872
872
candidate,
873
- candidate . kind != error . kind ,
873
+ kind_mismatch ,
874
874
line,
875
875
msg,
876
876
Color :: Green ,
@@ -882,13 +882,12 @@ impl<'test> TestCx<'test> {
882
882
} else if candidate. line_num . is_some ( )
883
883
&& candidate. line_num == error. line_num
884
884
{
885
- push_green_suggestion ( false , true , 1 ) ;
885
+ push_green_suggestion ( false , true , if kind_mismatch { 2 } else { 1 } ) ;
886
886
}
887
887
}
888
888
889
889
show_suggestions ( suggestions, "reported" , Color :: Green ) ;
890
890
}
891
- println ! ( "{}" , "---" . red( ) ) ;
892
891
}
893
892
panic ! (
894
893
"errors differ from expected\n status: {}\n command: {}\n " ,
0 commit comments