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

Unified 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, 9 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/file_win.cc ('k') | tests/standalone/io/file_system_links_test.dart » ('j') | 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 d6eac48a03daae6dd179e8fc64d43bf91e68cd4d..db5903d23904cedadb91cb9d57458e99705c671e 100644
--- a/tests/standalone/io/directory_test.dart
+++ b/tests/standalone/io/directory_test.dart
@@ -244,6 +244,98 @@ class DirectoryTest {
Expect.isFalse(d.existsSync());
}
+ static void testDeleteLinkSync() {
+ Directory tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ Directory d = new Directory("${path}target");
+ d.createSync();
+ Link l = new Link("${path}symlink");
+ l.createSync("${path}target");
+ Expect.isTrue(d.existsSync());
+ Expect.isTrue(l.existsSync());
+ new Directory(l.path).deleteSync(recursive: true);
+ Expect.isTrue(d.existsSync());
+ Expect.isFalse(l.existsSync());
+ d.deleteSync();
+ Expect.isFalse(d.existsSync());
+ tmp.deleteSync();
+ }
+
+ static void testDeleteLinkAsFileSync() {
+ Directory tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ Directory d = new Directory("${path}target");
+ d.createSync();
+ Link l = new Link("${path}symlink");
+ l.createSync("${path}target");
+ Expect.isTrue(d.existsSync());
+ Expect.isTrue(l.existsSync());
+ new Link(l.path).deleteSync();
+ Expect.isTrue(d.existsSync());
+ Expect.isFalse(l.existsSync());
+ d.deleteSync();
+ Expect.isFalse(d.existsSync());
+ tmp.deleteSync();
+ }
+
+ static void testDeleteBrokenLinkAsFileSync() {
+ Directory tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ Directory d = new Directory("${path}target");
+ d.createSync();
+ Link l = new Link("${path}symlink");
+ l.createSync("${path}target");
+ d.deleteSync();
+ Expect.isFalse(d.existsSync());
+ Expect.isTrue(l.existsSync());
+ new Link(l.path).deleteSync();
+ Expect.isFalse(l.existsSync());
+ Expect.isFalse(d.existsSync());
+ tmp.deleteSync();
+ }
+
+ static void testListBrokenLinkSync() {
+ Directory tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ Directory d = new Directory("${path}target");
+ d.createSync();
+ Link l = new Link("${path}symlink");
+ l.createSync("${path}target");
+ d.deleteSync();
+ int count = 0;
+ tmp.list(followLinks: true).listen(
+ (file) {
+ count++;
+ Expect.isTrue(file is Link);
+ },
+ onDone: () {
+ Expect.equals(1, count);
+ l.deleteSync();
+ tmp.deleteSync();
+ });
+ }
+
+ static void testListLinkSync() {
+ Directory tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ Directory d = new Directory("${path}target");
+ d.createSync();
+ Link l = new Link("${path}symlink");
+ l.createSync("${path}target");
+ int count = 0;
+ tmp.list(followLinks: true).listen(
+ (file) {
+ count++;
+ Expect.isTrue(file is Directory);
+ },
+ onDone: () {
+ Expect.equals(2, count);
+ l.deleteSync();
+ d.deleteSync();
+ tmp.deleteSync();
+ });
+ }
+
static void testCreateTemp([String template = ""]) {
var port = new ReceivePort();
Directory dir = new Directory(template);
@@ -314,6 +406,11 @@ class DirectoryTest {
testDeleteTooLongNameSync();
testExistsCreateDelete();
testExistsCreateDeleteSync();
+ testDeleteLinkSync();
+ testDeleteLinkAsFileSync();
+ testDeleteBrokenLinkAsFileSync();
+ testListBrokenLinkSync();
+ testListLinkSync();
testCreateTemp();
testCreateDeleteTemp();
testCurrent();
« 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