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

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: Fix file-system link test. 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..e953097604357e99664d99a85bc9b1dfd1faa0b7 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 File(l.path).deleteSync();
Søren Gjesse 2013/04/04 14:42:35 As discussed on chat this should fail as one canno
Anders Johnsen 2013/04/05 10:58:27 Done.
+ 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 File(l.path).deleteSync();
Søren Gjesse 2013/04/04 14:42:35 Ditto.
Anders Johnsen 2013/04/05 10:58:27 Done.
+ Expect.isFalse(l.existsSync());
+ Expect.isFalse(d.existsSync());
+ tmp.deleteSync();
+ }
+
+ static void testListBrokenLinkSync() {
Søren Gjesse 2013/04/04 14:42:35 Maybe extend this test to add both a file and a di
Anders Johnsen 2013/04/05 10:58:27 I can't as we can't link to files on Windows :(
+ 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() {
Søren Gjesse 2013/04/04 14:42:35 This already does some of what I suggested above.
Anders Johnsen 2013/04/05 10:58:27 Ditto.
+ 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