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 {
200
200
fn verify_touch ( ) -> Result < ( ) > {
201
201
const FILE_CONTENT : & [ u8 ] =
202
202
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?
204
204
205
205
let temp_dir = tempfile:: TempDir :: new ( ) ?;
206
206
let mut victim_path = temp_dir. path ( ) . to_owned ( ) ;
@@ -215,15 +215,20 @@ mod test {
215
215
let act_content = fs:: read ( & victim_path) ?;
216
216
217
217
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.
218
226
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
225
231
) ;
226
-
227
232
Ok ( ( ) )
228
233
}
229
234
}
You can’t perform that action at this time.
0 commit comments