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

Side by Side Diff: tests/standalone/io/windows_file_system_links_test.dart

Issue 12691002: dart:io | Add Link class, as sibling to File and Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows errors 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 | « tests/standalone/io/link_test.dart ('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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:io"; 5 import "dart:io";
6 import "dart:isolate"; 6 import "dart:isolate";
7 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() { 8 testJunctionTypeDelete() {
20 var temp = new Directory('').createTempSync(); 9 var temp = new Directory('').createTempSync();
21 var x = '${temp.path}${Platform.pathSeparator}x'; 10 var x = '${temp.path}${Platform.pathSeparator}x';
22 var y = '${temp.path}${Platform.pathSeparator}y'; 11 var y = '${temp.path}${Platform.pathSeparator}y';
23 12
24 new Directory(x).createSync(); 13 new Directory(x).createSync();
25 createJunction(x, y, () { 14 new Link(y).create(x).then((_) {
26 Expect.isTrue(new Directory(y).existsSync()); 15 Expect.isTrue(new Directory(y).existsSync());
27 Expect.isTrue(new Directory(x).existsSync()); 16 Expect.isTrue(new Directory(x).existsSync());
28 Expect.isTrue(FileSystemEntity.isLinkSync(y)); 17 Expect.isTrue(FileSystemEntity.isLinkSync(y));
29 Expect.isFalse(FileSystemEntity.isLinkSync(x)); 18 Expect.isFalse(FileSystemEntity.isLinkSync(x));
30 Expect.isTrue(FileSystemEntity.isDirectorySync(y)); 19 Expect.isTrue(FileSystemEntity.isDirectorySync(y));
31 Expect.isTrue(FileSystemEntity.isDirectorySync(x)); 20 Expect.isTrue(FileSystemEntity.isDirectorySync(x));
32 Expect.equals(FileSystemEntityType.DIRECTORY, 21 Expect.equals(FileSystemEntityType.DIRECTORY,
33 FileSystemEntity.typeSync(y)); 22 FileSystemEntity.typeSync(y));
34 Expect.equals(FileSystemEntityType.DIRECTORY, 23 Expect.equals(FileSystemEntityType.DIRECTORY,
35 FileSystemEntity.typeSync(x)); 24 FileSystemEntity.typeSync(x));
36 Expect.equals(FileSystemEntityType.LINK, 25 Expect.equals(FileSystemEntityType.LINK,
37 FileSystemEntity.typeSync(y, followLinks: false)); 26 FileSystemEntity.typeSync(y, followLinks: false));
38 Expect.equals(FileSystemEntityType.DIRECTORY, 27 Expect.equals(FileSystemEntityType.DIRECTORY,
39 FileSystemEntity.typeSync(x, followLinks: false)); 28 FileSystemEntity.typeSync(x, followLinks: false));
40
41 // Test Junction pointing to a missing directory. 29 // Test Junction pointing to a missing directory.
42 new Directory(x).deleteSync(); 30 new Directory(x).deleteSync();
43 Expect.isTrue(new Directory(y).existsSync()); 31 Expect.isTrue(new Directory(y).existsSync());
44 Expect.isFalse(new Directory(x).existsSync()); 32 Expect.isFalse(new Directory(x).existsSync());
45 Expect.isTrue(FileSystemEntity.isLinkSync(y)); 33 Expect.isTrue(FileSystemEntity.isLinkSync(y));
46 Expect.isFalse(FileSystemEntity.isLinkSync(x)); 34 Expect.isFalse(FileSystemEntity.isLinkSync(x));
47 Expect.isTrue(FileSystemEntity.isDirectorySync(y)); 35 Expect.isTrue(FileSystemEntity.isDirectorySync(y));
48 Expect.isFalse(FileSystemEntity.isDirectorySync(x)); 36 Expect.isFalse(FileSystemEntity.isDirectorySync(x));
49 Expect.equals(FileSystemEntityType.DIRECTORY, 37 Expect.equals(FileSystemEntityType.DIRECTORY,
50 FileSystemEntity.typeSync(y)); 38 FileSystemEntity.typeSync(y));
51 Expect.equals(FileSystemEntityType.NOT_FOUND, 39 Expect.equals(FileSystemEntityType.NOT_FOUND,
52 FileSystemEntity.typeSync(x)); 40 FileSystemEntity.typeSync(x));
53 Expect.equals(FileSystemEntityType.LINK, 41 Expect.equals(FileSystemEntityType.LINK,
54 FileSystemEntity.typeSync(y, followLinks: false)); 42 FileSystemEntity.typeSync(y, followLinks: false));
55 Expect.equals(FileSystemEntityType.NOT_FOUND, 43 Expect.equals(FileSystemEntityType.NOT_FOUND,
56 FileSystemEntity.typeSync(x, followLinks: false)); 44 FileSystemEntity.typeSync(x, followLinks: false));
57 45
58 // Delete Junction pointing to a missing directory. 46 // Delete Junction pointing to a missing directory.
59 new Directory(y).deleteSync(); 47 new Directory(y).deleteSync();
60 Expect.isFalse(FileSystemEntity.isLinkSync(y)); 48 Expect.isFalse(FileSystemEntity.isLinkSync(y));
61 Expect.equals(FileSystemEntityType.NOT_FOUND, 49 Expect.equals(FileSystemEntityType.NOT_FOUND,
62 FileSystemEntity.typeSync(y)); 50 FileSystemEntity.typeSync(y));
63 51
64 new Directory(x).createSync(); 52 new Directory(x).createSync();
65 createJunction(x, y, () { 53 new Link(y).create(x).then((_) {
66 Expect.equals(FileSystemEntityType.LINK, 54 Expect.equals(FileSystemEntityType.LINK,
67 FileSystemEntity.typeSync(y, followLinks: false)); 55 FileSystemEntity.typeSync(y, followLinks: false));
68 Expect.equals(FileSystemEntityType.DIRECTORY, 56 Expect.equals(FileSystemEntityType.DIRECTORY,
69 FileSystemEntity.typeSync(x, followLinks: false)); 57 FileSystemEntity.typeSync(x, followLinks: false));
70 58
71 // Delete Junction pointing to an existing directory. 59 // Delete Junction pointing to an existing directory.
72 new Directory(y).deleteSync(); 60 new Directory(y).deleteSync();
73 Expect.equals(FileSystemEntityType.NOT_FOUND, 61 Expect.equals(FileSystemEntityType.NOT_FOUND,
74 FileSystemEntity.typeSync(y)); 62 FileSystemEntity.typeSync(y));
75 Expect.equals(FileSystemEntityType.NOT_FOUND, 63 Expect.equals(FileSystemEntityType.NOT_FOUND,
76 FileSystemEntity.typeSync(y, followLinks: false)); 64 FileSystemEntity.typeSync(y, followLinks: false));
77 Expect.equals(FileSystemEntityType.DIRECTORY, 65 Expect.equals(FileSystemEntityType.DIRECTORY,
78 FileSystemEntity.typeSync(x)); 66 FileSystemEntity.typeSync(x));
79 Expect.equals(FileSystemEntityType.DIRECTORY, 67 Expect.equals(FileSystemEntityType.DIRECTORY,
80 FileSystemEntity.typeSync(x, followLinks: false)); 68 FileSystemEntity.typeSync(x, followLinks: false));
81 temp.deleteSync(recursive: true); 69 temp.deleteSync(recursive: true);
82 }); 70 });
83 }); 71 });
84 } 72 }
85 73
86 74
87 main() { 75 main() {
88 if (Platform.operatingSystem == 'windows') { 76 if (Platform.operatingSystem == 'windows') {
89 testJunctionTypeDelete(); 77 testJunctionTypeDelete();
90 } 78 }
91 } 79 }
OLDNEW
« no previous file with comments | « tests/standalone/io/link_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698