Re-mark directory_watcher/mac_os_test as passing.

As before, this test is expected to fail. It's only failing on the
bots so we need to get the debug information from the bots to figure
out how to fix it.

This also adds some additional debug information to help clarify some
confusing output from the most recent failing log.

R=rnystrom@google.com
BUG=15024

Review URL: https://codereview.chromium.org//64383004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/watcher@30315 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/watcher/lib/src/directory_watcher/mac_os.dart b/pkgs/watcher/lib/src/directory_watcher/mac_os.dart
index 09fdd66..e7b97e4 100644
--- a/pkgs/watcher/lib/src/directory_watcher/mac_os.dart
+++ b/pkgs/watcher/lib/src/directory_watcher/mac_os.dart
@@ -26,14 +26,21 @@
 /// This also works around issues 14793, 14806, and 14849 in the implementation
 /// of [Directory.watch].
 class MacOSDirectoryWatcher extends ResubscribableDirectoryWatcher {
-  // TODO(nweiz): remove this when issue 15042 is fixed.
-  static bool logDebugInfo = false;
+  // TODO(nweiz): remove these when issue 15042 is fixed.
+  static var logDebugInfo = false;
+  static var _count = 0;
+  final int _id;
 
   MacOSDirectoryWatcher(String directory)
-      : super(directory, () => new _MacOSDirectoryWatcher(directory));
+      : _id = _count++,
+        super(directory, () => new _MacOSDirectoryWatcher(directory, _count));
 }
 
 class _MacOSDirectoryWatcher implements ManuallyClosedDirectoryWatcher {
+  // TODO(nweiz): remove these when issue 15042 is fixed.
+  static var _count = 0;
+  final String _id;
+
   final String directory;
 
   Stream<WatchEvent> get events => _eventsController.stream;
@@ -73,9 +80,10 @@
   /// watcher is closed. This does not include [_watchSubscription].
   final _subscriptions = new Set<StreamSubscription>();
 
-  _MacOSDirectoryWatcher(String directory)
+  _MacOSDirectoryWatcher(String directory, int parentId)
       : directory = directory,
-        _files = new PathSet(directory) {
+        _files = new PathSet(directory),
+        _id = "$parentId/${_count++}" {
     _startWatch();
 
     _listen(new Directory(directory).list(recursive: true),
@@ -85,7 +93,10 @@
         onError: _emitError,
         onDone: () {
       if (MacOSDirectoryWatcher.logDebugInfo) {
-        print("watcher is ready");
+        print("[$_id] watcher is ready, known files:");
+        for (var file in _files.toSet()) {
+          print("[$_id]   ${p.relative(file, from: directory)}");
+        }
       }
       _readyCompleter.complete();
     },
@@ -93,6 +104,9 @@
   }
 
   void close() {
+    if (MacOSDirectoryWatcher.logDebugInfo) {
+      print("[$_id] watcher is closed");
+    }
     for (var subscription in _subscriptions) {
       subscription.cancel();
     }
@@ -105,14 +119,14 @@
   /// The callback that's run when [Directory.watch] emits a batch of events.
   void _onBatch(List<FileSystemEvent> batch) {
     if (MacOSDirectoryWatcher.logDebugInfo) {
-      print("======== batch:");
+      print("[$_id] ======== batch:");
       for (var event in batch) {
-        print("  ${_formatEvent(event)}");
+        print("[$_id]   ${_formatEvent(event)}");
       }
 
-      print("known files:");
-      for (var foo in _files.toSet()) {
-        print("  ${p.relative(foo, from: directory)}");
+      print("[$_id] known files:");
+      for (var file in _files.toSet()) {
+        print("[$_id]   ${p.relative(file, from: directory)}");
       }
     }
 
@@ -121,9 +135,9 @@
     _sortEvents(batch).forEach((path, events) {
       var relativePath = p.relative(path, from: directory);
       if (MacOSDirectoryWatcher.logDebugInfo) {
-        print("events for $relativePath:\n");
+        print("[$_id] events for $relativePath:\n");
         for (var event in events) {
-          print("  ${_formatEvent(event)}");
+          print("[$_id]   ${_formatEvent(event)}");
         }
       }
 
@@ -131,9 +145,9 @@
       events = canonicalEvent == null ?
           _eventsBasedOnFileSystem(path) : [canonicalEvent];
       if (MacOSDirectoryWatcher.logDebugInfo) {
-        print("canonical event for $relativePath: "
+        print("[$_id] canonical event for $relativePath: "
             "${_formatEvent(canonicalEvent)}");
-        print("actionable events for $relativePath: "
+        print("[$_id] actionable events for $relativePath: "
             "${events.map(_formatEvent)}");
       }
 
@@ -151,7 +165,7 @@
             _files.add(entity.path);
           }, onError: (e, stackTrace) {
             if (MacOSDirectoryWatcher.logDebugInfo) {
-              print("got error listing $relativePath: $e");
+              print("[$_id] got error listing $relativePath: $e");
             }
             _emitError(e, stackTrace);
           }, cancelOnError: true);
@@ -168,7 +182,7 @@
     });
 
     if (MacOSDirectoryWatcher.logDebugInfo) {
-      print("========");
+      print("[$_id] ======== batch complete");
     }
   }
 
@@ -307,10 +321,10 @@
     var dirExists = new Directory(path).existsSync();
 
     if (MacOSDirectoryWatcher.logDebugInfo) {
-      print("file existed: $fileExisted");
-      print("dir existed: $dirExisted");
-      print("file exists: $fileExists");
-      print("dir exists: $dirExists");
+      print("[$_id] file existed: $fileExisted");
+      print("[$_id] dir existed: $dirExisted");
+      print("[$_id] file exists: $fileExists");
+      print("[$_id] dir exists: $dirExists");
     }
 
     var events = [];
@@ -383,7 +397,7 @@
     if (type == ChangeType.ADD && _files.contains(path)) return;
 
     if (MacOSDirectoryWatcher.logDebugInfo) {
-      print("emitting $type ${p.relative(path, from: directory)}");
+      print("[$_id] emitting $type ${p.relative(path, from: directory)}");
     }
 
     _eventsController.add(new WatchEvent(type, path));
diff --git a/pkgs/watcher/test/utils.dart b/pkgs/watcher/test/utils.dart
index 567bdb2..a7bd9b6 100644
--- a/pkgs/watcher/test/utils.dart
+++ b/pkgs/watcher/test/utils.dart
@@ -15,6 +15,9 @@
 import 'package:watcher/src/stat.dart';
 import 'package:watcher/src/utils.dart';
 
+// TODO(nweiz): remove this when issue 15042 is fixed.
+import 'package:watcher/src/directory_watcher/mac_os.dart';
+
 /// The path to the temporary sandbox created for each test. All file
 /// operations are implicitly relative to this directory.
 String _sandboxDir;
@@ -115,6 +118,11 @@
 ///
 /// If [dir] is provided, watches a subdirectory in the sandbox with that name.
 void startWatcher({String dir}) {
+  var testCase = currentTestCase.description;
+  if (MacOSDirectoryWatcher.logDebugInfo) {
+    print("starting watcher for $testCase");
+  }
+
   // We want to wait until we're ready *after* we subscribe to the watcher's
   // events.
   _watcher = createWatcher(dir: dir, waitForReady: false);
@@ -128,6 +136,10 @@
         onError: currentSchedule.signalError);
 
     currentSchedule.onComplete.schedule(() {
+      if (MacOSDirectoryWatcher.logDebugInfo) {
+        print("stopping watcher for $testCase");
+      }
+
       var numEvents = _nextEvent;
       subscription.cancel();
       _nextEvent = 0;