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

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

Issue 18513006: Add some debug prints to figure out why a test is failing on windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months 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 | « no previous file | 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:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 /// Creates the sandbox directory the other functions in this library use and 43 /// Creates the sandbox directory the other functions in this library use and
44 /// ensures it's deleted when the test ends. 44 /// ensures it's deleted when the test ends.
45 /// 45 ///
46 /// This should usually be called by [setUp]. 46 /// This should usually be called by [setUp].
47 void createSandbox() { 47 void createSandbox() {
48 var dir = new Directory("").createTempSync(); 48 var dir = new Directory("").createTempSync();
49 _sandboxDir = dir.path; 49 _sandboxDir = dir.path;
50 50
51 // TODO(rnystrom): Temporary while debugging the Windows bot.
52 print("create mock modtime map for $_sandboxDir");
53
51 _mockFileModificationTimes = new Map<String, int>(); 54 _mockFileModificationTimes = new Map<String, int>();
52 mockGetModificationTime((path) { 55 mockGetModificationTime((path) {
53 path = p.relative(path, from: _sandboxDir); 56 path = p.relative(path, from: _sandboxDir);
54 57
55 // Make sure we got a path in the sandbox. 58 // Make sure we got a path in the sandbox.
56 assert(p.isRelative(path) && !path.startsWith("..")); 59 assert(p.isRelative(path) && !path.startsWith(".."));
57 60
61 // TODO(rnystrom): Temporary while debugging the Windows bot.
62 print("get mock modtime for $path = ${_mockFileModificationTimes[path]}");
58 return new DateTime.fromMillisecondsSinceEpoch( 63 return new DateTime.fromMillisecondsSinceEpoch(
59 _mockFileModificationTimes[path]); 64 _mockFileModificationTimes[path]);
60 }); 65 });
61 66
62 // Delete the sandbox when done. 67 // Delete the sandbox when done.
63 currentSchedule.onComplete.schedule(() { 68 currentSchedule.onComplete.schedule(() {
69 // TODO(rnystrom): Temporary while debugging the Windows bot.
70 print("delete mock modtime map for $_sandboxDir");
71
64 if (_sandboxDir != null) { 72 if (_sandboxDir != null) {
65 new Directory(_sandboxDir).deleteSync(recursive: true); 73 new Directory(_sandboxDir).deleteSync(recursive: true);
66 _sandboxDir = null; 74 _sandboxDir = null;
67 } 75 }
68 76
69 _mockFileModificationTimes = null; 77 _mockFileModificationTimes = null;
70 mockGetModificationTime(null); 78 mockGetModificationTime(null);
71 }, "delete sandbox"); 79 }, "delete sandbox");
72 } 80 }
73 81
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 140
133 schedule(() { 141 schedule(() {
134 var fullPath = p.join(_sandboxDir, path); 142 var fullPath = p.join(_sandboxDir, path);
135 143
136 // Create any needed subdirectories. 144 // Create any needed subdirectories.
137 var dir = new Directory(p.dirname(fullPath)); 145 var dir = new Directory(p.dirname(fullPath));
138 if (!dir.existsSync()) { 146 if (!dir.existsSync()) {
139 dir.createSync(recursive: true); 147 dir.createSync(recursive: true);
140 } 148 }
141 149
150 // TODO(rnystrom): Temporary while debugging the Windows bot.
151 print("write $path");
152
142 new File(fullPath).writeAsStringSync(contents); 153 new File(fullPath).writeAsStringSync(contents);
143 154
144 // Manually update the mock modification time for the file. 155 // Manually update the mock modification time for the file.
145 if (updateModified) { 156 if (updateModified) {
146 var milliseconds = _mockFileModificationTimes.putIfAbsent(path, () => 0); 157 var milliseconds = _mockFileModificationTimes.putIfAbsent(path, () => 0);
147 _mockFileModificationTimes[path]++; 158 _mockFileModificationTimes[path]++;
159 // TODO(rnystrom): Temporary while debugging the Windows bot.
160 print(" update modtime to ${_mockFileModificationTimes[path]}");
148 } 161 }
149 }); 162 });
150 } 163 }
151 164
152 /// Schedules deleting a file in the sandbox at [path]. 165 /// Schedules deleting a file in the sandbox at [path].
153 void deleteFile(String path) { 166 void deleteFile(String path) {
154 schedule(() { 167 schedule(() {
155 new File(p.join(_sandboxDir, path)).deleteSync(); 168 new File(p.join(_sandboxDir, path)).deleteSync();
156 }); 169 });
157 } 170 }
158 171
159 /// Schedules renaming a file in the sandbox from [from] to [to]. 172 /// Schedules renaming a file in the sandbox from [from] to [to].
160 /// 173 ///
161 /// If [contents] is omitted, creates an empty file. 174 /// If [contents] is omitted, creates an empty file.
162 void renameFile(String from, String to) { 175 void renameFile(String from, String to) {
163 schedule(() { 176 schedule(() {
164 new File(p.join(_sandboxDir, from)).renameSync(p.join(_sandboxDir, to)); 177 new File(p.join(_sandboxDir, from)).renameSync(p.join(_sandboxDir, to));
165 178
179 // TODO(rnystrom): Temporary while debugging the Windows bot.
180 print("rename $from -> $to");
181
166 // Manually update the mock modification time for the file. 182 // Manually update the mock modification time for the file.
167 var milliseconds = _mockFileModificationTimes.putIfAbsent(to, () => 0); 183 var milliseconds = _mockFileModificationTimes.putIfAbsent(to, () => 0);
168 _mockFileModificationTimes[to]++; 184 _mockFileModificationTimes[to]++;
185 // TODO(rnystrom): Temporary while debugging the Windows bot.
186 print(" update modtime to ${_mockFileModificationTimes[to]}");
169 }); 187 });
170 } 188 }
171 189
172 /// A [Matcher] for [WatchEvent]s. 190 /// A [Matcher] for [WatchEvent]s.
173 class _ChangeMatcher extends BaseMatcher { 191 class _ChangeMatcher extends BaseMatcher {
174 /// The expected change. 192 /// The expected change.
175 final ChangeType type; 193 final ChangeType type;
176 194
177 /// The expected path. 195 /// The expected path.
178 final String path; 196 final String path;
179 197
180 _ChangeMatcher(this.type, this.path); 198 _ChangeMatcher(this.type, this.path);
181 199
182 Description describe(Description description) { 200 Description describe(Description description) {
183 description.add("$type $path"); 201 description.add("$type $path");
184 } 202 }
185 203
186 bool matches(item, Map matchState) => 204 bool matches(item, Map matchState) =>
187 item is WatchEvent && item.type == type && item.path == path; 205 item is WatchEvent && item.type == type && item.path == path;
188 } 206 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698