3
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
5
use std:: borrow:: Cow :: Borrowed ;
6
- use std:: old_io:: { File , Command , Writer , TempDir , IoResult } ;
7
- use std:: old_io as io;
6
+ use std:: fs:: File ;
7
+ use std:: io:: { self , Write } ;
8
+ use std:: path:: Path ;
9
+ use std:: process:: Command ;
8
10
use std:: num:: Float ;
9
11
use std:: mem;
10
12
use serialize:: json:: { self , Json , ToJson } ;
13
+ use tempdir:: TempDir ;
11
14
use test;
12
15
13
16
use encoding:: label:: encoding_from_whatwg_label;
@@ -26,30 +29,25 @@ macro_rules! JArray {
26
29
}
27
30
28
31
29
- fn write_whole_file ( path : & Path , data : & str ) -> IoResult < ( ) > {
30
- ( try!( File :: open_mode ( path, io :: Open , io :: Write ) ) ) . write_all ( data. as_bytes ( ) )
32
+ fn write_whole_file ( path : & Path , data : & str ) -> io :: Result < ( ) > {
33
+ ( try!( File :: create ( path) ) ) . write_all ( data. as_bytes ( ) )
31
34
}
32
35
33
36
34
- fn print_json_diff ( results : & Json , expected : & Json ) -> IoResult < ( ) > {
35
- use std:: old_io:: stdio:: stdout;
36
-
37
+ fn print_json_diff ( results : & Json , expected : & Json ) -> io:: Result < ( ) > {
37
38
let temp = try!( TempDir :: new ( "rust-cssparser-tests" ) ) ;
38
39
let results = results. pretty ( ) . to_string ( ) + "\n " ;
39
40
let expected = expected. pretty ( ) . to_string ( ) + "\n " ;
40
- let mut result_path = temp. path ( ) . clone ( ) ;
41
- result_path. push ( "results.json" ) ;
42
- let mut expected_path = temp. path ( ) . clone ( ) ;
43
- expected_path. push ( "expected.json" ) ;
41
+ let result_path = temp. path ( ) . join ( "results.json" ) ;
42
+ let expected_path = temp. path ( ) . join ( "expected.json" ) ;
44
43
try!( write_whole_file ( & result_path, results. as_slice ( ) ) ) ;
45
44
try!( write_whole_file ( & expected_path, expected. as_slice ( ) ) ) ;
46
- stdout ( ) . write_all ( try!( Command :: new ( "colordiff" )
45
+ try!( Command :: new ( "colordiff" )
47
46
. arg ( "-u1000" )
48
- . arg ( result_path. display ( ) . to_string ( ) )
49
- . arg ( expected_path. display ( ) . to_string ( ) )
50
- . output ( )
51
- . map_err ( |_| io:: standard_error ( io:: OtherIoError ) )
52
- ) . output . as_slice ( ) )
47
+ . arg ( & result_path)
48
+ . arg ( & expected_path)
49
+ . status ( ) ) ;
50
+ Ok ( ( ) )
53
51
}
54
52
55
53
0 commit comments