@@ -138,7 +138,7 @@ pub fn run(
138
138
139
139
if config. verbose {
140
140
// We're going to be dumping a lot of info. Start on a new line.
141
- print ! ( "\n \n " ) ;
141
+ write ! ( stdout , "\n \n " ) ;
142
142
}
143
143
debug ! ( "running {}" , testpaths. file) ;
144
144
let mut props = TestProps :: from_file ( & testpaths. file , revision, & config) ;
@@ -614,7 +614,8 @@ impl<'test> TestCx<'test> {
614
614
) ;
615
615
} else {
616
616
for pattern in missing_patterns {
617
- println ! (
617
+ writeln ! (
618
+ self . stdout,
618
619
"\n {prefix}: error pattern '{pattern}' not found!" ,
619
620
prefix = self . error_prefix( )
620
621
) ;
@@ -794,7 +795,8 @@ impl<'test> TestCx<'test> {
794
795
} ;
795
796
format ! ( "{file_name}:{line_num}{opt_col_num}" )
796
797
} ;
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( ) ) ;
798
800
let push_suggestion =
799
801
|suggestions : & mut Vec < _ > , e : & Error , kind, line, msg, color, rank| {
800
802
let mut ret = String :: new ( ) ;
@@ -822,7 +824,7 @@ impl<'test> TestCx<'test> {
822
824
if let Some ( & ( _, top_rank) ) = suggestions. first ( ) {
823
825
for ( suggestion, rank) in suggestions {
824
826
if rank == top_rank {
825
- println ! ( " {} {suggestion}" , prefix. color( color) ) ;
827
+ writeln ! ( self . stdout , " {} {suggestion}" , prefix. color( color) ) ;
826
828
}
827
829
}
828
830
}
@@ -835,7 +837,8 @@ impl<'test> TestCx<'test> {
835
837
// - only known line - meh, but suggested
836
838
// - others are not worth suggesting
837
839
if !unexpected. is_empty ( ) {
838
- println ! (
840
+ writeln ! (
841
+ self . stdout,
839
842
"\n {prefix}: {n} diagnostics reported in JSON output but not expected in test file" ,
840
843
prefix = self . error_prefix( ) ,
841
844
n = unexpected. len( ) ,
@@ -869,7 +872,8 @@ impl<'test> TestCx<'test> {
869
872
}
870
873
}
871
874
if !not_found. is_empty ( ) {
872
- println ! (
875
+ writeln ! (
876
+ self . stdout,
873
877
"\n {prefix}: {n} diagnostics expected in test file but not reported in JSON output" ,
874
878
prefix = self . error_prefix( ) ,
875
879
n = not_found. len( ) ,
@@ -1963,11 +1967,11 @@ impl<'test> TestCx<'test> {
1963
1967
} else {
1964
1968
path. file_name ( ) . unwrap ( ) . into ( )
1965
1969
} ;
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 , "------------------------------------------" ) ;
1971
1975
}
1972
1976
1973
1977
fn dump_output_file ( & self , out : & str , extension : & str ) {
@@ -2029,7 +2033,7 @@ impl<'test> TestCx<'test> {
2029
2033
debug ! ( "{message}" ) ;
2030
2034
if self . config . verbose {
2031
2035
// Note: `./x test ... --verbose --no-capture` is needed to see this print.
2032
- println ! ( "{message}" ) ;
2036
+ writeln ! ( self . stdout , "{message}" ) ;
2033
2037
}
2034
2038
}
2035
2039
@@ -2045,7 +2049,7 @@ impl<'test> TestCx<'test> {
2045
2049
2046
2050
#[ track_caller]
2047
2051
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( ) ) ;
2049
2053
error ! ( "fatal error, panic: {:?}" , err) ;
2050
2054
panic ! ( "fatal error" ) ;
2051
2055
}
@@ -2063,15 +2067,15 @@ impl<'test> TestCx<'test> {
2063
2067
proc_res : & ProcRes ,
2064
2068
callback_before_unwind : impl FnOnce ( ) ,
2065
2069
) -> ! {
2066
- println ! ( "\n {prefix}: {err}" , prefix = self . error_prefix( ) ) ;
2070
+ writeln ! ( self . stdout , "\n {prefix}: {err}" , prefix = self . error_prefix( ) ) ;
2067
2071
2068
2072
// Some callers want to print additional notes after the main error message.
2069
2073
if let Some ( note) = extra_note {
2070
- println ! ( "{note}" ) ;
2074
+ writeln ! ( self . stdout , "{note}" ) ;
2071
2075
}
2072
2076
2073
2077
// 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( ) ) ;
2075
2079
2076
2080
// Some callers want print more context or show a custom diff before the unwind occurs.
2077
2081
callback_before_unwind ( ) ;
@@ -2141,7 +2145,7 @@ impl<'test> TestCx<'test> {
2141
2145
if !self . config . has_html_tidy {
2142
2146
return ;
2143
2147
}
2144
- println ! ( "info: generating a diff against nightly rustdoc" ) ;
2148
+ writeln ! ( self . stdout , "info: generating a diff against nightly rustdoc" ) ;
2145
2149
2146
2150
let suffix =
2147
2151
self . safe_revision ( ) . map_or ( "nightly" . into ( ) , |path| path. to_owned ( ) + "-nightly" ) ;
@@ -2177,7 +2181,7 @@ impl<'test> TestCx<'test> {
2177
2181
2178
2182
let proc_res = new_rustdoc. document ( & compare_dir, & new_rustdoc. testpaths ) ;
2179
2183
if !proc_res. status . success ( ) {
2180
- eprintln ! ( "failed to run nightly rustdoc" ) ;
2184
+ writeln ! ( self . stderr , "failed to run nightly rustdoc" ) ;
2181
2185
return ;
2182
2186
}
2183
2187
@@ -2222,6 +2226,7 @@ impl<'test> TestCx<'test> {
2222
2226
let diff_filename = format ! ( "build/tmp/rustdoc-compare-{}.diff" , std:: process:: id( ) ) ;
2223
2227
2224
2228
if !write_filtered_diff (
2229
+ self ,
2225
2230
& diff_filename,
2226
2231
out_dir,
2227
2232
& compare_dir,
@@ -2242,7 +2247,7 @@ impl<'test> TestCx<'test> {
2242
2247
if let Some ( pager) = pager {
2243
2248
let pager = pager. trim ( ) ;
2244
2249
if self . config . verbose {
2245
- eprintln ! ( "using pager {}" , pager) ;
2250
+ writeln ! ( self . stderr , "using pager {}" , pager) ;
2246
2251
}
2247
2252
let output = Command :: new ( pager)
2248
2253
// disable paging; we want this to be non-interactive
@@ -2253,8 +2258,8 @@ impl<'test> TestCx<'test> {
2253
2258
. output ( )
2254
2259
. unwrap ( ) ;
2255
2260
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) ) ;
2258
2263
} else {
2259
2264
warning ! ( "no pager configured, falling back to unified diff" ) ;
2260
2265
help ! (
@@ -2269,7 +2274,7 @@ impl<'test> TestCx<'test> {
2269
2274
match diff. read_until ( b'\n' , & mut line) {
2270
2275
Ok ( 0 ) => break ,
2271
2276
Ok ( _) => { }
2272
- Err ( e) => eprintln ! ( "ERROR: {:?}" , e) ,
2277
+ Err ( e) => writeln ! ( self . stderr , "ERROR: {:?}" , e) ,
2273
2278
}
2274
2279
match String :: from_utf8 ( line. clone ( ) ) {
2275
2280
Ok ( line) => {
@@ -2817,11 +2822,11 @@ impl<'test> TestCx<'test> {
2817
2822
if let Err ( err) = fs:: write ( & actual_path, & actual) {
2818
2823
self . fatal ( & format ! ( "failed to write {stream} to `{actual_path}`: {err}" , ) ) ;
2819
2824
}
2820
- println ! ( "Saved the actual {stream} to `{actual_path}`" ) ;
2825
+ writeln ! ( self . stdout , "Saved the actual {stream} to `{actual_path}`" ) ;
2821
2826
2822
2827
if !self . config . bless {
2823
2828
if expected. is_empty ( ) {
2824
- println ! ( "normalized {}:\n {}\n " , stream, actual) ;
2829
+ writeln ! ( self . stdout , "normalized {}:\n {}\n " , stream, actual) ;
2825
2830
} else {
2826
2831
self . show_diff (
2827
2832
stream,
@@ -2845,14 +2850,15 @@ impl<'test> TestCx<'test> {
2845
2850
if let Err ( err) = fs:: write ( & expected_path, & actual) {
2846
2851
self . fatal ( & format ! ( "failed to write {stream} to `{expected_path}`: {err}" ) ) ;
2847
2852
}
2848
- println ! (
2853
+ writeln ! (
2854
+ self . stdout,
2849
2855
"Blessing the {stream} of `{test_name}` as `{expected_path}`" ,
2850
2856
test_name = self . testpaths. file
2851
2857
) ;
2852
2858
}
2853
2859
}
2854
2860
2855
- println ! ( "\n The actual {stream} differed from the expected {stream}" ) ;
2861
+ writeln ! ( self . stdout , "\n The actual {stream} differed from the expected {stream}" ) ;
2856
2862
2857
2863
if self . config . bless { CompareOutcome :: Blessed } else { CompareOutcome :: Differed }
2858
2864
}
@@ -2867,7 +2873,7 @@ impl<'test> TestCx<'test> {
2867
2873
actual : & str ,
2868
2874
actual_unnormalized : & str ,
2869
2875
) {
2870
- eprintln ! ( "diff of {stream}:\n " ) ;
2876
+ writeln ! ( self . stderr , "diff of {stream}:\n " ) ;
2871
2877
if let Some ( diff_command) = self . config . diff_command . as_deref ( ) {
2872
2878
let mut args = diff_command. split_whitespace ( ) ;
2873
2879
let name = args. next ( ) . unwrap ( ) ;
@@ -2879,11 +2885,11 @@ impl<'test> TestCx<'test> {
2879
2885
}
2880
2886
Ok ( output) => {
2881
2887
let output = String :: from_utf8_lossy ( & output. stdout ) ;
2882
- eprint ! ( "{output}" ) ;
2888
+ write ! ( self . stderr , "{output}" ) ;
2883
2889
}
2884
2890
}
2885
2891
} else {
2886
- eprint ! ( "{}" , write_diff( expected, actual, 3 ) ) ;
2892
+ write ! ( self . stderr , "{}" , write_diff( expected, actual, 3 ) ) ;
2887
2893
}
2888
2894
2889
2895
// 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> {
2921
2927
&& !mismatches_unnormalized. is_empty ( )
2922
2928
&& !mismatches_normalized. is_empty ( )
2923
2929
{
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
+ ) ;
2925
2934
// 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
+ ) ;
2927
2940
}
2928
2941
}
2929
2942
@@ -3001,7 +3014,7 @@ impl<'test> TestCx<'test> {
3001
3014
fs:: create_dir_all ( & incremental_dir) . unwrap ( ) ;
3002
3015
3003
3016
if self . config . verbose {
3004
- println ! ( "init_incremental_test: incremental_dir={incremental_dir}" ) ;
3017
+ writeln ! ( self . stdout , "init_incremental_test: incremental_dir={incremental_dir}" ) ;
3005
3018
}
3006
3019
}
3007
3020
}
0 commit comments