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

Unified Diff: tests/standalone/io/windows_file_system_links_test.dart

Issue 12617002: dart:io | Implement FileSystemEntity.typeSync on Windows, to identify symbolic links and junctions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make new test a no-op on non-windows platforms. 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/windows_file_system_links_test.dart
diff --git a/tests/standalone/io/windows_file_system_links_test.dart b/tests/standalone/io/windows_file_system_links_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b83c21bb11625c73506cf4056e403c1ca42ba856
--- /dev/null
+++ b/tests/standalone/io/windows_file_system_links_test.dart
@@ -0,0 +1,84 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "dart:io";
+import "dart:isolate";
+
+createJunction(String dst, String link, void callback()) {
+ Process.run("cmd.exe", ["/c", "mklink /J $link $dst"]).then((result) {
+ if (result.exitCode == 0) {
+ callback();
+ } else {
+ throw new Exception('link creation failed');
+ }
+ });
+}
+
+
+testJunctionTypeDelete() {
+ var temp = new Directory('').createTempSync();
+ var x = '${temp.path}${Platform.pathSeparator}x';
+ var y = '${temp.path}${Platform.pathSeparator}y';
+
+ new Directory(x).createSync();
+ createJunction(x, y, () {
+ Expect.isTrue(new Directory(y).existsSync());
+ Expect.isTrue(new Directory(x).existsSync());
+ Expect.isTrue(FileSystemEntity.isLinkSync(y));
+ Expect.isFalse(FileSystemEntity.isLinkSync(x));
+ Expect.isTrue(FileSystemEntity.isDirectorySync(y));
+ Expect.isTrue(FileSystemEntity.isDirectorySync(x));
+ Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(y));
+ Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(x));
+ Expect.equals(FileSystemEntityType.LINK,
+ FileSystemEntity.typeSync(y, followLinks: false));
+ Expect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.typeSync(x, followLinks: false));
+
+ // Test Junction pointing to a missing directory.
+ new Directory(x).deleteSync();
+ Expect.isTrue(new Directory(y).existsSync());
+ Expect.isFalse(new Directory(x).existsSync());
+ Expect.isTrue(FileSystemEntity.isLinkSync(y));
+ Expect.isFalse(FileSystemEntity.isLinkSync(x));
+ Expect.isTrue(FileSystemEntity.isDirectorySync(y));
+ Expect.isFalse(FileSystemEntity.isDirectorySync(x));
+ Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(y));
Søren Gjesse 2013/03/08 09:38:50 Long line (two more below).
+ Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(x));
+ Expect.equals(FileSystemEntityType.LINK,
+ FileSystemEntity.typeSync(y, followLinks: false));
+ Expect.equals(FileSystemEntityType.NOT_FOUND,
+ FileSystemEntity.typeSync(x, followLinks: false));
+
+ // Delete Junction pointing to a missing directory.
+ new Directory(y).deleteSync();
+ Expect.isFalse(FileSystemEntity.isLinkSync(y));
+ Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y));
+
+ new Directory(x).createSync();
+ createJunction(x, y, () {
+ Expect.equals(FileSystemEntityType.LINK,
+ FileSystemEntity.typeSync(y, followLinks: false));
+ Expect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.typeSync(x, followLinks: false));
+
+ // Delete Junction pointing to an existing directory.
+ new Directory(y).deleteSync();
+ Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y));
+ Expect.equals(FileSystemEntityType.NOT_FOUND,
+ FileSystemEntity.typeSync(y, followLinks: false));
+ Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(x));
+ Expect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.typeSync(x, followLinks: false));
+ temp.deleteSync(recursive: true);
+ });
+ });
+}
+
+
+main() {
+ if (Platform.operatingSystem == 'windows') {
+ testJunctionTypeDelete();
+ }
+}
« no previous file with comments | « runtime/bin/file_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698