@@ -138,7 +138,7 @@ pub fn run(
138138
139139 if config. verbose {
140140 // We're going to be dumping a lot of info. Start on a new line.
141- print ! ( "\n \n " ) ;
141+ write ! ( stdout , "\n \n " ) ;
142142 }
143143 debug ! ( "running {}" , testpaths. file) ;
144144 let mut props = TestProps :: from_file ( & testpaths. file , revision, & config) ;
@@ -614,7 +614,8 @@ impl<'test> TestCx<'test> {
614614 ) ;
615615 } else {
616616 for pattern in missing_patterns {
617- println ! (
617+ writeln ! (
618+ self . stdout,
618619 "\n {prefix}: error pattern '{pattern}' not found!" ,
619620 prefix = self . error_prefix( )
620621 ) ;
@@ -794,7 +795,8 @@ impl<'test> TestCx<'test> {
794795 } ;
795796 format ! ( "{file_name}:{line_num}{opt_col_num}" )
796797 } ;
797- let print_error = |e| println ! ( "{}: {}: {}" , line_str( e) , e. kind, e. msg. cyan( ) ) ;
798+ let print_error =
799+ |e| writeln ! ( self . stdout, "{}: {}: {}" , line_str( e) , e. kind, e. msg. cyan( ) ) ;
798800 let push_suggestion =
799801 |suggestions : & mut Vec < _ > , e : & Error , kind, line, msg, color, rank| {
800802 let mut ret = String :: new ( ) ;
@@ -822,7 +824,7 @@ impl<'test> TestCx<'test> {
822824 if let Some ( & ( _, top_rank) ) = suggestions. first ( ) {
823825 for ( suggestion, rank) in suggestions {
824826 if rank == top_rank {
825- println ! ( " {} {suggestion}" , prefix. color( color) ) ;
827+ writeln ! ( self . stdout , " {} {suggestion}" , prefix. color( color) ) ;
826828 }
827829 }
828830 }
@@ -835,7 +837,8 @@ impl<'test> TestCx<'test> {
835837 // - only known line - meh, but suggested
836838 // - others are not worth suggesting
837839 if !unexpected. is_empty ( ) {
838- println ! (
840+ writeln ! (
841+ self . stdout,
839842 "\n {prefix}: {n} diagnostics reported in JSON output but not expected in test file" ,
840843 prefix = self . error_prefix( ) ,
841844 n = unexpected. len( ) ,
@@ -869,7 +872,8 @@ impl<'test> TestCx<'test> {
869872 }
870873 }
871874 if !not_found. is_empty ( ) {
872- println ! (
875+ writeln ! (
876+ self . stdout,
873877 "\n {prefix}: {n} diagnostics expected in test file but not reported in JSON output" ,
874878 prefix = self . error_prefix( ) ,
875879 n = not_found. len( ) ,
@@ -1963,11 +1967,11 @@ impl<'test> TestCx<'test> {
19631967 } else {
19641968 path. file_name ( ) . unwrap ( ) . into ( )
19651969 } ;
1966- println ! ( "------{proc_name} stdout------------------------------" ) ;
1967- println ! ( "{}" , out) ;
1968- println ! ( "------{proc_name} stderr------------------------------" ) ;
1969- println ! ( "{}" , err) ;
1970- println ! ( "------------------------------------------" ) ;
1970+ writeln ! ( self . stdout , "------{proc_name} stdout------------------------------" ) ;
1971+ writeln ! ( self . stdout , "{}" , out) ;
1972+ writeln ! ( self . stdout , "------{proc_name} stderr------------------------------" ) ;
1973+ writeln ! ( self . stdout , "{}" , err) ;
1974+ writeln ! ( self . stdout , "------------------------------------------" ) ;
19711975 }
19721976
19731977 fn dump_output_file ( & self , out : & str , extension : & str ) {
@@ -2029,7 +2033,7 @@ impl<'test> TestCx<'test> {
20292033 debug ! ( "{message}" ) ;
20302034 if self . config . verbose {
20312035 // Note: `./x test ... --verbose --no-capture` is needed to see this print.
2032- println ! ( "{message}" ) ;
2036+ writeln ! ( self . stdout , "{message}" ) ;
20332037 }
20342038 }
20352039
@@ -2045,7 +2049,7 @@ impl<'test> TestCx<'test> {
20452049
20462050 #[ track_caller]
20472051 fn fatal ( & self , err : & str ) -> ! {
2048- println ! ( "\n {prefix}: {err}" , prefix = self . error_prefix( ) ) ;
2052+ writeln ! ( self . stdout , "\n {prefix}: {err}" , prefix = self . error_prefix( ) ) ;
20492053 error ! ( "fatal error, panic: {:?}" , err) ;
20502054 panic ! ( "fatal error" ) ;
20512055 }
@@ -2063,15 +2067,15 @@ impl<'test> TestCx<'test> {
20632067 proc_res : & ProcRes ,
20642068 callback_before_unwind : impl FnOnce ( ) ,
20652069 ) -> ! {
2066- println ! ( "\n {prefix}: {err}" , prefix = self . error_prefix( ) ) ;
2070+ writeln ! ( self . stdout , "\n {prefix}: {err}" , prefix = self . error_prefix( ) ) ;
20672071
20682072 // Some callers want to print additional notes after the main error message.
20692073 if let Some ( note) = extra_note {
2070- println ! ( "{note}" ) ;
2074+ writeln ! ( self . stdout , "{note}" ) ;
20712075 }
20722076
20732077 // Print the details and output of the subprocess that caused this test to fail.
2074- println ! ( "{}" , proc_res. format_info( ) ) ;
2078+ writeln ! ( self . stdout , "{}" , proc_res. format_info( ) ) ;
20752079
20762080 // Some callers want print more context or show a custom diff before the unwind occurs.
20772081 callback_before_unwind ( ) ;
@@ -2141,7 +2145,7 @@ impl<'test> TestCx<'test> {
21412145 if !self . config . has_html_tidy {
21422146 return ;
21432147 }
2144- println ! ( "info: generating a diff against nightly rustdoc" ) ;
2148+ writeln ! ( self . stdout , "info: generating a diff against nightly rustdoc" ) ;
21452149
21462150 let suffix =
21472151 self . safe_revision ( ) . map_or ( "nightly" . into ( ) , |path| path. to_owned ( ) + "-nightly" ) ;
@@ -2177,7 +2181,7 @@ impl<'test> TestCx<'test> {
21772181
21782182 let proc_res = new_rustdoc. document ( & compare_dir, & new_rustdoc. testpaths ) ;
21792183 if !proc_res. status . success ( ) {
2180- eprintln ! ( "failed to run nightly rustdoc" ) ;
2184+ writeln ! ( self . stderr , "failed to run nightly rustdoc" ) ;
21812185 return ;
21822186 }
21832187
@@ -2222,6 +2226,7 @@ impl<'test> TestCx<'test> {
22222226 let diff_filename = format ! ( "build/tmp/rustdoc-compare-{}.diff" , std:: process:: id( ) ) ;
22232227
22242228 if !write_filtered_diff (
2229+ self ,
22252230 & diff_filename,
22262231 out_dir,
22272232 & compare_dir,
@@ -2242,7 +2247,7 @@ impl<'test> TestCx<'test> {
22422247 if let Some ( pager) = pager {
22432248 let pager = pager. trim ( ) ;
22442249 if self . config . verbose {
2245- eprintln ! ( "using pager {}" , pager) ;
2250+ writeln ! ( self . stderr , "using pager {}" , pager) ;
22462251 }
22472252 let output = Command :: new ( pager)
22482253 // disable paging; we want this to be non-interactive
@@ -2253,8 +2258,8 @@ impl<'test> TestCx<'test> {
22532258 . output ( )
22542259 . unwrap ( ) ;
22552260 assert ! ( output. status. success( ) ) ;
2256- println ! ( "{}" , String :: from_utf8_lossy( & output. stdout) ) ;
2257- eprintln ! ( "{}" , String :: from_utf8_lossy( & output. stderr) ) ;
2261+ writeln ! ( self . stdout , "{}" , String :: from_utf8_lossy( & output. stdout) ) ;
2262+ writeln ! ( self . stderr , "{}" , String :: from_utf8_lossy( & output. stderr) ) ;
22582263 } else {
22592264 warning ! ( "no pager configured, falling back to unified diff" ) ;
22602265 help ! (
@@ -2269,7 +2274,7 @@ impl<'test> TestCx<'test> {
22692274 match diff. read_until ( b'\n' , & mut line) {
22702275 Ok ( 0 ) => break ,
22712276 Ok ( _) => { }
2272- Err ( e) => eprintln ! ( "ERROR: {:?}" , e) ,
2277+ Err ( e) => writeln ! ( self . stderr , "ERROR: {:?}" , e) ,
22732278 }
22742279 match String :: from_utf8 ( line. clone ( ) ) {
22752280 Ok ( line) => {
@@ -2817,11 +2822,11 @@ impl<'test> TestCx<'test> {
28172822 if let Err ( err) = fs:: write ( & actual_path, & actual) {
28182823 self . fatal ( & format ! ( "failed to write {stream} to `{actual_path}`: {err}" , ) ) ;
28192824 }
2820- println ! ( "Saved the actual {stream} to `{actual_path}`" ) ;
2825+ writeln ! ( self . stdout , "Saved the actual {stream} to `{actual_path}`" ) ;
28212826
28222827 if !self . config . bless {
28232828 if expected. is_empty ( ) {
2824- println ! ( "normalized {}:\n {}\n " , stream, actual) ;
2829+ writeln ! ( self . stdout , "normalized {}:\n {}\n " , stream, actual) ;
28252830 } else {
28262831 self . show_diff (
28272832 stream,
@@ -2845,14 +2850,15 @@ impl<'test> TestCx<'test> {
28452850 if let Err ( err) = fs:: write ( & expected_path, & actual) {
28462851 self . fatal ( & format ! ( "failed to write {stream} to `{expected_path}`: {err}" ) ) ;
28472852 }
2848- println ! (
2853+ writeln ! (
2854+ self . stdout,
28492855 "Blessing the {stream} of `{test_name}` as `{expected_path}`" ,
28502856 test_name = self . testpaths. file
28512857 ) ;
28522858 }
28532859 }
28542860
2855- println ! ( "\n The actual {stream} differed from the expected {stream}" ) ;
2861+ writeln ! ( self . stdout , "\n The actual {stream} differed from the expected {stream}" ) ;
28562862
28572863 if self . config . bless { CompareOutcome :: Blessed } else { CompareOutcome :: Differed }
28582864 }
@@ -2867,7 +2873,7 @@ impl<'test> TestCx<'test> {
28672873 actual : & str ,
28682874 actual_unnormalized : & str ,
28692875 ) {
2870- eprintln ! ( "diff of {stream}:\n " ) ;
2876+ writeln ! ( self . stderr , "diff of {stream}:\n " ) ;
28712877 if let Some ( diff_command) = self . config . diff_command . as_deref ( ) {
28722878 let mut args = diff_command. split_whitespace ( ) ;
28732879 let name = args. next ( ) . unwrap ( ) ;
@@ -2879,11 +2885,11 @@ impl<'test> TestCx<'test> {
28792885 }
28802886 Ok ( output) => {
28812887 let output = String :: from_utf8_lossy ( & output. stdout ) ;
2882- eprint ! ( "{output}" ) ;
2888+ write ! ( self . stderr , "{output}" ) ;
28832889 }
28842890 }
28852891 } else {
2886- eprint ! ( "{}" , write_diff( expected, actual, 3 ) ) ;
2892+ write ! ( self . stderr , "{}" , write_diff( expected, actual, 3 ) ) ;
28872893 }
28882894
28892895 // NOTE: argument order is important, we need `actual` to be on the left so the line number match up when we compare it to `actual_unnormalized` below.
@@ -2921,9 +2927,16 @@ impl<'test> TestCx<'test> {
29212927 && !mismatches_unnormalized. is_empty ( )
29222928 && !mismatches_normalized. is_empty ( )
29232929 {
2924- eprintln ! ( "Note: some mismatched output was normalized before being compared" ) ;
2930+ writeln ! (
2931+ self . stderr,
2932+ "Note: some mismatched output was normalized before being compared"
2933+ ) ;
29252934 // FIXME: respect diff_command
2926- eprint ! ( "{}" , write_diff( & mismatches_unnormalized, & mismatches_normalized, 0 ) ) ;
2935+ write ! (
2936+ self . stderr,
2937+ "{}" ,
2938+ write_diff( & mismatches_unnormalized, & mismatches_normalized, 0 )
2939+ ) ;
29272940 }
29282941 }
29292942
@@ -3001,7 +3014,7 @@ impl<'test> TestCx<'test> {
30013014 fs:: create_dir_all ( & incremental_dir) . unwrap ( ) ;
30023015
30033016 if self . config . verbose {
3004- println ! ( "init_incremental_test: incremental_dir={incremental_dir}" ) ;
3017+ writeln ! ( self . stdout , "init_incremental_test: incremental_dir={incremental_dir}" ) ;
30053018 }
30063019 }
30073020}
0 commit comments