OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // |
| 5 // Directory listing test that tests listSync on a missing directory. |
| 6 // |
| 7 // TODO(7157): Merge this test into directory_test.dart testListNonExistent() |
| 8 // when it no longer crashes on Windows, when issue 7157 is resolved. |
| 9 |
| 10 import "dart:io"; |
| 11 import "dart:isolate"; |
| 12 |
| 13 void testListNonExistent() { |
| 14 new Directory("").createTemp().then((d) { |
| 15 d.delete().then((ignore) { |
| 16 Expect.throws(() => d.listSync(), (e) => e is DirectoryIOException); |
| 17 Expect.throws(() => d.listSync(recursive: true), |
| 18 (e) => e is DirectoryIOException); |
| 19 }); |
| 20 }); |
| 21 } |
| 22 |
| 23 void testListTooLongName() { |
| 24 new Directory("").createTemp().then((d) { |
| 25 var subDirName = 'subdir'; |
| 26 var subDir = new Directory("${d.path}/$subDirName"); |
| 27 subDir.create().then((ignore) { |
| 28 // Construct a long string of the form |
| 29 // 'tempdir/subdir/../subdir/../subdir'. |
| 30 var buffer = new StringBuffer(); |
| 31 buffer.add(subDir.path); |
| 32 for (var i = 0; i < 1000; i++) { |
| 33 buffer.add("/../${subDirName}"); |
| 34 } |
| 35 var long = new Directory("${buffer.toString()}"); |
| 36 Expect.throws(() => long.listSync(), |
| 37 (e) => e is DirectoryIOException); |
| 38 Expect.throws(() => long.listSync(recursive: true), |
| 39 (e) => e is DirectoryIOException); |
| 40 }); |
| 41 }); |
| 42 } |
| 43 |
| 44 void main() { |
| 45 testListNonExistent(); |
| 46 testListTooLongName(); |
| 47 } |
OLD | NEW |