File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -508,11 +508,18 @@ mod tests {
508508 . write_all ( b"runtime modified" )
509509 . expect ( "write" ) ;
510510
511- let event = tokio:: time:: timeout ( WATCH_TIMEOUT , watcher. recv ( ) )
512- . await
513- . expect ( "timeout" )
514- . expect ( "event" ) ;
515-
516- assert_eq ! ( event. path, runtime_file) ;
511+ // On macOS, notify's FSEvents backend restarts the entire stream
512+ // when a new path is added, which replays historical events for
513+ // already-watched paths. Drain until we see the runtime file.
514+ let deadline = tokio:: time:: Instant :: now ( ) + WATCH_TIMEOUT ;
515+ loop {
516+ let remaining = deadline - tokio:: time:: Instant :: now ( ) ;
517+ match tokio:: time:: timeout ( remaining, watcher. recv ( ) ) . await {
518+ Ok ( Some ( e) ) if e. path == runtime_file => break ,
519+ Ok ( Some ( _) ) => continue ,
520+ Ok ( None ) => panic ! ( "watcher channel closed before runtime file event" ) ,
521+ Err ( _) => panic ! ( "timeout waiting for runtime file change event" ) ,
522+ }
523+ }
517524 }
518525}
You can’t perform that action at this time.
0 commit comments