File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,15 +42,21 @@ async fn open_write() -> anyhow::Result<()> {
4242
4343#[ test( tokio:: test) ]
4444async fn readdir ( ) -> anyhow:: Result < ( ) > {
45- let accesses = track_child ! ( ( ) , |( ) : ( ) | {
45+ let tmpdir = tempfile:: tempdir ( ) ?;
46+ let tmpdir_path = std:: fs:: canonicalize ( tmpdir. path ( ) ) ?;
47+
48+ std:: fs:: create_dir ( tmpdir. path ( ) . join ( "hello_dir" ) ) ?;
49+
50+ let accesses = track_child ! ( tmpdir_path. to_str( ) . unwrap( ) . to_owned( ) , |tmpdir_path: String | {
51+ std:: env:: set_current_dir( tmpdir_path) . unwrap( ) ;
4652 tokio:: runtime:: Builder :: new_current_thread( ) . enable_io( ) . build( ) . unwrap( ) . block_on(
4753 async {
4854 let _ = tokio:: fs:: read_dir( "hello_dir" ) . await ;
4955 } ,
5056 ) ;
5157 } )
5258 . await ?;
53- assert_contains ( & accesses, current_dir ( ) ? . join ( "hello_dir" ) . as_path ( ) , AccessMode :: READ_DIR ) ;
59+ assert_contains ( & accesses, tmpdir_path . join ( "hello_dir" ) . as_path ( ) , AccessMode :: READ_DIR ) ;
5460
5561 Ok ( ( ) )
5662}
You can’t perform that action at this time.
0 commit comments