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

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

Issue 13578003: Fix directory-listing, directory-deletion and file deletion, when links are involved. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use Link for Link removal. Created 7 years, 8 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 | « tests/standalone/io/directory_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) 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"; 5 import "dart:io";
6 import "dart:isolate"; 6 import "dart:isolate";
7 7
8 8
9 createLink(String dst, String link, void callback()) { 9 createLink(String dst, String link, void callback()) {
10 new Link(link).create(dst).then((_) => callback()); 10 new Link(link).create(dst).then((_) => callback());
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 200
201 testDirectoryListingBrokenLink() { 201 testDirectoryListingBrokenLink() {
202 var keepAlive = new ReceivePort(); 202 var keepAlive = new ReceivePort();
203 var temp = new Directory('').createTempSync(); 203 var temp = new Directory('').createTempSync();
204 var x = '${temp.path}${Platform.pathSeparator}x'; 204 var x = '${temp.path}${Platform.pathSeparator}x';
205 var link = '${temp.path}${Platform.pathSeparator}link'; 205 var link = '${temp.path}${Platform.pathSeparator}link';
206 var doesNotExist = 'this_thing_does_not_exist'; 206 var doesNotExist = 'this_thing_does_not_exist';
207 new File(x).createSync(); 207 new File(x).createSync();
208 createLink(doesNotExist, link, () { 208 createLink(doesNotExist, link, () {
209 Expect.throws(() => temp.listSync(recursive: true), 209 temp.listSync(recursive: true); // No exceptions.
210 (e) => e is DirectoryIOException);
211 var files = []; 210 var files = [];
212 var dirs = []; 211 var dirs = [];
212 var links = [];
213 var errors = []; 213 var errors = [];
214 temp.list(recursive: true).listen( 214 temp.list(recursive: true).listen(
215 (entity) { 215 (entity) {
216 if (entity is File) { 216 if (entity is File) {
217 files.add(entity.path); 217 files.add(entity.path);
218 } else if (entity is Link) {
219 links.add(entity.path);
218 } else { 220 } else {
219 Expect.isTrue(entity is Directory); 221 Expect.isTrue(entity is Directory);
220 dirs.add(entity.path); 222 dirs.add(entity.path);
221 } 223 }
222 }, 224 },
223 onError: (e) => errors.add(e), 225 onError: (e) => errors.add(e),
224 onDone: () { 226 onDone: () {
225 Expect.equals(1, files.length); 227 Expect.equals(1, files.length);
226 Expect.isTrue(files[0].endsWith(x)); 228 Expect.isTrue(files[0].endsWith(x));
229 Expect.equals(1, links.length);
230 Expect.isTrue(links[0].endsWith(link));
227 Expect.equals(0, dirs.length); 231 Expect.equals(0, dirs.length);
228 Expect.equals(1, errors.length); 232 Expect.equals(0, errors.length);
229 Expect.isTrue(errors[0].toString().contains(link));
230 temp.deleteSync(recursive: true); 233 temp.deleteSync(recursive: true);
231 keepAlive.close(); 234 keepAlive.close();
232 }); 235 });
233 }); 236 });
234 } 237 }
235 238
236 239
237 main() { 240 main() {
238 testFileExistsCreate(); 241 testFileExistsCreate();
239 testFileDelete(); 242 testFileDelete();
240 testFileWriteRead(); 243 testFileWriteRead();
241 testDirectoryExistsCreate(); 244 testDirectoryExistsCreate();
242 testDirectoryDelete(); 245 testDirectoryDelete();
243 testDirectoryListing(); 246 testDirectoryListing();
244 testDirectoryListingBrokenLink(); 247 testDirectoryListingBrokenLink();
245 } 248 }
OLDNEW
« no previous file with comments | « tests/standalone/io/directory_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698