| Index: test/file_watcher/shared.dart
|
| diff --git a/test/file_watcher/shared.dart b/test/file_watcher/shared.dart
|
| index 2931d80228ac6a3803a737e4791da2c1a94ef048..9a4965cccccc8a39621b00f6e2b70ce9b7344ebf 100644
|
| --- a/test/file_watcher/shared.dart
|
| +++ b/test/file_watcher/shared.dart
|
| @@ -2,6 +2,8 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| +import 'dart:async';
|
| +
|
| import 'package:scheduled_test/scheduled_test.dart';
|
| import 'package:watcher/src/utils.dart';
|
|
|
| @@ -55,4 +57,19 @@ void sharedTests() {
|
| renameFile("old.txt", "file.txt");
|
| expectModifyEvent("file.txt");
|
| });
|
| +
|
| + // Regression test for a race condition.
|
| + test("closes the watcher immediately after deleting the file", () {
|
| + writeFile("old.txt");
|
| + var watcher = createWatcher(path: "file.txt", waitForReady: false);
|
| + var sub = schedule(() => watcher.events.listen(null));
|
| +
|
| + deleteFile("file.txt");
|
| + schedule(() async {
|
| + // Reproducing the race condition will always be flaky, but this sleep
|
| + // helped it reproduce more consistently on my machine.
|
| + await new Future.delayed(new Duration(milliseconds: 10));
|
| + (await sub).cancel();
|
| + });
|
| + });
|
| }
|
|
|