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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:io";
6 import "dart:isolate";
7
8 createJunction(String dst, String link, void callback()) {
9 Process.run("cmd.exe", ["/c", "mklink /J $link $dst"]).then((result) {
10 if (result.exitCode == 0) {
11 callback();
12 } else {
13 throw new Exception('link creation failed');
14 }
15 });
16 }
17
18
19 testJunctionTypeDelete() {
20 var temp = new Directory('').createTempSync();
21 var x = '${temp.path}${Platform.pathSeparator}x';
22 var y = '${temp.path}${Platform.pathSeparator}y';
23
24 new Directory(x).createSync();
25 createJunction(x, y, () {
26 Expect.isTrue(new Directory(y).existsSync());
27 Expect.isTrue(new Directory(x).existsSync());
28 Expect.isTrue(FileSystemEntity.isLinkSync(y));
29 Expect.isFalse(FileSystemEntity.isLinkSync(x));
30 Expect.isTrue(FileSystemEntity.isDirectorySync(y));
31 Expect.isTrue(FileSystemEntity.isDirectorySync(x));
32 Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(y));
33 Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(x));
34 Expect.equals(FileSystemEntityType.LINK,
35 FileSystemEntity.typeSync(y, followLinks: false));
36 Expect.equals(FileSystemEntityType.DIRECTORY,
37 FileSystemEntity.typeSync(x, followLinks: false));
38
39 // Test Junction pointing to a missing directory.
40 new Directory(x).deleteSync();
41 Expect.isTrue(new Directory(y).existsSync());
42 Expect.isFalse(new Directory(x).existsSync());
43 Expect.isTrue(FileSystemEntity.isLinkSync(y));
44 Expect.isFalse(FileSystemEntity.isLinkSync(x));
45 Expect.isTrue(FileSystemEntity.isDirectorySync(y));
46 Expect.isFalse(FileSystemEntity.isDirectorySync(x));
47 Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(y)) ;
Søren Gjesse 2013/03/08 09:38:50 Long line (two more below).
48 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(x));
49 Expect.equals(FileSystemEntityType.LINK,
50 FileSystemEntity.typeSync(y, followLinks: false));
51 Expect.equals(FileSystemEntityType.NOT_FOUND,
52 FileSystemEntity.typeSync(x, followLinks: false));
53
54 // Delete Junction pointing to a missing directory.
55 new Directory(y).deleteSync();
56 Expect.isFalse(FileSystemEntity.isLinkSync(y));
57 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y));
58
59 new Directory(x).createSync();
60 createJunction(x, y, () {
61 Expect.equals(FileSystemEntityType.LINK,
62 FileSystemEntity.typeSync(y, followLinks: false));
63 Expect.equals(FileSystemEntityType.DIRECTORY,
64 FileSystemEntity.typeSync(x, followLinks: false));
65
66 // Delete Junction pointing to an existing directory.
67 new Directory(y).deleteSync();
68 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y) );
69 Expect.equals(FileSystemEntityType.NOT_FOUND,
70 FileSystemEntity.typeSync(y, followLinks: false));
71 Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(x) );
72 Expect.equals(FileSystemEntityType.DIRECTORY,
73 FileSystemEntity.typeSync(x, followLinks: false));
74 temp.deleteSync(recursive: true);
75 });
76 });
77 }
78
79
80 main() {
81 if (Platform.operatingSystem == 'windows') {
82 testJunctionTypeDelete();
83 }
84 }
OLDNEW
« 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