| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:scheduled_test/scheduled_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
| 8 import 'package:watcher/src/directory_watcher/mac_os.dart'; | 8 import 'package:watcher/src/directory_watcher/mac_os.dart'; |
| 9 import 'package:watcher/watcher.dart'; | 9 import 'package:watcher/watcher.dart'; |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 writeFile("b.txt", contents: "after"); | 45 writeFile("b.txt", contents: "after"); |
| 46 expectModifyEvent("a.txt"); | 46 expectModifyEvent("a.txt"); |
| 47 expectModifyEvent("b.txt"); | 47 expectModifyEvent("b.txt"); |
| 48 }); | 48 }); |
| 49 | 49 |
| 50 test('emits events for many nested files moved out then immediately back in', | 50 test('emits events for many nested files moved out then immediately back in', |
| 51 () { | 51 () { |
| 52 withPermutations((i, j, k) => | 52 withPermutations((i, j, k) => |
| 53 writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt")); | 53 writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
| 54 | 54 |
| 55 // We sleep here because a narrow edge case caused by two interacting bugs | |
| 56 // can produce events that aren't expected if we start the watcher too | |
| 57 // soon after creating the files above. Here's what happens: | |
| 58 // | |
| 59 // * We create "dir/sub" and its contents above. | |
| 60 // | |
| 61 // * We initialize the watcher watching "dir". | |
| 62 // | |
| 63 // * Due to issue 14373, the watcher can receive native events describing | |
| 64 // the creation of "dir/sub" and its contents despite the fact that they | |
| 65 // occurred before the watcher was started. | |
| 66 // | |
| 67 // * Usually the above events will occur while the watcher is doing its | |
| 68 // initial scan of "dir/sub" and be ignored, but occasionally they will | |
| 69 // occur afterwards. | |
| 70 // | |
| 71 // * When processing the bogus CREATE events, the watcher has to assume that | |
| 72 // they could mean something other than CREATE (issue 14793). Thus it | |
| 73 // assumes that the files or directories in question could have changed | |
| 74 // and emits CHANGE events or additional REMOVE/CREATE pairs for them. | |
| 75 schedule(() => new Future.delayed(new Duration(seconds: 2))); | |
| 76 | |
| 77 startWatcher(dir: "dir"); | 55 startWatcher(dir: "dir"); |
| 78 | 56 |
| 79 renameDir("dir/sub", "sub"); | 57 renameDir("dir/sub", "sub"); |
| 80 renameDir("sub", "dir/sub"); | 58 renameDir("sub", "dir/sub"); |
| 81 | 59 |
| 82 inAnyOrder(() { | 60 inAnyOrder(() { |
| 83 withPermutations((i, j, k) => | 61 withPermutations((i, j, k) => |
| 84 expectRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); | 62 expectRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
| 85 }); | 63 }); |
| 86 | 64 |
| 87 inAnyOrder(() { | 65 inAnyOrder(() { |
| 88 withPermutations((i, j, k) => | 66 withPermutations((i, j, k) => |
| 89 expectAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); | 67 expectAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
| 90 }); | 68 }); |
| 91 }); | 69 }); |
| 92 } | 70 } |
| OLD | NEW |