@@ -3,6 +3,7 @@ use similar::TextDiff;
33use std:: path:: { Path , PathBuf } ;
44
55use crate :: drop_bomb:: DropBomb ;
6+ use crate :: fs_wrapper;
67
78#[ cfg( test) ]
89mod tests;
@@ -41,7 +42,7 @@ impl Diff {
4142 /// Specify the expected output for the diff from a file.
4243 pub fn expected_file < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
4344 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) ;
4546 let name = path. to_string_lossy ( ) . to_string ( ) ;
4647
4748 self . expected_file = Some ( path. into ( ) ) ;
@@ -60,10 +61,7 @@ impl Diff {
6061 /// Specify the actual output for the diff from a file.
6162 pub fn actual_file < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
6263 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) ;
6765 let name = path. to_string_lossy ( ) . to_string ( ) ;
6866
6967 self . actual = Some ( content) ;
@@ -111,7 +109,7 @@ impl Diff {
111109 if let Some ( ref expected_file) = self . expected_file {
112110 if std:: env:: var ( "RUSTC_BLESS_TEST" ) . is_ok ( ) {
113111 println ! ( "Blessing `{}`" , expected_file. display( ) ) ;
114- std :: fs :: write ( expected_file, actual) . unwrap ( ) ;
112+ fs_wrapper :: write ( expected_file, actual) ;
115113 return ;
116114 }
117115 }
0 commit comments