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

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

Issue 10825413: Don't traverse through junctions when recursively deleting on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/directory_win.cc ('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 // Directory listing test. 5 // Directory listing test.
6 6
7 #import("dart:io"); 7 #import("dart:io");
8 #import("dart:isolate"); 8 #import("dart:isolate");
9 9
10 class DirectoryTest { 10 class DirectoryTest {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 buffer.add(subDir.path); 179 buffer.add(subDir.path);
180 for (var i = 0; i < 1000; i++) { 180 for (var i = 0; i < 1000; i++) {
181 buffer.add("/../${subDirName}"); 181 buffer.add("/../${subDirName}");
182 } 182 }
183 var long = new Directory("${buffer.toString()}"); 183 var long = new Directory("${buffer.toString()}");
184 Expect.throws(long.deleteSync); 184 Expect.throws(long.deleteSync);
185 Expect.throws(() => long.deleteRecursivelySync()); 185 Expect.throws(() => long.deleteRecursivelySync());
186 d.deleteRecursivelySync(); 186 d.deleteRecursivelySync();
187 } 187 }
188 188
189 static void testDeleteSymlink() {
190 // temp/
191 // a/
192 // file.txt
193 // b/
194 // a_link -> a
195 var d = new Directory("").createTempSync();
196 var a = new Directory("${d.path}/a");
197 a.createSync();
198
199 var b = new Directory("${d.path}/b");
200 b.createSync();
201
202 var f = new File("${d.path}/a/file.txt");
203 f.createSync();
204 Expect.isTrue(f.existsSync());
205
206 // Create a symlink (or junction on Windows) from
207 // temp/b/a_link to temp/a.
208 var cmd = "ln";
209 var args = ['-s', "${d.path}/b/a_link", "${d.path}/a"];
210
211 if (Platform.operatingSystem == "windows") {
212 cmd = "cmd";
213 args = ["/c", "mklink", "/j", "${d.path}\\b\\a_link", "${d.path}\\a"];
214 }
215
216 Process.run(cmd, args).then((_) {
217 // Delete the directory containing the junction.
218 b.deleteRecursivelySync();
219
220 // We should not have recursed through a_link into a.
221 Expect.isTrue(f.existsSync());
222
223 // Clean up after ourselves.
224 d.deleteRecursivelySync();
225 });
226 }
227
189 static void testExistsCreateDelete() { 228 static void testExistsCreateDelete() {
190 new Directory("").createTemp().then((d) { 229 new Directory("").createTemp().then((d) {
191 d.exists().then((bool exists) { 230 d.exists().then((bool exists) {
192 Expect.isTrue(exists); 231 Expect.isTrue(exists);
193 Directory created = new Directory("${d.path}/subdir"); 232 Directory created = new Directory("${d.path}/subdir");
194 created.create().then((ignore) { 233 created.create().then((ignore) {
195 created.exists().then((bool exists) { 234 created.exists().then((bool exists) {
196 Expect.isTrue(exists); 235 Expect.isTrue(exists);
197 created.delete().then((ignore) { 236 created.delete().then((ignore) {
198 created.exists().then((bool exists) { 237 created.exists().then((bool exists) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 369 }
331 370
332 static void testMain() { 371 static void testMain() {
333 testListing(); 372 testListing();
334 testListNonExistent(); 373 testListNonExistent();
335 testListTooLongName(); 374 testListTooLongName();
336 testDeleteNonExistent(); 375 testDeleteNonExistent();
337 testDeleteTooLongName(); 376 testDeleteTooLongName();
338 testDeleteNonExistentSync(); 377 testDeleteNonExistentSync();
339 testDeleteTooLongNameSync(); 378 testDeleteTooLongNameSync();
379 testDeleteSymlink();
340 testExistsCreateDelete(); 380 testExistsCreateDelete();
341 testExistsCreateDeleteSync(); 381 testExistsCreateDeleteSync();
342 testCreateTemp(); 382 testCreateTemp();
343 testCreateDeleteTemp(); 383 testCreateDeleteTemp();
344 testCurrent(); 384 testCurrent();
345 testFromPath(); 385 testFromPath();
346 } 386 }
347 } 387 }
348 388
349 389
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 temp2.rename(temp1.path).then((temp4) { 469 temp2.rename(temp1.path).then((temp4) {
430 Expect.isFalse(temp3.existsSync()); 470 Expect.isFalse(temp3.existsSync());
431 Expect.isFalse(temp2.existsSync()); 471 Expect.isFalse(temp2.existsSync());
432 Expect.isTrue(temp1.existsSync()); 472 Expect.isTrue(temp1.existsSync());
433 Expect.isTrue(temp4.existsSync()); 473 Expect.isTrue(temp4.existsSync());
434 Expect.equals(temp1.path, temp4.path); 474 Expect.equals(temp1.path, temp4.path);
435 temp1.deleteRecursivelySync(); 475 temp1.deleteRecursivelySync();
436 }); 476 });
437 } 477 }
438 478
439
440 main() { 479 main() {
441 DirectoryTest.testMain(); 480 DirectoryTest.testMain();
442 NestedTempDirectoryTest.testMain(); 481 NestedTempDirectoryTest.testMain();
443 testCreateTempErrorSync(); 482 testCreateTempErrorSync();
444 testCreateTempError(); 483 testCreateTempError();
445 testRename(); 484 testRename();
446 } 485 }
OLDNEW
« no previous file with comments | « runtime/bin/directory_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698