@@ -18,6 +18,7 @@ use header::TestProps;
1818use header;
1919use procsrv;
2020use test:: TestPaths ;
21+ use uidiff;
2122use util:: logv;
2223
2324use std:: env;
@@ -2115,8 +2116,8 @@ actual:\n\
21152116 let normalized_stderr = self . normalize_output ( & proc_res. stderr ) ;
21162117
21172118 let mut errors = 0 ;
2118- errors += self . compare_output ( "stdout" , normalized_stdout. as_bytes ( ) , & expected_stdout) ;
2119- errors += self . compare_output ( "stderr" , normalized_stderr. as_bytes ( ) , & expected_stderr) ;
2119+ errors += self . compare_output ( "stdout" , & normalized_stdout, & expected_stdout) ;
2120+ errors += self . compare_output ( "stderr" , & normalized_stderr, & expected_stderr) ;
21202121
21212122 if errors > 0 {
21222123 println ! ( "To update references, run this command from build directory:" ) ;
@@ -2127,15 +2128,18 @@ actual:\n\
21272128 self . config. src_base. display( ) ,
21282129 self . config. build_base. display( ) ,
21292130 relative_path_to_file. display( ) ) ;
2130- self . fatal ( & format ! ( "{} errors occurred comparing output." , errors) ) ;
2131+ self . fatal_proc_rec ( & format ! ( "{} errors occurred comparing output." , errors) ,
2132+ & proc_res) ;
21312133 }
21322134 }
21332135
21342136 fn normalize_output ( & self , output : & str ) -> String {
21352137 let parent_dir = self . testpaths . file . parent ( ) . unwrap ( ) ;
21362138 let parent_dir_str = parent_dir. display ( ) . to_string ( ) ;
21372139 output. replace ( & parent_dir_str, "$DIR" )
2138- . replace ( "\\ " , "/" ) // windows, you know.
2140+ . replace ( "\\ " , "/" ) // normalize for paths on windows
2141+ . replace ( "\r \n " , "\n " ) // normalize for linebreaks on windows
2142+ . replace ( "\t " , "\\ t" ) // makes tabs visible
21392143 }
21402144
21412145 fn expected_output_path ( & self , kind : & str ) -> PathBuf {
@@ -2146,31 +2150,34 @@ actual:\n\
21462150 self . testpaths . file . with_extension ( extension)
21472151 }
21482152
2149- fn load_expected_output ( & self , path : & Path ) -> Vec < u8 > {
2153+ fn load_expected_output ( & self , path : & Path ) -> String {
21502154 if !path. exists ( ) {
2151- return vec ! [ ] ;
2155+ return String :: new ( ) ;
21522156 }
21532157
2154- let mut result = Vec :: new ( ) ;
2155- match File :: open ( path) . and_then ( |mut f| f. read_to_end ( & mut result) ) {
2158+ let mut result = String :: new ( ) ;
2159+ match File :: open ( path) . and_then ( |mut f| f. read_to_string ( & mut result) ) {
21562160 Ok ( _) => result,
21572161 Err ( e) => {
21582162 self . fatal ( & format ! ( "failed to load expected output from `{}`: {}" , path. display( ) , e) )
21592163 }
21602164 }
21612165 }
21622166
2163- fn compare_output ( & self , kind : & str , actual : & [ u8 ] , expected : & [ u8 ] ) -> usize {
2164- if self . config . verbose {
2165- println ! ( "normalized {}:\n {}\n " , kind, str :: from_utf8( actual) . unwrap_or( "not utf8" ) ) ;
2166- println ! ( "expected {}:\n {}\n " , kind, str :: from_utf8( expected) . unwrap_or( "not utf8" ) ) ;
2167- }
2167+ fn compare_output ( & self , kind : & str , actual : & str , expected : & str ) -> usize {
21682168 if actual == expected {
21692169 return 0 ;
21702170 }
21712171
2172+ println ! ( "normalized {}:\n {}\n " , kind, actual) ;
2173+ println ! ( "expected {}:\n {}\n " , kind, expected) ;
2174+ println ! ( "diff of {}:\n " , kind) ;
2175+ for line in uidiff:: diff_lines ( actual, expected) {
2176+ println ! ( "{}" , line) ;
2177+ }
2178+
21722179 let output_file = self . output_base_name ( ) . with_extension ( kind) ;
2173- match File :: create ( & output_file) . and_then ( |mut f| f. write_all ( actual) ) {
2180+ match File :: create ( & output_file) . and_then ( |mut f| f. write_all ( actual. as_bytes ( ) ) ) {
21742181 Ok ( ( ) ) => { }
21752182 Err ( e) => {
21762183 self . fatal ( & format ! ( "failed to write {} to `{}`: {}" ,
0 commit comments