Skip to content

Commit e0cc0bc

Browse files
authored
Test DirectoryWatcher exception on missing path. (#2224)
1 parent e6ce99d commit e0cc0bc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkgs/watcher/test/directory_watcher/file_tests.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:io' as io;
6+
import 'dart:io';
67
import 'dart:isolate';
78

89
import 'package:test/test.dart';
@@ -18,6 +19,21 @@ void fileTests({required bool isNative}) {
1819
}
1920

2021
void _fileTests({required bool isNative}) {
22+
test('error reported if directory does not exist', () async {
23+
await startWatcher(path: 'missing_path');
24+
25+
// TODO(davidmorgan): reconcile differences.
26+
if (isNative && !Platform.isMacOS) {
27+
expect(expectNoEvents, throwsA(isA<PathNotFoundException>()));
28+
} else {
29+
// The polling watcher and the MacOS watcher do not throw on missing file
30+
// on watch.
31+
await expectNoEvents();
32+
writeFile('missing_path/file.txt');
33+
await expectAddEvent('missing_path/file.txt');
34+
}
35+
});
36+
2137
test('does not notify for files that already exist when started', () async {
2238
// Make some pre-existing files.
2339
writeFile('a.txt');

0 commit comments

Comments
 (0)