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

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
« runtime/bin/directory_win.cc ('K') | « 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..81455a5d575d59c646e4c4e2958c90a67e161d1e 100644
--- a/tests/standalone/io/directory_test.dart
+++ b/tests/standalone/io/directory_test.dart
@@ -186,6 +186,36 @@ class DirectoryTest {
d.deleteRecursivelySync();
}
+ static void testDeleteWindowsJunction() {
Søren Gjesse 2012/08/17 07:07:37 Shouldn't we make this test run with symlinks on L
Mads Ager (google) 2012/08/17 07:08:46 Does this test leave a temporary directory behind.
Bob Nystrom 2012/08/20 23:24:32 Done.
Bob Nystrom 2012/08/20 23:24:32 Done.
+ if (Platform.operatingSystem != "windows") return;
+
+ // temp/
+ // a/
+ // file.txt
+ // b/
+ // a_junction -> a
+ var d = new Directory("").createTempSync();
+ new Directory("${d.path}\\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 junction from temp/b/a_junction -> temp/a.
+ var args = ["/c", "mklink", "/j",
+ "${d.path}\\b\\a_junction", "${d.path}\\a"];
+ Process.run("cmd", args).then((_) {
+ // Delete the directory containing the junction.
+ b.deleteRecursivelySync();
+
+ // We should not have recursed through a_junction into a.
+ Expect.isTrue(f.existsSync());
+ });
+ }
+
static void testExistsCreateDelete() {
new Directory("").createTemp().then((d) {
d.exists().then((bool exists) {
@@ -337,6 +367,7 @@ class DirectoryTest {
testDeleteTooLongName();
testDeleteNonExistentSync();
testDeleteTooLongNameSync();
+ testDeleteWindowsJunction();
testExistsCreateDelete();
testExistsCreateDeleteSync();
testCreateTemp();
@@ -436,6 +467,13 @@ testRename() {
});
}
+Future<File> writeFile(File file, String contents) {
Mads Ager (google) 2012/08/17 07:08:46 Where are you using this? Remove?
Bob Nystrom 2012/08/20 23:24:32 Done.
+ return file.open(FileMode.WRITE).chain((opened) {
+ return opened.writeString(contents).chain((_) {
+ return opened.close().transform((ignore) => file);
+ });
+ });
+}
main() {
DirectoryTest.testMain();
« runtime/bin/directory_win.cc ('K') | « runtime/bin/directory_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698