Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: pkg/watcher/test/utils.dart

Issue 59143006: Work around a flake in the Mac OS watcher test on the bots. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/watcher/test/no_subscription/shared.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/watcher/test/utils.dart
diff --git a/pkg/watcher/test/utils.dart b/pkg/watcher/test/utils.dart
index e18c7e8131919db141932865c07618a89c924e92..651fd6de4198687611baddc892ea787fde05eb41 100644
--- a/pkg/watcher/test/utils.dart
+++ b/pkg/watcher/test/utils.dart
@@ -176,11 +176,6 @@ void inAnyOrder(block()) {
/// Multiple calls to [expectEvent] require that the events are received in that
/// order unless they're called in an [inAnyOrder] block.
void expectEvent(ChangeType type, String path) {
- var matcher = predicate((e) {
- return e is WatchEvent && e.type == type &&
- e.path == p.join(_sandboxDir, p.normalize(path));
- }, "is $type $path");
-
if (_unorderedEventFuture != null) {
// Assign this to a local variable since it will be un-assigned by the time
// the scheduled callback runs.
@@ -188,7 +183,7 @@ void expectEvent(ChangeType type, String path) {
expect(
schedule(() => future, "should fire $type event on $path"),
- completion(contains(matcher)));
+ completion(contains(isWatchEvent(type, path))));
} else {
var future = currentSchedule.wrapFuture(
_watcherEvents.elementAt(_nextEvent),
@@ -196,11 +191,20 @@ void expectEvent(ChangeType type, String path) {
expect(
schedule(() => future, "should fire $type event on $path"),
- completion(matcher));
+ completion(isWatchEvent(type, path)));
}
_nextEvent++;
}
+/// Returns a matcher that matches a [WatchEvent] with the given [type] and
+/// [path].
+Match isWatchEvent(ChangeType type, String path) {
+ return predicate((e) {
+ return e is WatchEvent && e.type == type &&
+ e.path == p.join(_sandboxDir, p.normalize(path));
+ }, "is $type $path");
+}
+
void expectAddEvent(String path) => expectEvent(ChangeType.ADD, path);
void expectModifyEvent(String path) => expectEvent(ChangeType.MODIFY, path);
void expectRemoveEvent(String path) => expectEvent(ChangeType.REMOVE, path);
« no previous file with comments | « pkg/watcher/test/no_subscription/shared.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698