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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/directory_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/directory_test.dart
diff --git a/tests/standalone/io/directory_test.dart b/tests/standalone/io/directory_test.dart
index 488b1d02b0d07ed978258b4cd80dcdc3baf16191..4246bc60a80a53769c8ec909b7305ce5f262f8ec 100644
--- a/tests/standalone/io/directory_test.dart
+++ b/tests/standalone/io/directory_test.dart
@@ -186,6 +186,45 @@ class DirectoryTest {
d.deleteRecursivelySync();
}
+ static void testDeleteSymlink() {
+ // temp/
+ // a/
+ // file.txt
+ // b/
+ // a_link -> a
+ var d = new Directory("").createTempSync();
+ var a = new Directory("${d.path}/a");
+ a.createSync();
+
+ var b = new Directory("${d.path}/b");
+ b.createSync();
+
+ var f = new File("${d.path}/a/file.txt");
+ f.createSync();
+ Expect.isTrue(f.existsSync());
+
+ // Create a symlink (or junction on Windows) from
+ // temp/b/a_link to temp/a.
+ var cmd = "ln";
+ var args = ['-s', "${d.path}/b/a_link", "${d.path}/a"];
+
+ if (Platform.operatingSystem == "windows") {
+ cmd = "cmd";
+ args = ["/c", "mklink", "/j", "${d.path}\\b\\a_link", "${d.path}\\a"];
+ }
+
+ Process.run(cmd, args).then((_) {
+ // Delete the directory containing the junction.
+ b.deleteRecursivelySync();
+
+ // We should not have recursed through a_link into a.
+ Expect.isTrue(f.existsSync());
+
+ // Clean up after ourselves.
+ d.deleteRecursivelySync();
+ });
+ }
+
static void testExistsCreateDelete() {
new Directory("").createTemp().then((d) {
d.exists().then((bool exists) {
@@ -337,6 +376,7 @@ class DirectoryTest {
testDeleteTooLongName();
testDeleteNonExistentSync();
testDeleteTooLongNameSync();
+ testDeleteSymlink();
testExistsCreateDelete();
testExistsCreateDeleteSync();
testCreateTemp();
@@ -436,7 +476,6 @@ testRename() {
});
}
-
main() {
DirectoryTest.testMain();
NestedTempDirectoryTest.testMain();
« 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