dartfmt
diff --git a/pkgs/watcher/lib/src/async_queue.dart b/pkgs/watcher/lib/src/async_queue.dart
index adf6671..1895c80 100644
--- a/pkgs/watcher/lib/src/async_queue.dart
+++ b/pkgs/watcher/lib/src/async_queue.dart
@@ -34,8 +34,7 @@
/// Used to avoid top-leveling asynchronous errors.
final Function _errorHandler;
- AsyncQueue(this._processor, {Function onError})
- : _errorHandler = onError;
+ AsyncQueue(this._processor, {Function onError}) : _errorHandler = onError;
/// Enqueues [item] to be processed and starts asynchronously processing it
/// if a process isn't already running.
diff --git a/pkgs/watcher/lib/src/constructable_file_system_event.dart b/pkgs/watcher/lib/src/constructable_file_system_event.dart
index 63b51c1..a0f153e 100644
--- a/pkgs/watcher/lib/src/constructable_file_system_event.dart
+++ b/pkgs/watcher/lib/src/constructable_file_system_event.dart
@@ -37,8 +37,8 @@
final bool contentChanged;
final type = FileSystemEvent.MODIFY;
- ConstructableFileSystemModifyEvent(String path, bool isDirectory,
- this.contentChanged)
+ ConstructableFileSystemModifyEvent(
+ String path, bool isDirectory, this.contentChanged)
: super(path, isDirectory);
String toString() =>
@@ -50,8 +50,8 @@
final String destination;
final type = FileSystemEvent.MOVE;
- ConstructableFileSystemMoveEvent(String path, bool isDirectory,
- this.destination)
+ ConstructableFileSystemMoveEvent(
+ String path, bool isDirectory, this.destination)
: super(path, isDirectory);
String toString() => "FileSystemMoveEvent('$path', '$destination')";
diff --git a/pkgs/watcher/lib/src/directory_watcher/linux.dart b/pkgs/watcher/lib/src/directory_watcher/linux.dart
index c291aad..717e420 100644
--- a/pkgs/watcher/lib/src/directory_watcher/linux.dart
+++ b/pkgs/watcher/lib/src/directory_watcher/linux.dart
@@ -62,10 +62,10 @@
/// watcher is closed.
final _subscriptions = new Set<StreamSubscription>();
- _LinuxDirectoryWatcher(String path)
- : _files = new PathSet(path) {
- _nativeEvents.add(new Directory(path).watch().transform(
- new StreamTransformer.fromHandlers(handleDone: (sink) {
+ _LinuxDirectoryWatcher(String path) : _files = new PathSet(path) {
+ _nativeEvents.add(new Directory(path)
+ .watch()
+ .transform(new StreamTransformer.fromHandlers(handleDone: (sink) {
// Handle the done event here rather than in the call to [_listen] because
// [innerStream] won't close until we close the [StreamGroup]. However, if
// we close the [StreamGroup] here, we run the risk of new-directory
@@ -251,8 +251,8 @@
/// Like [Stream.listen], but automatically adds the subscription to
/// [_subscriptions] so that it can be canceled when [close] is called.
- void _listen(Stream stream, void onData(event), {Function onError,
- void onDone(), bool cancelOnError}) {
+ void _listen(Stream stream, void onData(event),
+ {Function onError, void onDone(), bool cancelOnError}) {
var subscription;
subscription = stream.listen(onData, onError: onError, onDone: () {
_subscriptions.remove(subscription);
diff --git a/pkgs/watcher/lib/src/directory_watcher/mac_os.dart b/pkgs/watcher/lib/src/directory_watcher/mac_os.dart
index 8a17e2e..759765f 100644
--- a/pkgs/watcher/lib/src/directory_watcher/mac_os.dart
+++ b/pkgs/watcher/lib/src/directory_watcher/mac_os.dart
@@ -81,10 +81,8 @@
//
// If we do receive a batch of events, [_onBatch] will ensure that these
// futures don't fire and that the directory is re-listed.
- Future.wait([
- _listDir(),
- _waitForBogusEvents()
- ]).then((_) => _readyCompleter.complete());
+ Future.wait([_listDir(), _waitForBogusEvents()]).then(
+ (_) => _readyCompleter.complete());
}
void close() {
@@ -116,8 +114,9 @@
_sortEvents(batch).forEach((path, eventSet) {
var canonicalEvent = _canonicalEvent(eventSet);
- var events = canonicalEvent == null ?
- _eventsBasedOnFileSystem(path) : [canonicalEvent];
+ var events = canonicalEvent == null
+ ? _eventsBasedOnFileSystem(path)
+ : [canonicalEvent];
for (var event in events) {
if (event is FileSystemCreateEvent) {
@@ -126,9 +125,8 @@
// This can happen if a file is copied on top of an existing one.
// We'll see an ADD event for the latter file when from the user's
// perspective, the file's contents just changed.
- var type = _files.contains(path)
- ? ChangeType.MODIFY
- : ChangeType.ADD;
+ var type =
+ _files.contains(path) ? ChangeType.MODIFY : ChangeType.ADD;
_emitEvent(type, path);
_files.add(path);
@@ -138,8 +136,8 @@
if (_files.containsDir(path)) continue;
StreamSubscription<FileSystemEntity> subscription;
- subscription = new Directory(path).list(recursive: true)
- .listen((entity) {
+ subscription =
+ new Directory(path).list(recursive: true).listen((entity) {
if (entity is Directory) return;
if (_files.contains(path)) return;
@@ -259,7 +257,8 @@
// from FSEvents reporting an add that happened prior to the watch
// beginning. If we also received a MODIFY event, we want to report that,
// but not the CREATE.
- if (type == FileSystemEvent.CREATE && hadModifyEvent &&
+ if (type == FileSystemEvent.CREATE &&
+ hadModifyEvent &&
_files.contains(batch.first.path)) {
type = FileSystemEvent.MODIFY;
}
@@ -277,7 +276,8 @@
case FileSystemEvent.MODIFY:
return new ConstructableFileSystemModifyEvent(
batch.first.path, isDir, false);
- default: throw 'unreachable';
+ default:
+ throw 'unreachable';
}
}
@@ -347,11 +347,11 @@
/// Start or restart the underlying [Directory.watch] stream.
void _startWatch() {
// Batch the FSEvent changes together so that we can dedup events.
- var innerStream = new Directory(path).watch(recursive: true)
+ var innerStream = new Directory(path)
+ .watch(recursive: true)
.transform(new BatchedStreamTransformer<FileSystemEvent>());
_watchSubscription = innerStream.listen(_onBatch,
- onError: _eventsController.addError,
- onDone: _onDone);
+ onError: _eventsController.addError, onDone: _onDone);
}
/// Starts or restarts listing the watched directory to get an initial picture
@@ -365,10 +365,7 @@
var stream = new Directory(path).list(recursive: true);
_initialListSubscription = stream.listen((entity) {
if (entity is! Directory) _files.add(entity.path);
- },
- onError: _emitError,
- onDone: completer.complete,
- cancelOnError: true);
+ }, onError: _emitError, onDone: completer.complete, cancelOnError: true);
return completer.future;
}
@@ -379,9 +376,8 @@
/// bogus events will be signaled in that time frame.
Future _waitForBogusEvents() {
var completer = new Completer();
- _bogusEventTimer = new Timer(
- new Duration(milliseconds: 200),
- completer.complete);
+ _bogusEventTimer =
+ new Timer(new Duration(milliseconds: 200), completer.complete);
return completer.future;
}
diff --git a/pkgs/watcher/lib/src/directory_watcher/polling.dart b/pkgs/watcher/lib/src/directory_watcher/polling.dart
index ebc1709..fa72a2f 100644
--- a/pkgs/watcher/lib/src/directory_watcher/polling.dart
+++ b/pkgs/watcher/lib/src/directory_watcher/polling.dart
@@ -25,9 +25,9 @@
/// and higher CPU usage. Defaults to one second.
PollingDirectoryWatcher(String directory, {Duration pollingDelay})
: super(directory, () {
- return new _PollingDirectoryWatcher(directory,
- pollingDelay != null ? pollingDelay : new Duration(seconds: 1));
- });
+ return new _PollingDirectoryWatcher(directory,
+ pollingDelay != null ? pollingDelay : new Duration(seconds: 1));
+ });
}
class _PollingDirectoryWatcher
@@ -73,8 +73,8 @@
final _polledFiles = new Set<String>();
_PollingDirectoryWatcher(this.path, this._pollingDelay) {
- _filesToProcess = new AsyncQueue<String>(_processFile,
- onError: (e, stackTrace) {
+ _filesToProcess =
+ new AsyncQueue<String>(_processFile, onError: (e, stackTrace) {
if (!_events.isClosed) _events.addError(e, stackTrace);
});
diff --git a/pkgs/watcher/lib/src/directory_watcher/windows.dart b/pkgs/watcher/lib/src/directory_watcher/windows.dart
index ec119f7..3352b68 100644
--- a/pkgs/watcher/lib/src/directory_watcher/windows.dart
+++ b/pkgs/watcher/lib/src/directory_watcher/windows.dart
@@ -80,8 +80,8 @@
/// The subscriptions to the [Directory.list] calls for listing the contents
/// of subdirectories that were moved into the watched directory.
- final Set<StreamSubscription<FileSystemEntity>> _listSubscriptions
- = new HashSet<StreamSubscription<FileSystemEntity>>();
+ final Set<StreamSubscription<FileSystemEntity>> _listSubscriptions =
+ new HashSet<StreamSubscription<FileSystemEntity>>();
_WindowsDirectoryWatcher(String path)
: path = path,
@@ -132,8 +132,7 @@
// the directory is now gone.
if (event is FileSystemMoveEvent ||
event is FileSystemDeleteEvent ||
- (FileSystemEntity.typeSync(path) ==
- FileSystemEntityType.NOT_FOUND)) {
+ (FileSystemEntity.typeSync(path) == FileSystemEntityType.NOT_FOUND)) {
for (var path in _files.paths) {
_emitEvent(ChangeType.REMOVE, path);
}
@@ -151,8 +150,8 @@
void _onEvent(FileSystemEvent event) {
assert(isReady);
- final batcher = _eventBatchers.putIfAbsent(
- event.path, () => new _EventBatcher());
+ final batcher =
+ _eventBatchers.putIfAbsent(event.path, () => new _EventBatcher());
batcher.addEvent(event, () {
_eventBatchers.remove(event.path);
_onBatch(batcher.events);
@@ -162,10 +161,10 @@
/// The callback that's run when [Directory.watch] emits a batch of events.
void _onBatch(List<FileSystemEvent> batch) {
_sortEvents(batch).forEach((path, eventSet) {
-
var canonicalEvent = _canonicalEvent(eventSet);
- var events = canonicalEvent == null ?
- _eventsBasedOnFileSystem(path) : [canonicalEvent];
+ var events = canonicalEvent == null
+ ? _eventsBasedOnFileSystem(path)
+ : [canonicalEvent];
for (var event in events) {
if (event is FileSystemCreateEvent) {
@@ -278,8 +277,8 @@
// (respectively) that will be contradictory.
if (event is FileSystemModifyEvent) continue;
assert(event is FileSystemCreateEvent ||
- event is FileSystemDeleteEvent ||
- event is FileSystemMoveEvent);
+ event is FileSystemDeleteEvent ||
+ event is FileSystemMoveEvent);
// If we previously thought this was a MODIFY, we now consider it to be a
// CREATE or REMOVE event. This is safe for the same reason as above.
@@ -290,8 +289,8 @@
// A CREATE event contradicts a REMOVE event and vice versa.
assert(type == FileSystemEvent.CREATE ||
- type == FileSystemEvent.DELETE ||
- type == FileSystemEvent.MOVE);
+ type == FileSystemEvent.DELETE ||
+ type == FileSystemEvent.MOVE);
if (type != event.type) return null;
}
@@ -305,7 +304,8 @@
batch.first.path, isDir, false);
case FileSystemEvent.MOVE:
return null;
- default: throw 'unreachable';
+ default:
+ throw 'unreachable';
}
}
@@ -369,8 +369,7 @@
// Batch the events together so that we can dedup events.
var innerStream = new Directory(path).watch(recursive: true);
_watchSubscription = innerStream.listen(_onEvent,
- onError: _eventsController.addError,
- onDone: _onDone);
+ onError: _eventsController.addError, onDone: _onDone);
}
/// Starts or restarts listing the watched directory to get an initial picture
@@ -385,11 +384,9 @@
void handleEntity(entity) {
if (entity is! Directory) _files.add(entity.path);
}
- _initialListSubscription = stream.listen(
- handleEntity,
- onError: _emitError,
- onDone: completer.complete,
- cancelOnError: true);
+
+ _initialListSubscription = stream.listen(handleEntity,
+ onError: _emitError, onDone: completer.complete, cancelOnError: true);
return completer.future;
}
diff --git a/pkgs/watcher/lib/src/file_watcher/native.dart b/pkgs/watcher/lib/src/file_watcher/native.dart
index f413a72..8e7dd09 100644
--- a/pkgs/watcher/lib/src/file_watcher/native.dart
+++ b/pkgs/watcher/lib/src/file_watcher/native.dart
@@ -42,7 +42,8 @@
void _listen() {
// Batch the events together so that we can dedup them.
- _subscription = new File(path).watch()
+ _subscription = new File(path)
+ .watch()
.transform(new BatchedStreamTransformer<FileSystemEvent>())
.listen(_onBatch, onError: _eventsController.addError, onDone: _onDone);
}
diff --git a/pkgs/watcher/lib/src/file_watcher/polling.dart b/pkgs/watcher/lib/src/file_watcher/polling.dart
index 3f2e9f1..97a4f95 100644
--- a/pkgs/watcher/lib/src/file_watcher/polling.dart
+++ b/pkgs/watcher/lib/src/file_watcher/polling.dart
@@ -14,9 +14,9 @@
class PollingFileWatcher extends ResubscribableWatcher implements FileWatcher {
PollingFileWatcher(String path, {Duration pollingDelay})
: super(path, () {
- return new _PollingFileWatcher(path,
- pollingDelay != null ? pollingDelay : new Duration(seconds: 1));
- });
+ return new _PollingFileWatcher(path,
+ pollingDelay != null ? pollingDelay : new Duration(seconds: 1));
+ });
}
class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher {
diff --git a/pkgs/watcher/lib/src/resubscribable.dart b/pkgs/watcher/lib/src/resubscribable.dart
index aeefe93..28c425f 100644
--- a/pkgs/watcher/lib/src/resubscribable.dart
+++ b/pkgs/watcher/lib/src/resubscribable.dart
@@ -44,22 +44,24 @@
_eventsController = new StreamController<WatchEvent>.broadcast(
onListen: () {
- watcher = _factory();
- subscription = watcher.events.listen(_eventsController.add,
- onError: _eventsController.addError,
- onDone: _eventsController.close);
+ watcher = _factory();
+ subscription = watcher.events.listen(_eventsController.add,
+ onError: _eventsController.addError,
+ onDone: _eventsController.close);
- // It's important that we complete the value of [_readyCompleter] at the
- // time [onListen] is called, as opposed to the value when [watcher.ready]
- // fires. A new completer may be created by that time.
- watcher.ready.then(_readyCompleter.complete);
- }, onCancel: () {
- // Cancel the subscription before closing the watcher so that the
- // watcher's `onDone` event doesn't close [events].
- subscription.cancel();
- watcher.close();
- _readyCompleter = new Completer();
- }, sync: true);
+ // It's important that we complete the value of [_readyCompleter] at the
+ // time [onListen] is called, as opposed to the value when [watcher.ready]
+ // fires. A new completer may be created by that time.
+ watcher.ready.then(_readyCompleter.complete);
+ },
+ onCancel: () {
+ // Cancel the subscription before closing the watcher so that the
+ // watcher's `onDone` event doesn't close [events].
+ subscription.cancel();
+ watcher.close();
+ _readyCompleter = new Completer();
+ },
+ sync: true);
}
}
diff --git a/pkgs/watcher/lib/src/utils.dart b/pkgs/watcher/lib/src/utils.dart
index 022c8c1..ef39eef 100644
--- a/pkgs/watcher/lib/src/utils.dart
+++ b/pkgs/watcher/lib/src/utils.dart
@@ -31,8 +31,7 @@
/// If [broadcast] is true, a broadcast stream is returned. This assumes that
/// the stream returned by [future] will be a broadcast stream as well.
/// [broadcast] defaults to false.
-Stream<T> futureStream<T>(Future<Stream<T>> future,
- {bool broadcast: false}) {
+Stream<T> futureStream<T>(Future<Stream<T>> future, {bool broadcast: false}) {
var subscription;
StreamController<T> controller;
@@ -47,10 +46,8 @@
onListen() {
future.then((stream) {
if (controller == null) return;
- subscription = stream.listen(
- controller.add,
- onError: controller.addError,
- onDone: controller.close);
+ subscription = stream.listen(controller.add,
+ onError: controller.addError, onDone: controller.close);
});
}
diff --git a/pkgs/watcher/test/directory_watcher/linux_test.dart b/pkgs/watcher/test/directory_watcher/linux_test.dart
index 897b130..34e6896 100644
--- a/pkgs/watcher/test/directory_watcher/linux_test.dart
+++ b/pkgs/watcher/test/directory_watcher/linux_test.dart
@@ -19,28 +19,28 @@
sharedTests();
test('DirectoryWatcher creates a LinuxDirectoryWatcher on Linux', () {
- expect(new DirectoryWatcher('.'),
- new isInstanceOf<LinuxDirectoryWatcher>());
+ expect(
+ new DirectoryWatcher('.'), new isInstanceOf<LinuxDirectoryWatcher>());
});
test('emits events for many nested files moved out then immediately back in',
() {
- withPermutations((i, j, k) =>
- writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt"));
+ withPermutations(
+ (i, j, k) => writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt"));
startWatcher(path: "dir");
renameDir("dir/sub", "sub");
renameDir("sub", "dir/sub");
allowEither(() {
- inAnyOrder(withPermutations((i, j, k) =>
- isRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
+ inAnyOrder(withPermutations(
+ (i, j, k) => isRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
- inAnyOrder(withPermutations((i, j, k) =>
- isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
+ inAnyOrder(withPermutations(
+ (i, j, k) => isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
}, () {
- inAnyOrder(withPermutations((i, j, k) =>
- isModifyEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
+ inAnyOrder(withPermutations(
+ (i, j, k) => isModifyEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
});
});
}
diff --git a/pkgs/watcher/test/directory_watcher/mac_os_test.dart b/pkgs/watcher/test/directory_watcher/mac_os_test.dart
index 2c82f34..46b7ca2 100644
--- a/pkgs/watcher/test/directory_watcher/mac_os_test.dart
+++ b/pkgs/watcher/test/directory_watcher/mac_os_test.dart
@@ -19,11 +19,12 @@
sharedTests();
test('DirectoryWatcher creates a MacOSDirectoryWatcher on Mac OS', () {
- expect(new DirectoryWatcher('.'),
- new isInstanceOf<MacOSDirectoryWatcher>());
+ expect(
+ new DirectoryWatcher('.'), new isInstanceOf<MacOSDirectoryWatcher>());
});
- test('does not notify about the watched directory being deleted and '
+ test(
+ 'does not notify about the watched directory being deleted and '
'recreated immediately before watching', () {
createDir("dir");
writeFile("dir/old.txt");
@@ -37,8 +38,8 @@
test('emits events for many nested files moved out then immediately back in',
() {
- withPermutations((i, j, k) =>
- writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt"));
+ withPermutations(
+ (i, j, k) => writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt"));
startWatcher(path: "dir");
@@ -46,14 +47,14 @@
renameDir("sub", "dir/sub");
allowEither(() {
- inAnyOrder(withPermutations((i, j, k) =>
- isRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
+ inAnyOrder(withPermutations(
+ (i, j, k) => isRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
- inAnyOrder(withPermutations((i, j, k) =>
- isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
+ inAnyOrder(withPermutations(
+ (i, j, k) => isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
}, () {
- inAnyOrder(withPermutations((i, j, k) =>
- isModifyEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
+ inAnyOrder(withPermutations(
+ (i, j, k) => isModifyEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
});
});
}
diff --git a/pkgs/watcher/test/directory_watcher/shared.dart b/pkgs/watcher/test/directory_watcher/shared.dart
index 148eee2..2bdc077 100644
--- a/pkgs/watcher/test/directory_watcher/shared.dart
+++ b/pkgs/watcher/test/directory_watcher/shared.dart
@@ -59,10 +59,7 @@
writeFile("a.txt", contents: "same");
writeFile("b.txt", contents: "after");
- inAnyOrder([
- isModifyEvent("a.txt"),
- isModifyEvent("b.txt")
- ]);
+ inAnyOrder([isModifyEvent("a.txt"), isModifyEvent("b.txt")]);
});
test('when the watched directory is deleted, removes all files', () {
@@ -72,10 +69,7 @@
startWatcher(path: "dir");
deleteDir("dir");
- inAnyOrder([
- isRemoveEvent("dir/a.txt"),
- isRemoveEvent("dir/b.txt")
- ]);
+ inAnyOrder([isRemoveEvent("dir/a.txt"), isRemoveEvent("dir/b.txt")]);
});
test('when the watched directory is moved, removes all files', () {
@@ -86,14 +80,12 @@
renameDir("dir", "moved_dir");
createDir("dir");
- inAnyOrder([
- isRemoveEvent("dir/a.txt"),
- isRemoveEvent("dir/b.txt")
- ]);
+ inAnyOrder([isRemoveEvent("dir/a.txt"), isRemoveEvent("dir/b.txt")]);
});
// Regression test for b/30768513.
- test("doesn't crash when the directory is moved immediately after a subdir "
+ test(
+ "doesn't crash when the directory is moved immediately after a subdir "
"is added", () {
writeFile("dir/a.txt");
writeFile("dir/b.txt");
@@ -103,10 +95,7 @@
createDir("dir/subdir");
renameDir("dir", "moved_dir");
createDir("dir");
- inAnyOrder([
- isRemoveEvent("dir/a.txt"),
- isRemoveEvent("dir/b.txt")
- ]);
+ inAnyOrder([isRemoveEvent("dir/a.txt"), isRemoveEvent("dir/b.txt")]);
});
group("moves", () {
@@ -115,10 +104,7 @@
startWatcher();
renameFile("old.txt", "new.txt");
- inAnyOrder([
- isAddEvent("new.txt"),
- isRemoveEvent("old.txt")
- ]);
+ inAnyOrder([isAddEvent("new.txt"), isRemoveEvent("old.txt")]);
});
test('notifies when a file is moved from outside the watched directory',
@@ -145,10 +131,7 @@
startWatcher();
renameFile("from.txt", "to.txt");
- inAnyOrder([
- isRemoveEvent("from.txt"),
- isModifyEvent("to.txt")
- ]);
+ inAnyOrder([isRemoveEvent("from.txt"), isModifyEvent("to.txt")]);
});
});
@@ -174,7 +157,8 @@
});
});
- test("reports a modification when a file is deleted and then immediately "
+ test(
+ "reports a modification when a file is deleted and then immediately "
"recreated", () {
writeFile("file.txt");
startWatcher();
@@ -191,7 +175,8 @@
});
});
- test("reports a modification when a file is moved and then immediately "
+ test(
+ "reports a modification when a file is moved and then immediately "
"recreated", () {
writeFile("old.txt");
startWatcher();
@@ -200,10 +185,7 @@
writeFile("old.txt", contents: "re-created");
allowEither(() {
- inAnyOrder([
- isModifyEvent("old.txt"),
- isAddEvent("new.txt")
- ]);
+ inAnyOrder([isModifyEvent("old.txt"), isAddEvent("new.txt")]);
}, () {
// Backup case.
expectRemoveEvent("old.txt");
@@ -212,7 +194,8 @@
});
});
- test("reports a removal when a file is modified and then immediately "
+ test(
+ "reports a removal when a file is modified and then immediately "
"removed", () {
writeFile("file.txt");
startWatcher();
@@ -248,16 +231,14 @@
expectAddEvent("a/b/c/d/file.txt");
});
- test('notifies when a subdirectory is moved within the watched directory '
+ test(
+ 'notifies when a subdirectory is moved within the watched directory '
'and then its contents are modified', () {
writeFile("old/file.txt");
startWatcher();
renameDir("old", "new");
- inAnyOrder([
- isRemoveEvent("old/file.txt"),
- isAddEvent("new/file.txt")
- ]);
+ inAnyOrder([isRemoveEvent("old/file.txt"), isAddEvent("new/file.txt")]);
writeFile("new/file.txt", contents: "modified");
expectModifyEvent("new/file.txt");
@@ -295,20 +276,19 @@
});
test('emits events for many nested files added at once', () {
- withPermutations((i, j, k) =>
- writeFile("sub/sub-$i/sub-$j/file-$k.txt"));
+ withPermutations((i, j, k) => writeFile("sub/sub-$i/sub-$j/file-$k.txt"));
createDir("dir");
startWatcher(path: "dir");
renameDir("sub", "dir/sub");
- inAnyOrder(withPermutations((i, j, k) =>
- isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
+ inAnyOrder(withPermutations(
+ (i, j, k) => isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
});
test('emits events for many nested files removed at once', () {
- withPermutations((i, j, k) =>
- writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt"));
+ withPermutations(
+ (i, j, k) => writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt"));
createDir("dir");
startWatcher(path: "dir");
@@ -319,13 +299,13 @@
// directory.
renameDir("dir/sub", "sub");
- inAnyOrder(withPermutations((i, j, k) =>
- isRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
+ inAnyOrder(withPermutations(
+ (i, j, k) => isRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")));
});
test('emits events for many nested files moved at once', () {
- withPermutations((i, j, k) =>
- writeFile("dir/old/sub-$i/sub-$j/file-$k.txt"));
+ withPermutations(
+ (i, j, k) => writeFile("dir/old/sub-$i/sub-$j/file-$k.txt"));
createDir("dir");
startWatcher(path: "dir");
@@ -339,18 +319,18 @@
})));
});
- test("emits events for many files added at once in a subdirectory with the "
+ test(
+ "emits events for many files added at once in a subdirectory with the "
"same name as a removed file", () {
writeFile("dir/sub");
- withPermutations((i, j, k) =>
- writeFile("old/sub-$i/sub-$j/file-$k.txt"));
+ withPermutations((i, j, k) => writeFile("old/sub-$i/sub-$j/file-$k.txt"));
startWatcher(path: "dir");
deleteFile("dir/sub");
renameDir("old", "dir/sub");
- var events = withPermutations((i, j, k) =>
- isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt"));
+ var events = withPermutations(
+ (i, j, k) => isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt"));
events.add(isRemoveEvent("dir/sub"));
inAnyOrder(events);
});
diff --git a/pkgs/watcher/test/directory_watcher/windows_test.dart b/pkgs/watcher/test/directory_watcher/windows_test.dart
index 55e40a9..176fe2d 100644
--- a/pkgs/watcher/test/directory_watcher/windows_test.dart
+++ b/pkgs/watcher/test/directory_watcher/windows_test.dart
@@ -19,7 +19,7 @@
sharedTests();
test('DirectoryWatcher creates a WindowsDirectoryWatcher on Windows', () {
- expect(new DirectoryWatcher('.'),
- new isInstanceOf<WindowsDirectoryWatcher>());
+ expect(
+ new DirectoryWatcher('.'), new isInstanceOf<WindowsDirectoryWatcher>());
});
}
diff --git a/pkgs/watcher/test/file_watcher/shared.dart b/pkgs/watcher/test/file_watcher/shared.dart
index 9a4965c..50f7aeb 100644
--- a/pkgs/watcher/test/file_watcher/shared.dart
+++ b/pkgs/watcher/test/file_watcher/shared.dart
@@ -50,7 +50,8 @@
expectRemoveEvent("file.txt");
});
- test("emits a modify event when another file is moved on top of the watched "
+ test(
+ "emits a modify event when another file is moved on top of the watched "
"file", () {
writeFile("old.txt");
startWatcher(path: "file.txt");
diff --git a/pkgs/watcher/test/path_set_test.dart b/pkgs/watcher/test/path_set_test.dart
index d3420d3..be15c77 100644
--- a/pkgs/watcher/test/path_set_test.dart
+++ b/pkgs/watcher/test/path_set_test.dart
@@ -6,12 +6,11 @@
import 'package:test/test.dart';
import 'package:watcher/src/path_set.dart';
-Matcher containsPath(String path) => predicate((set) =>
- set is PathSet && set.contains(path),
- 'set contains "$path"');
+Matcher containsPath(String path) => predicate(
+ (set) => set is PathSet && set.contains(path), 'set contains "$path"');
-Matcher containsDir(String path) => predicate((set) =>
- set is PathSet && set.containsDir(path),
+Matcher containsDir(String path) => predicate(
+ (set) => set is PathSet && set.containsDir(path),
'set contains directory "$path"');
void main() {
@@ -61,11 +60,13 @@
set.add("root/path/to/two");
set.add("root/path/to/sub/three");
- expect(set.remove("root/path"), unorderedEquals([
- "root/path/to/one",
- "root/path/to/two",
- "root/path/to/sub/three"
- ].map(p.normalize)));
+ expect(
+ set.remove("root/path"),
+ unorderedEquals([
+ "root/path/to/one",
+ "root/path/to/two",
+ "root/path/to/sub/three"
+ ].map(p.normalize)));
expect(set, containsPath("root/outside"));
expect(set, isNot(containsPath("root/path/to/one")));
@@ -73,19 +74,22 @@
expect(set, isNot(containsPath("root/path/to/sub/three")));
});
- test("that's a directory in the set removes and returns it and all files "
+ test(
+ "that's a directory in the set removes and returns it and all files "
"beneath it", () {
set.add("root/path");
set.add("root/path/to/one");
set.add("root/path/to/two");
set.add("root/path/to/sub/three");
- expect(set.remove("root/path"), unorderedEquals([
- "root/path",
- "root/path/to/one",
- "root/path/to/two",
- "root/path/to/sub/three"
- ].map(p.normalize)));
+ expect(
+ set.remove("root/path"),
+ unorderedEquals([
+ "root/path",
+ "root/path/to/one",
+ "root/path/to/two",
+ "root/path/to/sub/three"
+ ].map(p.normalize)));
expect(set, isNot(containsPath("root/path")));
expect(set, isNot(containsPath("root/path/to/one")));
@@ -157,14 +161,16 @@
expect(set, isNot(containsDir("root/path/to/file")));
});
- test("returns false for a directory that was added implicitly and then "
+ test(
+ "returns false for a directory that was added implicitly and then "
"removed implicitly", () {
set.add("root/path/to/file");
set.remove("root/path/to/file");
expect(set, isNot(containsDir("root/path")));
});
- test("returns false for a directory that was added explicitly whose "
+ test(
+ "returns false for a directory that was added explicitly whose "
"children were then removed", () {
set.add("root/path");
set.add("root/path/to/file");
@@ -190,11 +196,13 @@
set.add("root/path/to/one");
set.add("root/path/to/two");
- expect(set.paths, unorderedEquals([
- "root/path",
- "root/path/to/one",
- "root/path/to/two",
- ].map(p.normalize)));
+ expect(
+ set.paths,
+ unorderedEquals([
+ "root/path",
+ "root/path/to/one",
+ "root/path/to/two",
+ ].map(p.normalize)));
});
test("doesn't return paths removed from the set", () {
diff --git a/pkgs/watcher/test/utils.dart b/pkgs/watcher/test/utils.dart
index e91ed15..6700500 100644
--- a/pkgs/watcher/test/utils.dart
+++ b/pkgs/watcher/test/utils.dart
@@ -35,6 +35,7 @@
set watcherFactory(WatcherFactory factory) {
_watcherFactory = factory;
}
+
WatcherFactory _watcherFactory;
/// Creates the sandbox directory the other functions in this library use and
@@ -113,20 +114,22 @@
// Schedule [_watcher.events.listen] so that the watcher doesn't start
// watching [path] before it exists. Expose [_watcherEvents] immediately so
// that it can be accessed synchronously after this.
- _watcherEvents = new ScheduledStream(futureStream(schedule(() {
- currentSchedule.onComplete.schedule(() {
- _watcher = null;
- if (!_closePending) _watcherEvents.close();
+ _watcherEvents = new ScheduledStream(futureStream(
+ schedule(() {
+ currentSchedule.onComplete.schedule(() {
+ _watcher = null;
+ if (!_closePending) _watcherEvents.close();
- // If there are already errors, don't add this to the output and make
- // people think it might be the root cause.
- if (currentSchedule.errors.isEmpty) {
- _watcherEvents.expect(isDone);
- }
- }, "reset watcher");
+ // If there are already errors, don't add this to the output and make
+ // people think it might be the root cause.
+ if (currentSchedule.errors.isEmpty) {
+ _watcherEvents.expect(isDone);
+ }
+ }, "reset watcher");
- return _watcher.events;
- }, "create watcher"), broadcast: true));
+ return _watcher.events;
+ }, "create watcher"),
+ broadcast: true));
schedule(() => _watcher.ready, "wait for watcher to be ready");
}
@@ -193,8 +196,8 @@
///
/// If both blocks match, the one that consumed more events will be used.
void allowEither(block1(), block2()) {
- _expectOrCollect(either(
- _collectStreamMatcher(block1), _collectStreamMatcher(block2)));
+ _expectOrCollect(
+ either(_collectStreamMatcher(block1), _collectStreamMatcher(block2)));
}
/// Allows the expectations established in [block] to match the emitted events.
@@ -210,7 +213,8 @@
/// [path].
Matcher isWatchEvent(ChangeType type, String path) {
return predicate((e) {
- return e is WatchEvent && e.type == type &&
+ return e is WatchEvent &&
+ e.type == type &&
e.path == p.join(_sandboxDir, p.normalize(path));
}, "is $type $path");
}
@@ -344,8 +348,7 @@
/// Returns a set of all values returns by [callback].
///
/// [limit] defaults to 3.
-Set<S> withPermutations<S>(S callback(int i, int j, int k),
- {int limit}) {
+Set<S> withPermutations<S>(S callback(int i, int j, int k), {int limit}) {
if (limit == null) limit = 3;
var results = new Set<S>();
for (var i = 0; i < limit; i++) {