@@ -11,7 +11,7 @@ import 'package:watcher/src/utils.dart';
1111
1212import '../utils.dart' ;
1313
14- void fileTests () {
14+ void fileTests ({ required bool isNative} ) {
1515 for (var i = 0 ; i != runsPerTest; ++ i) {
1616 _fileTests ();
1717 }
@@ -297,6 +297,29 @@ void _fileTests() {
297297 })));
298298 });
299299
300+ test (
301+ 'emits events for many nested files moved out then immediately back in' ,
302+ () async {
303+ withPermutations (
304+ (i, j, k) => writeFile ('dir/sub/sub-$i /sub-$j /file-$k .txt' ));
305+
306+ await startWatcher (path: 'dir' );
307+
308+ renameDir ('dir/sub' , 'sub' );
309+ renameDir ('sub' , 'dir/sub' );
310+
311+ if (isNative) {
312+ await inAnyOrder (withPermutations (
313+ (i, j, k) => isRemoveEvent ('dir/sub/sub-$i /sub-$j /file-$k .txt' )));
314+ await inAnyOrder (withPermutations (
315+ (i, j, k) => isAddEvent ('dir/sub/sub-$i /sub-$j /file-$k .txt' )));
316+ } else {
317+ // Polling watchers can't detect this as directory contents mtimes
318+ // aren't updated.
319+ await expectNoEvents ();
320+ }
321+ });
322+
300323 test (
301324 'emits events for many files added at once in a subdirectory with the '
302325 'same name as a removed file' , () async {
@@ -334,4 +357,17 @@ void _fileTests() {
334357 }
335358 });
336359 });
360+
361+ test (
362+ 'does not notify about the watched directory being deleted and '
363+ 'recreated immediately before watching' , () async {
364+ createDir ('dir' );
365+ writeFile ('dir/old.txt' );
366+ deleteDir ('dir' );
367+ createDir ('dir' );
368+
369+ await startWatcher (path: 'dir' );
370+ writeFile ('dir/newer.txt' );
371+ await expectAddEvent ('dir/newer.txt' );
372+ });
337373}
0 commit comments