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

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

Issue 12533008: dart:io | Add FileSystemEntity.typeSync to test for symbolic links. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add error-checking for arguments. Disable Windows implementation. 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 8
9 createLink(String dst, String link, bool symbolic, void callback()) { 9 createLink(String dst, String link, bool symbolic, void callback()) {
Bob Nystrom 2013/03/06 19:02:52 Would be nice if this worked on Windows too. :)
Bill Hesse 2013/03/07 09:53:12 That will be added with the Link class.
10 var args = [ symbolic ? '-s' : '', dst, link ]; 10 var args = [ symbolic ? '-s' : '', dst, link ];
11 var script = 'tests/standalone/io/ln.sh'; 11 var script = 'tests/standalone/io/ln.sh';
12 if (!new File(script).existsSync()) { 12 if (!new File(script).existsSync()) {
13 script = '../$script'; 13 script = '../$script';
14 } 14 }
15 Process.run(script, args).then((result) { 15 Process.run(script, args).then((result) {
16 if (result.exitCode == 0) { 16 if (result.exitCode == 0) {
17 callback(); 17 callback();
18 } else { 18 } else {
19 throw new Exception('link creation failed'); 19 throw new Exception('link creation failed');
20 } 20 }
21 }); 21 });
22 } 22 }
23 23
24 24
25 testFileExistsCreate() { 25 testFileExistsCreate() {
26 var temp = new Directory('').createTempSync(); 26 var temp = new Directory('').createTempSync();
27 var x = '${temp.path}${Platform.pathSeparator}x'; 27 var x = '${temp.path}${Platform.pathSeparator}x';
28 var y = '${temp.path}${Platform.pathSeparator}y'; 28 var y = '${temp.path}${Platform.pathSeparator}y';
29 createLink(x, y, true, () { 29 createLink(x, y, true, () {
30 Expect.isFalse(new File(y).existsSync());
30 Expect.isFalse(new File(x).existsSync()); 31 Expect.isFalse(new File(x).existsSync());
31 Expect.isFalse(new File(y).existsSync()); 32 Expect.isTrue(FileSystemEntity.isLinkSync(y));
33 Expect.isFalse(FileSystemEntity.isLinkSync(x));
34 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y));
35 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(x));
36 Expect.equals(FileSystemEntityType.LINK,
37 FileSystemEntity.typeSync(y, followLinks: false));
38 Expect.equals(FileSystemEntityType.NOT_FOUND,
39 FileSystemEntity.typeSync(x, followLinks: false));
40
32 new File(y).createSync(); 41 new File(y).createSync();
42 Expect.isTrue(new File(y).existsSync());
33 Expect.isTrue(new File(x).existsSync()); 43 Expect.isTrue(new File(x).existsSync());
34 Expect.isTrue(new File(y).existsSync()); 44 Expect.isTrue(FileSystemEntity.isLinkSync(y));
45 Expect.isFalse(FileSystemEntity.isLinkSync(x));
46 Expect.isTrue(FileSystemEntity.isFileSync(y));
47 Expect.isTrue(FileSystemEntity.isFileSync(x));
48 Expect.equals(FileSystemEntityType.FILE, FileSystemEntity.typeSync(y));
49 Expect.equals(FileSystemEntityType.FILE, FileSystemEntity.typeSync(x));
50 Expect.equals(FileSystemEntityType.LINK,
51 FileSystemEntity.typeSync(y, followLinks: false));
52 Expect.equals(FileSystemEntityType.FILE,
53 FileSystemEntity.typeSync(x, followLinks: false));
54 new File(x).deleteSync();
55 new Directory(x).createSync();
56 Expect.isTrue(FileSystemEntity.isLinkSync(y));
57 Expect.isFalse(FileSystemEntity.isLinkSync(x));
58 Expect.isTrue(FileSystemEntity.isDirectorySync(y));
59 Expect.isTrue(FileSystemEntity.isDirectorySync(x));
60 Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(y));
61 Expect.equals(FileSystemEntityType.DIRECTORY, FileSystemEntity.typeSync(x));
62 Expect.equals(FileSystemEntityType.LINK,
63 FileSystemEntity.typeSync(y, followLinks: false));
64 Expect.equals(FileSystemEntityType.DIRECTORY,
65 FileSystemEntity.typeSync(x, followLinks: false));
66
35 temp.deleteSync(recursive: true); 67 temp.deleteSync(recursive: true);
36 }); 68 });
37 } 69 }
38 70
39 71
40 testFileDelete() { 72 testFileDelete() {
41 var temp = new Directory('').createTempSync(); 73 var temp = new Directory('').createTempSync();
42 var x = '${temp.path}${Platform.pathSeparator}x'; 74 var x = '${temp.path}${Platform.pathSeparator}x';
43 var y = '${temp.path}${Platform.pathSeparator}y'; 75 var y = '${temp.path}${Platform.pathSeparator}y';
44 new File(x).createSync(); 76 new File(x).createSync();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 236
205 main() { 237 main() {
206 testFileExistsCreate(); 238 testFileExistsCreate();
207 testFileDelete(); 239 testFileDelete();
208 testFileWriteRead(); 240 testFileWriteRead();
209 testDirectoryExistsCreate(); 241 testDirectoryExistsCreate();
210 testDirectoryDelete(); 242 testDirectoryDelete();
211 testDirectoryListing(); 243 testDirectoryListing();
212 testDirectoryListingBrokenLink(); 244 testDirectoryListingBrokenLink();
213 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698