| OLD | NEW |
| 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 // Directory listing test that tests listSync on a missing directory. | 5 // Directory listing test that tests listSync on a missing directory. |
| 6 // | 6 // |
| 7 // TODO(7157): Merge this test into directory_test.dart testListNonExistent() | 7 // TODO(7157): Merge this test into directory_test.dart testListNonExistent() |
| 8 // when it no longer crashes on Windows, when issue 7157 is resolved. | 8 // when it no longer crashes on Windows, when issue 7157 is resolved. |
| 9 | 9 |
| 10 import "dart:io"; | 10 import "dart:io"; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 void testListTooLongName() { | 25 void testListTooLongName() { |
| 26 var keepAlive = new ReceivePort(); | 26 var keepAlive = new ReceivePort(); |
| 27 new Directory("").createTemp().then((d) { | 27 new Directory("").createTemp().then((d) { |
| 28 var subDirName = 'subdir'; | 28 var subDirName = 'subdir'; |
| 29 var subDir = new Directory("${d.path}/$subDirName"); | 29 var subDir = new Directory("${d.path}/$subDirName"); |
| 30 subDir.create().then((ignore) { | 30 subDir.create().then((ignore) { |
| 31 // Construct a long string of the form | 31 // Construct a long string of the form |
| 32 // 'tempdir/subdir/../subdir/../subdir'. | 32 // 'tempdir/subdir/../subdir/../subdir'. |
| 33 var buffer = new StringBuffer(); | 33 var buffer = new StringBuffer(); |
| 34 buffer.add(subDir.path); | 34 buffer.write(subDir.path); |
| 35 for (var i = 0; i < 1000; i++) { | 35 for (var i = 0; i < 1000; i++) { |
| 36 buffer.add("/../${subDirName}"); | 36 buffer.write("/../${subDirName}"); |
| 37 } | 37 } |
| 38 var long = new Directory("${buffer.toString()}"); | 38 var long = new Directory("${buffer.toString()}"); |
| 39 Expect.throws(() => long.listSync(), | 39 Expect.throws(() => long.listSync(), |
| 40 (e) => e is DirectoryIOException); | 40 (e) => e is DirectoryIOException); |
| 41 Expect.throws(() => long.listSync(recursive: true), | 41 Expect.throws(() => long.listSync(recursive: true), |
| 42 (e) => e is DirectoryIOException); | 42 (e) => e is DirectoryIOException); |
| 43 d.deleteSync(recursive: true); | 43 d.deleteSync(recursive: true); |
| 44 keepAlive.close(); | 44 keepAlive.close(); |
| 45 }); | 45 }); |
| 46 }); | 46 }); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void main() { | 49 void main() { |
| 50 testListNonExistent(); | 50 testListNonExistent(); |
| 51 testListTooLongName(); | 51 testListTooLongName(); |
| 52 } | 52 } |
| OLD | NEW |