@@ -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;
@@ -42,7 +43,7 @@ impl Diff {
4243 /// Specify the expected output for the diff from a file.
4344 pub fn expected_file < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
4445 let path = path. as_ref ( ) ;
45- let content = std :: fs :: read_to_string ( path) . expect ( "failed to read file" ) ;
46+ let content = fs_wrapper :: read_to_string ( path) ;
4647 let name = path. to_string_lossy ( ) . to_string ( ) ;
4748
4849 self . expected_file = Some ( path. into ( ) ) ;
@@ -61,10 +62,7 @@ impl Diff {
6162 /// Specify the actual output for the diff from a file.
6263 pub fn actual_file < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
6364 let path = path. as_ref ( ) ;
64- let content = match std:: fs:: read_to_string ( path) {
65- Ok ( c) => c,
66- Err ( e) => panic ! ( "failed to read `{}`: {:?}" , path. display( ) , e) ,
67- } ;
65+ let content = fs_wrapper:: read_to_string ( path) ;
6866 let name = path. to_string_lossy ( ) . to_string ( ) ;
6967
7068 self . actual = Some ( content) ;
@@ -112,7 +110,7 @@ impl Diff {
112110 if let Some ( ref expected_file) = self . expected_file {
113111 if std:: env:: var ( "RUSTC_BLESS_TEST" ) . is_ok ( ) {
114112 println ! ( "Blessing `{}`" , expected_file. display( ) ) ;
115- std :: fs :: write ( expected_file, actual) . unwrap ( ) ;
113+ fs_wrapper :: write ( expected_file, actual) ;
116114 return ;
117115 }
118116 }
0 commit comments