OLD | NEW |
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 library io_test; | 5 library io_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:pathos/path.dart' as path; | 9 import 'package:pathos/path.dart' as path; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 expect(withTempDir((temp) { | 112 expect(withTempDir((temp) { |
113 writeTextFile(path.join(temp, 'file1.txt'), ''); | 113 writeTextFile(path.join(temp, 'file1.txt'), ''); |
114 createSymlink(temp, path.join(temp, 'linkdir')); | 114 createSymlink(temp, path.join(temp, 'linkdir')); |
115 | 115 |
116 expect(listDir(temp, recursive: true), unorderedEquals([ | 116 expect(listDir(temp, recursive: true), unorderedEquals([ |
117 path.join(temp, 'file1.txt'), | 117 path.join(temp, 'file1.txt'), |
118 path.join(temp, 'linkdir') | 118 path.join(temp, 'linkdir') |
119 ])); | 119 ])); |
120 }), completes); | 120 }), completes); |
121 }); | 121 }); |
| 122 |
| 123 test('treats a broken symlink as a file', () { |
| 124 expect(withTempDir((temp) { |
| 125 writeTextFile(path.join(temp, 'file1.txt'), ''); |
| 126 createDir(path.join(temp, 'dir')); |
| 127 createSymlink(path.join(temp, 'dir'), path.join(temp, 'linkdir')); |
| 128 deleteEntry(path.join(temp, 'dir')); |
| 129 |
| 130 expect(listDir(temp, recursive: true), unorderedEquals([ |
| 131 path.join(temp, 'file1.txt'), |
| 132 path.join(temp, 'linkdir') |
| 133 ])); |
| 134 }), completes); |
| 135 }); |
122 }); | 136 }); |
123 | 137 |
124 testExistencePredicate("entryExists", entryExists, | 138 testExistencePredicate("entryExists", entryExists, |
125 forFile: true, | 139 forFile: true, |
126 forFileSymlink: true, | 140 forFileSymlink: true, |
127 forMultiLevelFileSymlink: true, | 141 forMultiLevelFileSymlink: true, |
128 forDirectory: true, | 142 forDirectory: true, |
129 forDirectorySymlink: true, | 143 forDirectorySymlink: true, |
130 forMultiLevelDirectorySymlink: true, | 144 forMultiLevelDirectorySymlink: true, |
131 forBrokenSymlink: true, | 145 forBrokenSymlink: true, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 var symlink2Path = path.join(temp, "link2.txt"); | 271 var symlink2Path = path.join(temp, "link2.txt"); |
258 writeTextFile(targetPath, "contents"); | 272 writeTextFile(targetPath, "contents"); |
259 createSymlink(targetPath, symlink1Path); | 273 createSymlink(targetPath, symlink1Path); |
260 createSymlink(symlink1Path, symlink2Path); | 274 createSymlink(symlink1Path, symlink2Path); |
261 expect(predicate(symlink2Path), equals(forMultiLevelFileSymlink)); | 275 expect(predicate(symlink2Path), equals(forMultiLevelFileSymlink)); |
262 }), completes); | 276 }), completes); |
263 }); | 277 }); |
264 } | 278 } |
265 }); | 279 }); |
266 } | 280 } |
OLD | NEW |