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

Side by Side Diff: tests/standalone/io/directory_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 | « runtime/bin/file_win.cc ('k') | tests/standalone/io/file_system_links_test.dart » ('j') | 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 // Directory listing test. 5 // Directory listing test.
6 6
7 import "dart:async"; 7 import "dart:async";
8 import "dart:io"; 8 import "dart:io";
9 import "dart:isolate"; 9 import "dart:isolate";
10 10
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Expect.isTrue(d2.existsSync()); 237 Expect.isTrue(d2.existsSync());
238 Directory created = new Directory("${d.path}/subdir"); 238 Directory created = new Directory("${d.path}/subdir");
239 created.createSync(); 239 created.createSync();
240 Expect.isTrue(created.existsSync()); 240 Expect.isTrue(created.existsSync());
241 created.deleteSync(); 241 created.deleteSync();
242 Expect.isFalse(created.existsSync()); 242 Expect.isFalse(created.existsSync());
243 d.deleteSync(); 243 d.deleteSync();
244 Expect.isFalse(d.existsSync()); 244 Expect.isFalse(d.existsSync());
245 } 245 }
246 246
247 static void testDeleteLinkSync() {
248 Directory tmp = new Directory("").createTempSync();
249 var path = "${tmp.path}${Platform.pathSeparator}";
250 Directory d = new Directory("${path}target");
251 d.createSync();
252 Link l = new Link("${path}symlink");
253 l.createSync("${path}target");
254 Expect.isTrue(d.existsSync());
255 Expect.isTrue(l.existsSync());
256 new Directory(l.path).deleteSync(recursive: true);
257 Expect.isTrue(d.existsSync());
258 Expect.isFalse(l.existsSync());
259 d.deleteSync();
260 Expect.isFalse(d.existsSync());
261 tmp.deleteSync();
262 }
263
264 static void testDeleteLinkAsFileSync() {
265 Directory tmp = new Directory("").createTempSync();
266 var path = "${tmp.path}${Platform.pathSeparator}";
267 Directory d = new Directory("${path}target");
268 d.createSync();
269 Link l = new Link("${path}symlink");
270 l.createSync("${path}target");
271 Expect.isTrue(d.existsSync());
272 Expect.isTrue(l.existsSync());
273 new Link(l.path).deleteSync();
274 Expect.isTrue(d.existsSync());
275 Expect.isFalse(l.existsSync());
276 d.deleteSync();
277 Expect.isFalse(d.existsSync());
278 tmp.deleteSync();
279 }
280
281 static void testDeleteBrokenLinkAsFileSync() {
282 Directory tmp = new Directory("").createTempSync();
283 var path = "${tmp.path}${Platform.pathSeparator}";
284 Directory d = new Directory("${path}target");
285 d.createSync();
286 Link l = new Link("${path}symlink");
287 l.createSync("${path}target");
288 d.deleteSync();
289 Expect.isFalse(d.existsSync());
290 Expect.isTrue(l.existsSync());
291 new Link(l.path).deleteSync();
292 Expect.isFalse(l.existsSync());
293 Expect.isFalse(d.existsSync());
294 tmp.deleteSync();
295 }
296
297 static void testListBrokenLinkSync() {
298 Directory tmp = new Directory("").createTempSync();
299 var path = "${tmp.path}${Platform.pathSeparator}";
300 Directory d = new Directory("${path}target");
301 d.createSync();
302 Link l = new Link("${path}symlink");
303 l.createSync("${path}target");
304 d.deleteSync();
305 int count = 0;
306 tmp.list(followLinks: true).listen(
307 (file) {
308 count++;
309 Expect.isTrue(file is Link);
310 },
311 onDone: () {
312 Expect.equals(1, count);
313 l.deleteSync();
314 tmp.deleteSync();
315 });
316 }
317
318 static void testListLinkSync() {
319 Directory tmp = new Directory("").createTempSync();
320 var path = "${tmp.path}${Platform.pathSeparator}";
321 Directory d = new Directory("${path}target");
322 d.createSync();
323 Link l = new Link("${path}symlink");
324 l.createSync("${path}target");
325 int count = 0;
326 tmp.list(followLinks: true).listen(
327 (file) {
328 count++;
329 Expect.isTrue(file is Directory);
330 },
331 onDone: () {
332 Expect.equals(2, count);
333 l.deleteSync();
334 d.deleteSync();
335 tmp.deleteSync();
336 });
337 }
338
247 static void testCreateTemp([String template = ""]) { 339 static void testCreateTemp([String template = ""]) {
248 var port = new ReceivePort(); 340 var port = new ReceivePort();
249 Directory dir = new Directory(template); 341 Directory dir = new Directory(template);
250 Future.wait([dir.createTemp(), dir.createTemp()]) 342 Future.wait([dir.createTemp(), dir.createTemp()])
251 .then((tempDirs) { 343 .then((tempDirs) {
252 Expect.notEquals(tempDirs[0].path, tempDirs[1].path); 344 Expect.notEquals(tempDirs[0].path, tempDirs[1].path);
253 for (Directory t in tempDirs) { 345 for (Directory t in tempDirs) {
254 Expect.isTrue(t.existsSync()); 346 Expect.isTrue(t.existsSync());
255 t.deleteSync(); 347 t.deleteSync();
256 Expect.isFalse(t.existsSync()); 348 Expect.isFalse(t.existsSync());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 static void testMain() { 399 static void testMain() {
308 testListing(); 400 testListing();
309 testListNonExistent(); 401 testListNonExistent();
310 testListTooLongName(); 402 testListTooLongName();
311 testDeleteNonExistent(); 403 testDeleteNonExistent();
312 testDeleteTooLongName(); 404 testDeleteTooLongName();
313 testDeleteNonExistentSync(); 405 testDeleteNonExistentSync();
314 testDeleteTooLongNameSync(); 406 testDeleteTooLongNameSync();
315 testExistsCreateDelete(); 407 testExistsCreateDelete();
316 testExistsCreateDeleteSync(); 408 testExistsCreateDeleteSync();
409 testDeleteLinkSync();
410 testDeleteLinkAsFileSync();
411 testDeleteBrokenLinkAsFileSync();
412 testListBrokenLinkSync();
413 testListLinkSync();
317 testCreateTemp(); 414 testCreateTemp();
318 testCreateDeleteTemp(); 415 testCreateDeleteTemp();
319 testCurrent(); 416 testCurrent();
320 testFromPath(); 417 testFromPath();
321 } 418 }
322 } 419 }
323 420
324 421
325 class NestedTempDirectoryTest { 422 class NestedTempDirectoryTest {
326 List<Directory> createdDirectories; 423 List<Directory> createdDirectories;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 testCreateTempErrorSync(); 616 testCreateTempErrorSync();
520 testCreateTempError(); 617 testCreateTempError();
521 testCreateExistingSync(); 618 testCreateExistingSync();
522 testCreateExisting(); 619 testCreateExisting();
523 testCreateDirExistingFileSync(); 620 testCreateDirExistingFileSync();
524 testCreateDirExistingFile(); 621 testCreateDirExistingFile();
525 testCreateRecursive(); 622 testCreateRecursive();
526 testCreateRecursiveSync(); 623 testCreateRecursiveSync();
527 testRename(); 624 testRename();
528 } 625 }
OLDNEW
« no previous file with comments | « runtime/bin/file_win.cc ('k') | tests/standalone/io/file_system_links_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698