Skip to content

Commit b942142

Browse files
zichanggcommit-bot@chromium.org
authored andcommitted
[io] add testcases for link pointing to directory
As Alex suggested, add test for links of directory. Previous cl only check links pointing to a file. https://dart-review.googlesource.com/c/sdk/+/122028/ Change-Id: I0529c9cdde3178a3364b0d091c833b5c63a39b47 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122422 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Zichang Guo <zichangguo@google.com>
1 parent 230f48d commit b942142

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/standalone_2/io/link_test.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,17 @@ testRelativeLinksSync() {
276276
}
277277

278278
testIsDir() async {
279+
// Only run on Platforms that supports file watcher
279280
if (!Platform.isWindows && !Platform.isLinux && !Platform.isMacOS) return;
280281
Directory sandbox = Directory.systemTemp.createTempSync();
281282
Directory dir = new Directory(sandbox.path + Platform.pathSeparator + "dir");
282283
dir.createSync();
283284
File target = new File(sandbox.path + Platform.pathSeparator + "target");
284285
target.createSync();
285286

286-
final eventCompleter = new Completer<FileSystemEvent>();
287+
var eventCompleter = new Completer<FileSystemEvent>();
287288
var subscription;
289+
// Check for link pointing to file
288290
subscription = dir.watch().listen((FileSystemEvent event) {
289291
if (event.path.endsWith('link')) {
290292
eventCompleter.complete(event);
@@ -293,8 +295,20 @@ testIsDir() async {
293295
});
294296
Link link = new Link(dir.path + Platform.pathSeparator + "link");
295297
link.createSync(target.path);
296-
final event = await eventCompleter.future;
297-
// Link should not be marked as Dir.
298+
var event = await eventCompleter.future;
299+
Expect.isFalse(event.isDirectory);
300+
301+
// Check for link pointing to directory
302+
eventCompleter = new Completer<FileSystemEvent>();
303+
subscription = dir.watch().listen((FileSystemEvent event) {
304+
if (event.path.endsWith('link2')) {
305+
eventCompleter.complete(event);
306+
subscription.cancel();
307+
}
308+
});
309+
link = new Link(dir.path + Platform.pathSeparator + "link2");
310+
link.createSync(dir.path);
311+
event = await eventCompleter.future;
298312
Expect.isFalse(event.isDirectory);
299313

300314
sandbox.deleteSync(recursive: true);

0 commit comments

Comments
 (0)