pkg/watcher: prepare for 0.9.3 added changelog updated pubspec code formatting removed unused imports R=ajohnsen@google.com Review URL: https://codereview.chromium.org//441483004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/watcher@38862 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/watcher/CHANGELOG.md b/pkgs/watcher/CHANGELOG.md new file mode 100644 index 0000000..eb544f6 --- /dev/null +++ b/pkgs/watcher/CHANGELOG.md
@@ -0,0 +1,7 @@ +# 0.9.3 + +* Improved support for Windows via `WindowsDirectoryWatcher`. + +* Simplified `PollingDirectoryWatcher`. + +* Fixed bugs in `MacOSDirectoryWatcher`
diff --git a/pkgs/watcher/example/watch.dart b/pkgs/watcher/example/watch.dart index aba127d..da3c263 100644 --- a/pkgs/watcher/example/watch.dart +++ b/pkgs/watcher/example/watch.dart
@@ -5,8 +5,6 @@ /// Watches the given directory and prints each modification to it. library watch; -import 'dart:io'; - import 'package:path/path.dart' as p; import 'package:watcher/watcher.dart';
diff --git a/pkgs/watcher/lib/src/async_queue.dart b/pkgs/watcher/lib/src/async_queue.dart index 8ac0cdf..b83493d 100644 --- a/pkgs/watcher/lib/src/async_queue.dart +++ b/pkgs/watcher/lib/src/async_queue.dart
@@ -70,4 +70,4 @@ _isProcessing = false; }); } -} \ No newline at end of file +}
diff --git a/pkgs/watcher/lib/src/constructable_file_system_event.dart b/pkgs/watcher/lib/src/constructable_file_system_event.dart index 010d297..d00a1dc 100644 --- a/pkgs/watcher/lib/src/constructable_file_system_event.dart +++ b/pkgs/watcher/lib/src/constructable_file_system_event.dart
@@ -40,11 +40,11 @@ final type = FileSystemEvent.MODIFY; ConstructableFileSystemModifyEvent(String path, bool isDirectory, - this.contentChanged) + this.contentChanged) : super(path, isDirectory); String toString() => - "FileSystemModifyEvent('$path', contentChanged=$contentChanged)"; + "FileSystemModifyEvent('$path', contentChanged=$contentChanged)"; } class ConstructableFileSystemMoveEvent extends _ConstructableFileSystemEvent @@ -53,7 +53,7 @@ final type = FileSystemEvent.MOVE; ConstructableFileSystemMoveEvent(String path, bool isDirectory, - this.destination) + this.destination) : super(path, isDirectory); String toString() => "FileSystemMoveEvent('$path', '$destination')";
diff --git a/pkgs/watcher/lib/src/utils.dart b/pkgs/watcher/lib/src/utils.dart index 163e9f4..007c84c 100644 --- a/pkgs/watcher/lib/src/utils.dart +++ b/pkgs/watcher/lib/src/utils.dart
@@ -20,7 +20,7 @@ /// Returns the union of all elements in each set in [sets]. Set unionAll(Iterable<Set> sets) => - sets.fold(new Set(), (union, set) => union.union(set)); + sets.fold(new Set(), (union, set) => union.union(set)); /// Returns a buffered stream that will emit the same values as the stream /// returned by [future] once [future] completes. @@ -76,7 +76,7 @@ /// Returns a [Future] that completes after pumping the event queue [times] /// times. By default, this should pump the event queue enough times to allow /// any code to run, as long as it's not waiting on some external event. -Future pumpEventQueue([int times=20]) { +Future pumpEventQueue([int times = 20]) { if (times == 0) return new Future.value(); // We use a delayed future to allow microtask events to finish. The // Future.value or Future() constructors use scheduleMicrotask themselves and
diff --git a/pkgs/watcher/lib/src/watch_event.dart b/pkgs/watcher/lib/src/watch_event.dart index d998a25..be6d70c 100644 --- a/pkgs/watcher/lib/src/watch_event.dart +++ b/pkgs/watcher/lib/src/watch_event.dart
@@ -32,4 +32,4 @@ const ChangeType(this._name); String toString() => _name; -} \ No newline at end of file +}
diff --git a/pkgs/watcher/pubspec.yaml b/pkgs/watcher/pubspec.yaml index 51ba562..d517e8f 100644 --- a/pkgs/watcher/pubspec.yaml +++ b/pkgs/watcher/pubspec.yaml
@@ -1,15 +1,15 @@ name: watcher version: 0.9.3-dev -author: "Dart Team <misc@dartlang.org>" +author: Dart Team <misc@dartlang.org> homepage: http://www.dartlang.org description: > A file watcher. It monitors for changes to contents of directories and notifies you when files have been added, removed, or modified. -dependencies: - path: ">=0.9.0 <2.0.0" - stack_trace: ">=0.9.1 <2.0.0" -dev_dependencies: - scheduled_test: ">=0.9.3-dev <0.11.0" - unittest: ">=0.9.2 <0.10.0" environment: - sdk: ">=0.8.10+6 <2.0.0" + sdk: '>=1.0.0 <2.0.0' +dependencies: + path: '>=0.9.0 <2.0.0' + stack_trace: '>=0.9.1 <2.0.0' +dev_dependencies: + scheduled_test: '>=0.9.3 <0.12.0' + unittest: '>=0.9.2 <0.12.0'
diff --git a/pkgs/watcher/test/directory_watcher/linux_test.dart b/pkgs/watcher/test/directory_watcher/linux_test.dart index cae38ad..c17eb53 100644 --- a/pkgs/watcher/test/directory_watcher/linux_test.dart +++ b/pkgs/watcher/test/directory_watcher/linux_test.dart
@@ -9,7 +9,7 @@ import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); watcherFactory = (dir) => new LinuxDirectoryWatcher(dir);
diff --git a/pkgs/watcher/test/directory_watcher/mac_os_test.dart b/pkgs/watcher/test/directory_watcher/mac_os_test.dart index 1e9bd7d..bbf966a 100644 --- a/pkgs/watcher/test/directory_watcher/mac_os_test.dart +++ b/pkgs/watcher/test/directory_watcher/mac_os_test.dart
@@ -9,7 +9,7 @@ import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); MacOSDirectoryWatcher.logDebugInfo = true;
diff --git a/pkgs/watcher/test/directory_watcher/polling_test.dart b/pkgs/watcher/test/directory_watcher/polling_test.dart index da29207..1ef49b5 100644 --- a/pkgs/watcher/test/directory_watcher/polling_test.dart +++ b/pkgs/watcher/test/directory_watcher/polling_test.dart
@@ -8,7 +8,7 @@ import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); // Use a short delay to make the tests run quickly.
diff --git a/pkgs/watcher/test/directory_watcher/shared.dart b/pkgs/watcher/test/directory_watcher/shared.dart index d3575ea..8632401 100644 --- a/pkgs/watcher/test/directory_watcher/shared.dart +++ b/pkgs/watcher/test/directory_watcher/shared.dart
@@ -7,7 +7,7 @@ import '../utils.dart'; -sharedTests() { +void sharedTests() { test('does not notify for files that already exist when started', () { // Make some pre-existing files. writeFile("a.txt");
diff --git a/pkgs/watcher/test/directory_watcher/windows_test.dart b/pkgs/watcher/test/directory_watcher/windows_test.dart index 6bfb88b..ea5c8c5 100644 --- a/pkgs/watcher/test/directory_watcher/windows_test.dart +++ b/pkgs/watcher/test/directory_watcher/windows_test.dart
@@ -2,7 +2,6 @@ // 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 'package:path/path.dart' as p; import 'package:scheduled_test/scheduled_test.dart'; import 'package:watcher/src/directory_watcher/windows.dart'; import 'package:watcher/watcher.dart'; @@ -10,7 +9,7 @@ import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); watcherFactory = (dir) => new WindowsDirectoryWatcher(dir); @@ -24,4 +23,3 @@ new isInstanceOf<WindowsDirectoryWatcher>()); }); } -
diff --git a/pkgs/watcher/test/no_subscription/linux_test.dart b/pkgs/watcher/test/no_subscription/linux_test.dart index 7978830..f7f1b49 100644 --- a/pkgs/watcher/test/no_subscription/linux_test.dart +++ b/pkgs/watcher/test/no_subscription/linux_test.dart
@@ -4,12 +4,11 @@ import 'package:scheduled_test/scheduled_test.dart'; import 'package:watcher/src/directory_watcher/linux.dart'; -import 'package:watcher/watcher.dart'; import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); watcherFactory = (dir) => new LinuxDirectoryWatcher(dir); @@ -17,4 +16,4 @@ setUp(createSandbox); sharedTests(); -} \ No newline at end of file +}
diff --git a/pkgs/watcher/test/no_subscription/mac_os_test.dart b/pkgs/watcher/test/no_subscription/mac_os_test.dart index e0275c4..721d3e7 100644 --- a/pkgs/watcher/test/no_subscription/mac_os_test.dart +++ b/pkgs/watcher/test/no_subscription/mac_os_test.dart
@@ -4,12 +4,11 @@ import 'package:scheduled_test/scheduled_test.dart'; import 'package:watcher/src/directory_watcher/mac_os.dart'; -import 'package:watcher/watcher.dart'; import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); watcherFactory = (dir) => new MacOSDirectoryWatcher(dir); @@ -17,4 +16,4 @@ setUp(createSandbox); sharedTests(); -} \ No newline at end of file +}
diff --git a/pkgs/watcher/test/no_subscription/polling_test.dart b/pkgs/watcher/test/no_subscription/polling_test.dart index fa4f0cb..c71b5ce 100644 --- a/pkgs/watcher/test/no_subscription/polling_test.dart +++ b/pkgs/watcher/test/no_subscription/polling_test.dart
@@ -8,7 +8,7 @@ import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); watcherFactory = (dir) => new PollingDirectoryWatcher(dir); @@ -16,4 +16,4 @@ setUp(createSandbox); sharedTests(); -} \ No newline at end of file +}
diff --git a/pkgs/watcher/test/no_subscription/shared.dart b/pkgs/watcher/test/no_subscription/shared.dart index 99172a2..9ba5c98 100644 --- a/pkgs/watcher/test/no_subscription/shared.dart +++ b/pkgs/watcher/test/no_subscription/shared.dart
@@ -3,14 +3,13 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; -import 'dart:io'; import 'package:scheduled_test/scheduled_test.dart'; import 'package:watcher/watcher.dart'; import '../utils.dart'; -sharedTests() { +void sharedTests() { test('does not notify for changes when there are no subscribers', () { // Note that this test doesn't rely as heavily on the test functions in // utils.dart because it needs to be very explicit about when the event
diff --git a/pkgs/watcher/test/ready/linux_test.dart b/pkgs/watcher/test/ready/linux_test.dart index 7978830..f7f1b49 100644 --- a/pkgs/watcher/test/ready/linux_test.dart +++ b/pkgs/watcher/test/ready/linux_test.dart
@@ -4,12 +4,11 @@ import 'package:scheduled_test/scheduled_test.dart'; import 'package:watcher/src/directory_watcher/linux.dart'; -import 'package:watcher/watcher.dart'; import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); watcherFactory = (dir) => new LinuxDirectoryWatcher(dir); @@ -17,4 +16,4 @@ setUp(createSandbox); sharedTests(); -} \ No newline at end of file +}
diff --git a/pkgs/watcher/test/ready/mac_os_test.dart b/pkgs/watcher/test/ready/mac_os_test.dart index e0275c4..721d3e7 100644 --- a/pkgs/watcher/test/ready/mac_os_test.dart +++ b/pkgs/watcher/test/ready/mac_os_test.dart
@@ -4,12 +4,11 @@ import 'package:scheduled_test/scheduled_test.dart'; import 'package:watcher/src/directory_watcher/mac_os.dart'; -import 'package:watcher/watcher.dart'; import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); watcherFactory = (dir) => new MacOSDirectoryWatcher(dir); @@ -17,4 +16,4 @@ setUp(createSandbox); sharedTests(); -} \ No newline at end of file +}
diff --git a/pkgs/watcher/test/ready/polling_test.dart b/pkgs/watcher/test/ready/polling_test.dart index fa4f0cb..c71b5ce 100644 --- a/pkgs/watcher/test/ready/polling_test.dart +++ b/pkgs/watcher/test/ready/polling_test.dart
@@ -8,7 +8,7 @@ import 'shared.dart'; import '../utils.dart'; -main() { +void main() { initConfig(); watcherFactory = (dir) => new PollingDirectoryWatcher(dir); @@ -16,4 +16,4 @@ setUp(createSandbox); sharedTests(); -} \ No newline at end of file +}
diff --git a/pkgs/watcher/test/ready/shared.dart b/pkgs/watcher/test/ready/shared.dart index af1b58f..7be4833 100644 --- a/pkgs/watcher/test/ready/shared.dart +++ b/pkgs/watcher/test/ready/shared.dart
@@ -6,7 +6,7 @@ import '../utils.dart'; -sharedTests() { +void sharedTests() { test('ready does not complete until after subscription', () { var watcher = createWatcher(waitForReady: false);
diff --git a/pkgs/watcher/test/utils.dart b/pkgs/watcher/test/utils.dart index 8b660e8..6758dae 100644 --- a/pkgs/watcher/test/utils.dart +++ b/pkgs/watcher/test/utils.dart
@@ -4,7 +4,6 @@ library watcher.test.utils; -import 'dart:async'; import 'dart:io'; import 'package:path/path.dart' as p; @@ -250,16 +249,16 @@ /// Expects that the next event emitted will be for an add event for [path]. void expectAddEvent(String path) => - _expectOrCollect(isWatchEvent(ChangeType.ADD, path)); + _expectOrCollect(isWatchEvent(ChangeType.ADD, path)); /// Expects that the next event emitted will be for a modification event for /// [path]. void expectModifyEvent(String path) => - _expectOrCollect(isWatchEvent(ChangeType.MODIFY, path)); + _expectOrCollect(isWatchEvent(ChangeType.MODIFY, path)); /// Expects that the next event emitted will be for a removal event for [path]. void expectRemoveEvent(String path) => - _expectOrCollect(isWatchEvent(ChangeType.REMOVE, path)); + _expectOrCollect(isWatchEvent(ChangeType.REMOVE, path)); /// Consumes an add event for [path] if one is emitted at this point in the /// schedule, but doesn't throw an error if it isn't. @@ -267,7 +266,7 @@ /// If this is used at the end of a test, [startClosingEventStream] should be /// called before it. void allowAddEvent(String path) => - _expectOrCollect(allow(isWatchEvent(ChangeType.ADD, path))); + _expectOrCollect(allow(isWatchEvent(ChangeType.ADD, path))); /// Consumes a modification event for [path] if one is emitted at this point in /// the schedule, but doesn't throw an error if it isn't. @@ -275,7 +274,7 @@ /// If this is used at the end of a test, [startClosingEventStream] should be /// called before it. void allowModifyEvent(String path) => - _expectOrCollect(allow(isWatchEvent(ChangeType.MODIFY, path))); + _expectOrCollect(allow(isWatchEvent(ChangeType.MODIFY, path))); /// Consumes a removal event for [path] if one is emitted at this point in the /// schedule, but doesn't throw an error if it isn't. @@ -283,7 +282,7 @@ /// If this is used at the end of a test, [startClosingEventStream] should be /// called before it. void allowRemoveEvent(String path) => - _expectOrCollect(allow(isWatchEvent(ChangeType.REMOVE, path))); + _expectOrCollect(allow(isWatchEvent(ChangeType.REMOVE, path))); /// Schedules writing a file in the sandbox at [path] with [contents]. ///