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

Side by Side Diff: pkg/watcher/test/utils.dart

Issue 63643008: Remove debugging prints from the Mac OS directory watcher. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/watcher/test/directory_watcher/mac_os_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library watcher.test.utils; 5 library watcher.test.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import 'package:path/path.dart' as p; 11 import 'package:path/path.dart' as p;
12 import 'package:scheduled_test/scheduled_test.dart'; 12 import 'package:scheduled_test/scheduled_test.dart';
13 import 'package:unittest/compact_vm_config.dart'; 13 import 'package:unittest/compact_vm_config.dart';
14 import 'package:watcher/watcher.dart'; 14 import 'package:watcher/watcher.dart';
15 import 'package:watcher/src/stat.dart'; 15 import 'package:watcher/src/stat.dart';
16 import 'package:watcher/src/utils.dart'; 16 import 'package:watcher/src/utils.dart';
17 17
18 // TODO(nweiz): remove this when issue 15042 is fixed.
19 import 'package:watcher/src/directory_watcher/mac_os.dart';
20
21 /// The path to the temporary sandbox created for each test. All file 18 /// The path to the temporary sandbox created for each test. All file
22 /// operations are implicitly relative to this directory. 19 /// operations are implicitly relative to this directory.
23 String _sandboxDir; 20 String _sandboxDir;
24 21
25 /// The [DirectoryWatcher] being used for the current scheduled test. 22 /// The [DirectoryWatcher] being used for the current scheduled test.
26 DirectoryWatcher _watcher; 23 DirectoryWatcher _watcher;
27 24
28 /// The index in [_watcher]'s event stream for the next event. When event 25 /// The index in [_watcher]'s event stream for the next event. When event
29 /// expectations are set using [expectEvent] (et. al.), they use this to 26 /// expectations are set using [expectEvent] (et. al.), they use this to
30 /// expect a series of events in order. 27 /// expect a series of events in order.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 108 }
112 109
113 /// The stream of events from the watcher started with [startWatcher]. 110 /// The stream of events from the watcher started with [startWatcher].
114 Stream _watcherEvents; 111 Stream _watcherEvents;
115 112
116 /// Creates a new [DirectoryWatcher] that watches a temporary directory and 113 /// Creates a new [DirectoryWatcher] that watches a temporary directory and
117 /// starts monitoring it for events. 114 /// starts monitoring it for events.
118 /// 115 ///
119 /// If [dir] is provided, watches a subdirectory in the sandbox with that name. 116 /// If [dir] is provided, watches a subdirectory in the sandbox with that name.
120 void startWatcher({String dir}) { 117 void startWatcher({String dir}) {
121 var testCase = currentTestCase.description;
122 if (MacOSDirectoryWatcher.logDebugInfo) {
123 print("starting watcher for $testCase");
124 }
125
126 // We want to wait until we're ready *after* we subscribe to the watcher's 118 // We want to wait until we're ready *after* we subscribe to the watcher's
127 // events. 119 // events.
128 _watcher = createWatcher(dir: dir, waitForReady: false); 120 _watcher = createWatcher(dir: dir, waitForReady: false);
129 121
130 // Schedule [_watcher.events.listen] so that the watcher doesn't start 122 // Schedule [_watcher.events.listen] so that the watcher doesn't start
131 // watching [dir] before it exists. Expose [_watcherEvents] immediately so 123 // watching [dir] before it exists. Expose [_watcherEvents] immediately so
132 // that it can be accessed synchronously after this. 124 // that it can be accessed synchronously after this.
133 _watcherEvents = futureStream(schedule(() { 125 _watcherEvents = futureStream(schedule(() {
134 var allEvents = new Queue(); 126 var allEvents = new Queue();
135 var subscription = _watcher.events.listen(allEvents.add, 127 var subscription = _watcher.events.listen(allEvents.add,
136 onError: currentSchedule.signalError); 128 onError: currentSchedule.signalError);
137 129
138 currentSchedule.onComplete.schedule(() { 130 currentSchedule.onComplete.schedule(() {
139 if (MacOSDirectoryWatcher.logDebugInfo) {
140 print("stopping watcher for $testCase");
141 }
142
143 var numEvents = _nextEvent; 131 var numEvents = _nextEvent;
144 subscription.cancel(); 132 subscription.cancel();
145 _nextEvent = 0; 133 _nextEvent = 0;
146 _watcher = null; 134 _watcher = null;
147 135
148 // If there are already errors, don't add this to the output and make 136 // If there are already errors, don't add this to the output and make
149 // people think it might be the root cause. 137 // people think it might be the root cause.
150 if (currentSchedule.errors.isEmpty) { 138 if (currentSchedule.errors.isEmpty) {
151 expect(allEvents, hasLength(numEvents)); 139 expect(allEvents, hasLength(numEvents));
152 } else { 140 } else {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 void withPermutations(callback(int i, int j, int k), {int limit}) { 291 void withPermutations(callback(int i, int j, int k), {int limit}) {
304 if (limit == null) limit = 3; 292 if (limit == null) limit = 3;
305 for (var i = 0; i < limit; i++) { 293 for (var i = 0; i < limit; i++) {
306 for (var j = 0; j < limit; j++) { 294 for (var j = 0; j < limit; j++) {
307 for (var k = 0; k < limit; k++) { 295 for (var k = 0; k < limit; k++) {
308 callback(i, j, k); 296 callback(i, j, k);
309 } 297 }
310 } 298 }
311 } 299 }
312 } 300 }
OLDNEW
« no previous file with comments | « pkg/watcher/test/directory_watcher/mac_os_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698