@@ -3,6 +3,7 @@ use similar::TextDiff;
3
3
use std:: path:: { Path , PathBuf } ;
4
4
5
5
use crate :: drop_bomb:: DropBomb ;
6
+ use crate :: fs_wrapper;
6
7
7
8
#[ cfg( test) ]
8
9
mod tests;
@@ -41,7 +42,7 @@ impl Diff {
41
42
/// Specify the expected output for the diff from a file.
42
43
pub fn expected_file < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
43
44
let path = path. as_ref ( ) ;
44
- let content = std :: fs :: read_to_string ( path) . expect ( "failed to read file" ) ;
45
+ let content = fs_wrapper :: read ( path) ;
45
46
let name = path. to_string_lossy ( ) . to_string ( ) ;
46
47
47
48
self . expected_file = Some ( path. into ( ) ) ;
@@ -60,10 +61,7 @@ impl Diff {
60
61
/// Specify the actual output for the diff from a file.
61
62
pub fn actual_file < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
62
63
let path = path. as_ref ( ) ;
63
- let content = match std:: fs:: read_to_string ( path) {
64
- Ok ( c) => c,
65
- Err ( e) => panic ! ( "failed to read `{}`: {:?}" , path. display( ) , e) ,
66
- } ;
64
+ let content = fs_wrapper:: read ( path) ;
67
65
let name = path. to_string_lossy ( ) . to_string ( ) ;
68
66
69
67
self . actual = Some ( content) ;
@@ -111,7 +109,7 @@ impl Diff {
111
109
if let Some ( ref expected_file) = self . expected_file {
112
110
if std:: env:: var ( "RUSTC_BLESS_TEST" ) . is_ok ( ) {
113
111
println ! ( "Blessing `{}`" , expected_file. display( ) ) ;
114
- std :: fs :: write ( expected_file, actual) . unwrap ( ) ;
112
+ fs_wrapper :: write ( expected_file, actual) ;
115
113
return ;
116
114
}
117
115
}
0 commit comments