From 647f2ec309017de995b9340e9220987ec0812eb0 Mon Sep 17 00:00:00 2001 From: Zichang Guo Date: Tue, 13 Aug 2019 23:38:15 +0000 Subject: [PATCH] [vm] fix file_system_watcher_test.dart on Mac Fix the failed bot Change-Id: I8179e9bb03d2328a6c9385207ee594fda094a127 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112960 Reviewed-by: Siva Annamalai Commit-Queue: Zichang Guo --- tests/standalone_2/io/file_system_watcher_test.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/standalone_2/io/file_system_watcher_test.dart b/tests/standalone_2/io/file_system_watcher_test.dart index 63b6752c33f..492379ac020 100644 --- a/tests/standalone_2/io/file_system_watcher_test.dart +++ b/tests/standalone_2/io/file_system_watcher_test.dart @@ -336,11 +336,15 @@ testWatchConsistentModifiedFile() async { // Delay some time to ensure that watcher is created when modification is running consistently. await Future.delayed(Duration(milliseconds: 10)); var watcher = dir.watch(); + var subscription; // Wait for event and check the type - var event = await watcher.first; - Expect.isTrue(event is FileSystemModifyEvent); - Expect.isTrue(event.path.endsWith('file')); + subscription = watcher.listen((data) { + if (data is FileSystemModifyEvent) { + Expect.isTrue(data.path.endsWith('file')); + subscription.cancel(); + } + }); // Create a file to signal modifier isolate to stop modification and clean up temp directory. var file = new File(join(dir.path, 'EventReceived'));