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

Side by Side Diff: tests/standalone/io/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: Implement Link.CreateSync, use it in file_system_links_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 unified diff | Download patch | Annotate | Revision Log
« sdk/lib/io/link.dart ('K') | « sdk/lib/io/link.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) 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()) {
nweiz 2013/03/08 20:26:41 The "symbolic" parameter no longer means anything.
Bill Hesse 2013/03/11 09:25:59 Removed. This removes a test for hard linking, bu
10 var args = [ symbolic ? '-s' : '', dst, link ]; 10 new Link(link).create(dst, linkRelative: true).then((_) => callback());
11 var script = 'tests/standalone/io/ln.sh';
12 if (!new File(script).existsSync()) {
13 script = '../$script';
14 }
15 Process.run(script, args).then((result) {
16 if (result.exitCode == 0) {
17 callback();
18 } else {
19 throw new Exception('link creation failed');
20 }
21 });
22 } 11 }
23 12
24 13
25 testFileExistsCreate() { 14 testFileExistsCreate() {
26 var temp = new Directory('').createTempSync(); 15 var temp = new Directory('').createTempSync();
27 var x = '${temp.path}${Platform.pathSeparator}x'; 16 var x = '${temp.path}${Platform.pathSeparator}x';
28 var y = '${temp.path}${Platform.pathSeparator}y'; 17 var y = '${temp.path}${Platform.pathSeparator}y';
29 createLink(x, y, true, () { 18 createLink(x, y, true, () {
30 Expect.isFalse(new File(y).existsSync()); 19 Expect.isFalse(new File(y).existsSync());
nweiz 2013/03/08 20:26:41 It's a little weird to me that all these File APIs
Bill Hesse 2013/03/11 09:25:59 Done.
31 Expect.isFalse(new File(x).existsSync()); 20 Expect.isFalse(new File(x).existsSync());
32 Expect.isTrue(FileSystemEntity.isLinkSync(y)); 21 Expect.isTrue(FileSystemEntity.isLinkSync(y));
33 Expect.isFalse(FileSystemEntity.isLinkSync(x)); 22 Expect.isFalse(FileSystemEntity.isLinkSync(x));
34 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y)); 23 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y));
35 Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(x)); 24 Expect.equals(FileSystemEntityType.NOT_FOUND, 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.NOT_FOUND, 27 Expect.equals(FileSystemEntityType.NOT_FOUND,
39 FileSystemEntity.typeSync(x, followLinks: false)); 28 FileSystemEntity.typeSync(x, followLinks: false));
40 29
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 testDirectoryListing() { 148 testDirectoryListing() {
160 var keepAlive = new ReceivePort(); 149 var keepAlive = new ReceivePort();
161 var temp = new Directory('').createTempSync(); 150 var temp = new Directory('').createTempSync();
162 var temp2 = new Directory('').createTempSync(); 151 var temp2 = new Directory('').createTempSync();
163 var y = '${temp.path}${Platform.pathSeparator}y'; 152 var y = '${temp.path}${Platform.pathSeparator}y';
164 var x = '${temp2.path}${Platform.pathSeparator}x'; 153 var x = '${temp2.path}${Platform.pathSeparator}x';
165 new File(x).createSync(); 154 new File(x).createSync();
166 createLink(temp2.path, y, true, () { 155 createLink(temp2.path, y, true, () {
167 var files = []; 156 var files = [];
168 var dirs = []; 157 var dirs = [];
169 for (var entry in temp.listSync(recursive:true)) { 158 for (var entry in temp.listSync(recursive:true)) {
nweiz 2013/03/08 20:26:41 Shouldn't list start returning Links now?
Bill Hesse 2013/03/11 09:25:59 This will occur in a later change. It should be m
170 if (entry is File) { 159 if (entry is File) {
171 files.add(entry.path); 160 files.add(entry.path);
172 } else { 161 } else {
173 Expect.isTrue(entry is Directory); 162 Expect.isTrue(entry is Directory);
174 dirs.add(entry.path); 163 dirs.add(entry.path);
175 } 164 }
176 } 165 }
177 Expect.equals(1, files.length); 166 Expect.equals(1, files.length);
178 Expect.isTrue(files[0].endsWith('$y${Platform.pathSeparator}x')); 167 Expect.isTrue(files[0].endsWith('$y${Platform.pathSeparator}x'));
179 Expect.equals(1, dirs.length); 168 Expect.equals(1, dirs.length);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 229
241 230
242 main() { 231 main() {
243 testFileExistsCreate(); 232 testFileExistsCreate();
244 testFileDelete(); 233 testFileDelete();
245 testFileWriteRead(); 234 testFileWriteRead();
246 testDirectoryExistsCreate(); 235 testDirectoryExistsCreate();
247 testDirectoryDelete(); 236 testDirectoryDelete();
248 testDirectoryListing(); 237 testDirectoryListing();
249 testDirectoryListingBrokenLink(); 238 testDirectoryListingBrokenLink();
250 } 239 }
nweiz 2013/03/08 20:26:41 I assume you're planning on adding a bunch more te
OLDNEW
« sdk/lib/io/link.dart ('K') | « sdk/lib/io/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698