@@ -21,7 +21,10 @@ use util;
21
21
use util:: logv;
22
22
23
23
use std:: cell:: Cell ;
24
- use std:: io;
24
+ use std:: rt:: io;
25
+ use std:: rt:: io:: Writer ;
26
+ use std:: rt:: io:: extensions:: ReaderUtil ;
27
+ use std:: rt:: io:: file:: FileInfo ;
25
28
use std:: os;
26
29
use std:: str;
27
30
use std:: task:: { spawn_sched, SingleThreaded } ;
@@ -60,7 +63,7 @@ pub fn run(config: config, testfile: ~str) {
60
63
pub fn run_metrics ( config : config , testfile : ~str , mm : & mut MetricMap ) {
61
64
if config. verbose {
62
65
// We're going to be dumping a lot of info. Start on a new line.
63
- io :: stdout ( ) . write_str ( "\n \n " ) ;
66
+ print ! ( "\n \n " ) ;
64
67
}
65
68
let testfile = Path :: new ( testfile) ;
66
69
debug ! ( "running {}" , testfile. display( ) ) ;
@@ -170,7 +173,9 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
170
173
let rounds =
171
174
match props. pp_exact { Some ( _) => 1 , None => 2 } ;
172
175
173
- let mut srcs = ~[ io:: read_whole_file_str ( testfile) . unwrap ( ) ] ;
176
+ let src = testfile. open_reader ( io:: Open ) . read_to_end ( ) ;
177
+ let src = str:: from_utf8_owned ( src) ;
178
+ let mut srcs = ~[ src] ;
174
179
175
180
let mut round = 0 ;
176
181
while round < rounds {
@@ -190,7 +195,8 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
190
195
let mut expected = match props. pp_exact {
191
196
Some ( ref file) => {
192
197
let filepath = testfile. dir_path ( ) . join ( file) ;
193
- io:: read_whole_file_str ( & filepath) . unwrap ( )
198
+ let s = filepath. open_reader ( io:: Open ) . read_to_end ( ) ;
199
+ str:: from_utf8_owned ( s)
194
200
}
195
201
None => { srcs[ srcs. len ( ) - 2 u] . clone ( ) }
196
202
} ;
@@ -228,8 +234,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
228
234
fn compare_source( expected : & str , actual : & str ) {
229
235
if expected != actual {
230
236
error( ~"pretty-printed source does not match expected source") ;
231
- let msg =
232
- format ! ( "\n \
237
+ println ! ( "\n \
233
238
expected:\n \
234
239
------------------------------------------\n \
235
240
{}\n \
@@ -240,7 +245,6 @@ actual:\n\
240
245
------------------------------------------\n \
241
246
\n ",
242
247
expected, actual) ;
243
- io:: stdout( ) . write_str ( msg) ;
244
248
fail ! ( ) ;
245
249
}
246
250
}
@@ -741,9 +745,7 @@ fn dump_output(config: &config, testfile: &Path, out: &str, err: &str) {
741
745
fn dump_output_file ( config : & config , testfile : & Path ,
742
746
out : & str , extension : & str ) {
743
747
let outfile = make_out_name ( config, testfile, extension) ;
744
- let writer =
745
- io:: file_writer ( & outfile, [ io:: Create , io:: Truncate ] ) . unwrap ( ) ;
746
- writer. write_str ( out) ;
748
+ outfile. open_writer ( io:: CreateOrTruncate ) . write ( out. as_bytes ( ) ) ;
747
749
}
748
750
749
751
fn make_out_name ( config : & config , testfile : & Path , extension : & str ) -> Path {
@@ -771,24 +773,20 @@ fn output_base_name(config: &config, testfile: &Path) -> Path {
771
773
772
774
fn maybe_dump_to_stdout ( config : & config , out : & str , err : & str ) {
773
775
if config. verbose {
774
- let sep1 = format ! ( "------{}------------------------------" , "stdout" ) ;
775
- let sep2 = format ! ( "------{}------------------------------" , "stderr" ) ;
776
- let sep3 = ~"------------------------------------------";
777
- io::stdout().write_line(sep1);
778
- io::stdout().write_line(out);
779
- io::stdout().write_line(sep2);
780
- io::stdout().write_line(err);
781
- io::stdout().write_line(sep3);
776
+ println ! ( "------{}------------------------------" , "stdout" ) ;
777
+ println ! ( "{}" , out) ;
778
+ println ! ( "------{}------------------------------" , "stderr" ) ;
779
+ println ! ( "{}" , err) ;
780
+ println ! ( "------------------------------------------" ) ;
782
781
}
783
782
}
784
783
785
- fn error(err: ~str) { io::stdout().write_line(format !("\n error: {}" , err) ) ; }
784
+ fn error ( err : ~str ) { println ! ( "\n error: {}" , err) ; }
786
785
787
786
fn fatal ( err : ~str ) -> ! { error ( err) ; fail ! ( ) ; }
788
787
789
788
fn fatal_ProcRes ( err : ~str , ProcRes : & ProcRes ) -> ! {
790
- let msg =
791
- format ! ( "\n \
789
+ print ! ( "\n \
792
790
error: {}\n \
793
791
command: {}\n \
794
792
stdout:\n \
@@ -801,7 +799,6 @@ stderr:\n\
801
799
------------------------------------------\n \
802
800
\n ",
803
801
err, ProcRes . cmdline, ProcRes . stdout, ProcRes . stderr) ;
804
- io:: stdout ( ) . write_str ( msg) ;
805
802
fail ! ( ) ;
806
803
}
807
804
@@ -821,9 +818,9 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
821
818
~[ ( ~"", ~"") ] , Some ( ~"") ) ;
822
819
823
820
if config. verbose {
824
- io :: stdout ( ) . write_str ( format ! ( "push ({}) {} {} {}" ,
821
+ println ! ( "push ({}) {} {} {}" ,
825
822
config. target, args. prog,
826
- copy_result. out, copy_result. err) ) ;
823
+ copy_result. out, copy_result. err) ;
827
824
}
828
825
829
826
logv ( config, format ! ( "executing ({}) {}" , config. target, cmdline) ) ;
@@ -913,9 +910,9 @@ fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
913
910
~[ ( ~"", ~"") ] , Some ( ~"") ) ;
914
911
915
912
if config. verbose {
916
- io :: stdout ( ) . write_str ( format ! ( "push ({}) {} {} {}" ,
913
+ println ! ( "push ({}) {} {} {}" ,
917
914
config. target, file. display( ) ,
918
- copy_result. out, copy_result. err) ) ;
915
+ copy_result. out, copy_result. err) ;
919
916
}
920
917
}
921
918
}
@@ -999,7 +996,8 @@ fn disassemble_extract(config: &config, _props: &TestProps,
999
996
1000
997
1001
998
fn count_extracted_lines ( p : & Path ) -> uint {
1002
- let x = io:: read_whole_file_str ( & p. with_extension ( "ll" ) ) . unwrap ( ) ;
999
+ let x = p. with_extension ( "ll" ) . open_reader ( io:: Open ) . read_to_end ( ) ;
1000
+ let x = str:: from_utf8_owned ( x) ;
1003
1001
x. line_iter ( ) . len ( )
1004
1002
}
1005
1003
0 commit comments