File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ mod test {
200200 fn verify_touch ( ) -> Result < ( ) > {
201201 const FILE_CONTENT : & [ u8 ] =
202202 b"I am some random text with crlfs \r \n but also nls \n and terminated with a nl \n " ;
203- const DELAY : Duration = Duration :: from_millis ( 10 ) ; // don't hang up tests for too long.
203+ const DELAY : Duration = Duration :: from_millis ( 20 ) ; // don't hang up tests for too long, but maybe 10ms is too short?
204204
205205 let temp_dir = tempfile:: TempDir :: new ( ) ?;
206206 let mut victim_path = temp_dir. path ( ) . to_owned ( ) ;
@@ -215,15 +215,20 @@ mod test {
215215 let act_content = fs:: read ( & victim_path) ?;
216216
217217 assert_eq ! ( FILE_CONTENT , act_content) ;
218+ let tdif = new_md
219+ . modified ( )
220+ . expect ( "getting modified time new" )
221+ . duration_since ( old_md. modified ( ) . expect ( "getting modified time old" ) )
222+ . expect ( "system time botch" ) ;
223+ // can't expect sleep 20ms to actually delay exactly that --
224+ // but the test is to verify that `touch` made the file look any newer.
225+ // Give ourselves 50% slop under what we were aiming for and call it good enough.
218226 assert ! (
219- new_md
220- . modified( )
221- . expect( "getting modified time" )
222- . duration_since( old_md. modified( ) . expect( "getting modified time old" ) )
223- . expect( "system botch" )
224- >= DELAY
227+ tdif >= ( DELAY / 2 ) ,
228+ "verify_touch: expected {:?}, actual {:?}" ,
229+ DELAY ,
230+ tdif
225231 ) ;
226-
227232 Ok ( ( ) )
228233 }
229234}
You can’t perform that action at this time.
0 commit comments