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

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

Issue 11364097: Allow Directory.create to create all missing path components. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload Created 8 years, 1 month 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 // Dart test program for testing error handling in directory I/O. 5 // Dart test program for testing error handling in directory I/O.
6 6
7 #import("dart:io"); 7 #import("dart:io");
8 #import("dart:isolate"); 8 #import("dart:isolate");
9 9
10 Directory tempDir() { 10 Directory tempDir() {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 "The system cannot find the path specified") != -1); 130 "The system cannot find the path specified") != -1);
131 Expect.equals(3, e.osError.errorCode); 131 Expect.equals(3, e.osError.errorCode);
132 } 132 }
133 133
134 return true; 134 return true;
135 } 135 }
136 136
137 137
138 void testDeleteRecursivelyNonExistent(Directory temp, Function done) { 138 void testDeleteRecursivelyNonExistent(Directory temp, Function done) {
139 Directory nonExistent = new Directory("${temp.path}/nonExistent"); 139 Directory nonExistent = new Directory("${temp.path}/nonExistent");
140 Expect.throws(() => nonExistent.deleteRecursivelySync(), 140 Expect.throws(() => nonExistent.deleteSync(recursive: true),
141 (e) => checkDeleteRecursivelyNonExistentFileException(e)); 141 (e) => checkDeleteRecursivelyNonExistentFileException(e));
142 142
143 nonExistent.deleteRecursively().handleException((e) { 143 nonExistent.delete(recursive: true).handleException((e) {
144 checkDeleteRecursivelyNonExistentFileException(e); 144 checkDeleteRecursivelyNonExistentFileException(e);
145 done(); 145 done();
146 return true; 146 return true;
147 }); 147 });
148 } 148 }
149 149
150 150
151 bool checkListNonExistentFileException(e) { 151 bool checkListNonExistentFileException(e) {
152 Expect.isTrue(e is DirectoryIOException); 152 Expect.isTrue(e is DirectoryIOException);
153 Expect.isTrue(e.osError != null); 153 Expect.isTrue(e.osError != null);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 var d = new Directory(''); 215 var d = new Directory('');
216 var temp1 = d.createTempSync(); 216 var temp1 = d.createTempSync();
217 var fileName = '${temp.path}/x'; 217 var fileName = '${temp.path}/x';
218 new File(fileName).createSync(); 218 new File(fileName).createSync();
219 Expect.throws(() => temp1.renameSync(fileName), 219 Expect.throws(() => temp1.renameSync(fileName),
220 (e) => e is DirectoryIOException); 220 (e) => e is DirectoryIOException);
221 var renameDone = temp1.rename(fileName); 221 var renameDone = temp1.rename(fileName);
222 renameDone.then((ignore) => Expect.fail('rename dir overwrite file')); 222 renameDone.then((ignore) => Expect.fail('rename dir overwrite file'));
223 renameDone.handleException((e) { 223 renameDone.handleException((e) {
224 Expect.isTrue(e is DirectoryIOException); 224 Expect.isTrue(e is DirectoryIOException);
225 temp1.deleteRecursivelySync(); 225 temp1.deleteSync(recursive: true);
226 done(); 226 done();
227 return true; 227 return true;
228 }); 228 });
229 } 229 }
230 230
231 231
232 void runTest(Function test) { 232 void runTest(Function test) {
233 // Create a temporary directory for the test. 233 // Create a temporary directory for the test.
234 var temp = new Directory('').createTempSync(); 234 var temp = new Directory('').createTempSync();
235 235
236 // Wait for the test to finish and delete the temporary directory. 236 // Wait for the test to finish and delete the temporary directory.
237 ReceivePort p = new ReceivePort(); 237 ReceivePort p = new ReceivePort();
238 p.receive((x,y) { 238 p.receive((x,y) {
239 p.close(); 239 p.close();
240 temp.deleteRecursivelySync(); 240 temp.deleteSync(recursive: true);
241 }); 241 });
242 242
243 // Run the test. 243 // Run the test.
244 test(temp, () => p.toSendPort().send(null)); 244 test(temp, () => p.toSendPort().send(null));
245 } 245 }
246 246
247 247
248 main() { 248 main() {
249 runTest(testCreateInNonExistent); 249 runTest(testCreateInNonExistent);
250 runTest(testCreateTempInNonExistent); 250 runTest(testCreateTempInNonExistent);
251 runTest(testDeleteNonExistent); 251 runTest(testDeleteNonExistent);
252 runTest(testDeleteRecursivelyNonExistent); 252 runTest(testDeleteRecursivelyNonExistent);
253 runTest(testListNonExistent); 253 runTest(testListNonExistent);
254 runTest(testRenameNonExistent); 254 runTest(testRenameNonExistent);
255 runTest(testRenameFileAsDirectory); 255 runTest(testRenameFileAsDirectory);
256 runTest(testRenameOverwriteFile); 256 runTest(testRenameOverwriteFile);
257 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698