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

Side by Side Diff: tests/standalone/io/file_system_links_test.dart

Issue 23886004: Update dart:io tests to use asyncStart/asyncEnd (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:io";
6
7 import "package:async_helper/async_helper.dart";
5 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
6 import "dart:io";
7 import "dart:isolate";
8
9 9
10 createLink(String dst, String link, void callback()) { 10 createLink(String dst, String link, void callback()) {
11 new Link(link).create(dst).then((_) => callback()); 11 new Link(link).create(dst).then((_) => callback());
12 } 12 }
13 13
14 14
15 testFileExistsCreate() { 15 testFileExistsCreate() {
16 var temp = new Directory('').createTempSync(); 16 var temp = new Directory('').createTempSync();
17 var x = '${temp.path}${Platform.pathSeparator}x'; 17 var x = '${temp.path}${Platform.pathSeparator}x';
18 var y = '${temp.path}${Platform.pathSeparator}y'; 18 var y = '${temp.path}${Platform.pathSeparator}y';
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 Expect.isFalse(link.existsSync()); 146 Expect.isFalse(link.existsSync());
147 Expect.isTrue(temp2.existsSync()); 147 Expect.isTrue(temp2.existsSync());
148 Expect.isTrue(new File(x).existsSync()); 148 Expect.isTrue(new File(x).existsSync());
149 temp2.deleteSync(recursive: true); 149 temp2.deleteSync(recursive: true);
150 }); 150 });
151 }); 151 });
152 } 152 }
153 153
154 154
155 testDirectoryListing() { 155 testDirectoryListing() {
156 var keepAlive = new ReceivePort(); 156 asyncStart();
157 var temp = new Directory('').createTempSync(); 157 var temp = new Directory('').createTempSync();
158 var temp2 = new Directory('').createTempSync(); 158 var temp2 = new Directory('').createTempSync();
159 var y = '${temp.path}${Platform.pathSeparator}y'; 159 var y = '${temp.path}${Platform.pathSeparator}y';
160 var x = '${temp2.path}${Platform.pathSeparator}x'; 160 var x = '${temp2.path}${Platform.pathSeparator}x';
161 new File(x).createSync(); 161 new File(x).createSync();
162 createLink(temp2.path, y, () { 162 createLink(temp2.path, y, () {
163 var files = []; 163 var files = [];
164 var dirs = []; 164 var dirs = [];
165 for (var entry in temp.listSync(recursive:true)) { 165 for (var entry in temp.listSync(recursive:true)) {
166 if (entry is File) { 166 if (entry is File) {
(...skipping 19 matching lines...) Expand all
186 dirs.add(entity.path); 186 dirs.add(entity.path);
187 } 187 }
188 }, 188 },
189 onDone: () { 189 onDone: () {
190 Expect.equals(1, files.length); 190 Expect.equals(1, files.length);
191 Expect.isTrue(files[0].endsWith('$y${Platform.pathSeparator}x')); 191 Expect.isTrue(files[0].endsWith('$y${Platform.pathSeparator}x'));
192 Expect.equals(1, dirs.length); 192 Expect.equals(1, dirs.length);
193 Expect.isTrue(dirs[0].endsWith(y)); 193 Expect.isTrue(dirs[0].endsWith(y));
194 temp.deleteSync(recursive: true); 194 temp.deleteSync(recursive: true);
195 temp2.deleteSync(recursive: true); 195 temp2.deleteSync(recursive: true);
196 keepAlive.close(); 196 asyncEnd();
197 }); 197 });
198 }); 198 });
199 } 199 }
200 200
201 201
202 testDirectoryListingBrokenLink() { 202 testDirectoryListingBrokenLink() {
203 var keepAlive = new ReceivePort(); 203 asyncStart();
204 var temp = new Directory('').createTempSync(); 204 var temp = new Directory('').createTempSync();
205 var x = '${temp.path}${Platform.pathSeparator}x'; 205 var x = '${temp.path}${Platform.pathSeparator}x';
206 var link = '${temp.path}${Platform.pathSeparator}link'; 206 var link = '${temp.path}${Platform.pathSeparator}link';
207 var doesNotExist = 'this_thing_does_not_exist'; 207 var doesNotExist = 'this_thing_does_not_exist';
208 new File(x).createSync(); 208 new File(x).createSync();
209 createLink(doesNotExist, link, () { 209 createLink(doesNotExist, link, () {
210 temp.listSync(recursive: true); // No exceptions. 210 temp.listSync(recursive: true); // No exceptions.
211 var files = []; 211 var files = [];
212 var dirs = []; 212 var dirs = [];
213 var links = []; 213 var links = [];
(...skipping 11 matching lines...) Expand all
225 }, 225 },
226 onError: (e) => errors.add(e), 226 onError: (e) => errors.add(e),
227 onDone: () { 227 onDone: () {
228 Expect.equals(1, files.length); 228 Expect.equals(1, files.length);
229 Expect.isTrue(files[0].endsWith(x)); 229 Expect.isTrue(files[0].endsWith(x));
230 Expect.equals(1, links.length); 230 Expect.equals(1, links.length);
231 Expect.isTrue(links[0].endsWith(link)); 231 Expect.isTrue(links[0].endsWith(link));
232 Expect.equals(0, dirs.length); 232 Expect.equals(0, dirs.length);
233 Expect.equals(0, errors.length); 233 Expect.equals(0, errors.length);
234 temp.deleteSync(recursive: true); 234 temp.deleteSync(recursive: true);
235 keepAlive.close(); 235 asyncEnd();
236 }); 236 });
237 }); 237 });
238 } 238 }
239 239
240 240
241 main() { 241 main() {
242 // Links on Windows are tested by windows_file_system_[async_]links_test. 242 // Links on Windows are tested by windows_file_system_[async_]links_test.
243 if (Platform.operatingSystem != 'windows') { 243 if (Platform.operatingSystem != 'windows') {
244 testFileExistsCreate(); 244 testFileExistsCreate();
245 testFileDelete(); 245 testFileDelete();
246 testFileWriteRead(); 246 testFileWriteRead();
247 testDirectoryExistsCreate(); 247 testDirectoryExistsCreate();
248 testDirectoryDelete(); 248 testDirectoryDelete();
249 testDirectoryListing(); 249 testDirectoryListing();
250 testDirectoryListingBrokenLink(); 250 testDirectoryListingBrokenLink();
251 } 251 }
252 } 252 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_system_async_links_test.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698