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 '../../../pkg/path/lib/path.dart' as path; | 7 import '../../../pkg/path/lib/path.dart' as path; |
8 import '../../../pkg/unittest/lib/unittest.dart'; | 8 import '../../../pkg/unittest/lib/unittest.dart'; |
9 | 9 |
10 import '../../pub/io.dart'; | 10 import '../../pub/io.dart'; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 test('returns the unresolved paths for symlinks', () { | 95 test('returns the unresolved paths for symlinks', () { |
96 expect(withTempDir((temp) { | 96 expect(withTempDir((temp) { |
97 var dirToList = path.join(temp, 'dir-to-list'); | 97 var dirToList = path.join(temp, 'dir-to-list'); |
98 var future = defer(() { | 98 var future = defer(() { |
99 createDir(path.join(temp, 'dir1')); | 99 createDir(path.join(temp, 'dir1')); |
100 writeTextFile(path.join(temp, 'dir1', 'file1.txt'), ''); | 100 writeTextFile(path.join(temp, 'dir1', 'file1.txt'), ''); |
101 createDir(path.join(temp, 'dir2')); | 101 createDir(path.join(temp, 'dir2')); |
102 writeTextFile(path.join(temp, 'dir2', 'file2.txt'), ''); | 102 writeTextFile(path.join(temp, 'dir2', 'file2.txt'), ''); |
103 createDir(dirToList); | 103 createDir(dirToList); |
104 return createSymlink(path.join(temp, 'dir1'), | 104 return createSymlink(path.join(dirToList, 'linked-dir1'), |
105 path.join(dirToList, 'linked-dir1')); | 105 path.join(temp, 'dir1')); |
106 }).then((_) { | 106 }).then((_) { |
107 createDir(path.join(dirToList, 'subdir')); | 107 createDir(path.join(dirToList, 'subdir')); |
108 return createSymlink( | 108 return createSymlink( |
109 path.join(temp, 'dir2'), | 109 path.join(dirToList, 'subdir', 'linked-dir2'), |
110 path.join(dirToList, 'subdir', 'linked-dir2')); | 110 path.join(temp, 'dir2')); |
111 }).then((_) => listDir(dirToList, recursive: true)); | 111 }).then((_) => listDir(dirToList, recursive: true)); |
112 expect(future, completion(unorderedEquals([ | 112 expect(future, completion(unorderedEquals([ |
113 path.join(dirToList, 'linked-dir1'), | 113 path.join(dirToList, 'linked-dir1'), |
114 path.join(dirToList, 'linked-dir1', 'file1.txt'), | 114 path.join(dirToList, 'linked-dir1', 'file1.txt'), |
115 path.join(dirToList, 'subdir'), | 115 path.join(dirToList, 'subdir'), |
116 path.join(dirToList, 'subdir', 'linked-dir2'), | 116 path.join(dirToList, 'subdir', 'linked-dir2'), |
117 path.join(dirToList, 'subdir', 'linked-dir2', 'file2.txt'), | 117 path.join(dirToList, 'subdir', 'linked-dir2', 'file2.txt'), |
118 ]))); | 118 ]))); |
119 return future; | 119 return future; |
120 }), completes); | 120 }), completes); |
121 }); | 121 }); |
122 | 122 |
123 test('works with recursive symlinks', () { | 123 test('works with recursive symlinks', () { |
124 expect(withTempDir((temp) { | 124 expect(withTempDir((temp) { |
125 var future = defer(() { | 125 var future = defer(() { |
126 writeTextFile(path.join(temp, 'file1.txt'), ''); | 126 writeTextFile(path.join(temp, 'file1.txt'), ''); |
127 return createSymlink(temp, path.join(temp, 'linkdir')); | 127 return createSymlink(path.join(temp, 'linkdir'), temp); |
128 }).then((_) => listDir(temp, recursive: true)); | 128 }).then((_) => listDir(temp, recursive: true)); |
129 expect(future, completion(unorderedEquals([ | 129 expect(future, completion(unorderedEquals([ |
130 path.join(temp, 'file1.txt'), | 130 path.join(temp, 'file1.txt'), |
131 path.join(temp, 'linkdir') | 131 path.join(temp, 'linkdir') |
132 ]))); | 132 ]))); |
133 return future; | 133 return future; |
134 }), completes); | 134 }), completes); |
135 }); | 135 }); |
136 }); | 136 }); |
137 } | 137 } |
OLD | NEW |