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

Side by Side Diff: utils/tests/pub/io_test.dart

Issue 13132002: Version 0.4.3.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 7 years, 8 months 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
« no previous file with comments | « utils/tests/pub/install/pub_install_test.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library io_test; 5 library io_test;
6 6
7 import 'dart:io';
8
7 import '../../../pkg/pathos/lib/path.dart' as path; 9 import '../../../pkg/pathos/lib/path.dart' as path;
8 import '../../../pkg/unittest/lib/unittest.dart'; 10 import '../../../pkg/unittest/lib/unittest.dart';
9 11
10 import '../../pub/io.dart'; 12 import '../../pub/io.dart';
11 import '../../pub/utils.dart'; 13 import '../../pub/utils.dart';
12 import 'test_pub.dart'; 14 import 'test_pub.dart';
13 15
14 main() { 16 main() {
15 initConfig(); 17 initConfig();
16 18
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return createSymlink(temp, path.join(temp, 'linkdir')); 129 return createSymlink(temp, path.join(temp, 'linkdir'));
128 }).then((_) => listDir(temp, recursive: true)); 130 }).then((_) => listDir(temp, recursive: true));
129 expect(future, completion(unorderedEquals([ 131 expect(future, completion(unorderedEquals([
130 path.join(temp, 'file1.txt'), 132 path.join(temp, 'file1.txt'),
131 path.join(temp, 'linkdir') 133 path.join(temp, 'linkdir')
132 ]))); 134 ])));
133 return future; 135 return future;
134 }), completes); 136 }), completes);
135 }); 137 });
136 }); 138 });
139
140 testExistencePredicate("entryExists", entryExists,
141 forFile: true,
142 forFileSymlink: true,
143 forMultiLevelFileSymlink: true,
144 forDirectory: true,
145 forDirectorySymlink: true,
146 forMultiLevelDirectorySymlink: true,
147 forBrokenSymlink: true,
148 forMultiLevelBrokenSymlink: true);
149
150 testExistencePredicate("linkExists", linkExists,
151 forFile: false,
152 forFileSymlink: true,
153 forMultiLevelFileSymlink: true,
154 forDirectory: false,
155 forDirectorySymlink: true,
156 forMultiLevelDirectorySymlink: true,
157 forBrokenSymlink: true,
158 forMultiLevelBrokenSymlink: true);
159
160 testExistencePredicate("fileExists", fileExists,
161 forFile: true,
162 forFileSymlink: true,
163 forMultiLevelFileSymlink: true,
164 forDirectory: false,
165 forDirectorySymlink: false,
166 forMultiLevelDirectorySymlink: false,
167 forBrokenSymlink: false,
168 forMultiLevelBrokenSymlink: false);
169
170 testExistencePredicate("dirExists", dirExists,
171 forFile: false,
172 forFileSymlink: false,
173 forMultiLevelFileSymlink: false,
174 forDirectory: true,
175 forDirectorySymlink: true,
176 forMultiLevelDirectorySymlink: true,
177 forBrokenSymlink: false,
178 forMultiLevelBrokenSymlink: false);
137 } 179 }
180
181 void testExistencePredicate(String name, bool predicate(String path),
182 {bool forFile,
183 bool forFileSymlink,
184 bool forMultiLevelFileSymlink,
185 bool forDirectory,
186 bool forDirectorySymlink,
187 bool forMultiLevelDirectorySymlink,
188 bool forBrokenSymlink,
189 bool forMultiLevelBrokenSymlink}) {
190 group(name, () {
191 test('returns $forFile for a file', () {
192 expect(withTempDir((temp) {
193 var path = path.join(temp, "test.txt");
194 writeTextFile(path, "contents");
195 expect(predicate(path), equals(forFile));
196 }), completes);
197 });
198
199 test('returns $forDirectory for a directory', () {
200 expect(withTempDir((temp) {
201 var path = path.join(temp, "dir");
202 createDir(path);
203 expect(predicate(path), equals(forDirectory));
204 }), completes);
205 });
206
207 test('returns $forDirectorySymlink for a symlink to a directory', () {
208 expect(withTempDir((temp) {
209 var targetPath = path.join(temp, "dir");
210 var symlinkPath = path.join(temp, "linkdir");
211 createDir(targetPath);
212 return createSymlink(targetPath, symlinkPath).then((_) {
213 expect(predicate(symlinkPath), equals(forDirectorySymlink));
214 });
215 }), completes);
216 });
217
218 test('returns $forMultiLevelDirectorySymlink for a multi-level symlink to '
219 'a directory', () {
220 expect(withTempDir((temp) {
221 var targetPath = path.join(temp, "dir");
222 var symlink1Path = path.join(temp, "link1dir");
223 var symlink2Path = path.join(temp, "link2dir");
224 createDir(targetPath);
225 return createSymlink(targetPath, symlink1Path)
226 .then((_) => createSymlink(symlink1Path, symlink2Path))
227 .then((_) {
228 expect(predicate(symlink2Path),
229 equals(forMultiLevelDirectorySymlink));
230 });
231 }), completes);
232 });
233
234 test('returns $forBrokenSymlink for a broken symlink', () {
235 expect(withTempDir((temp) {
236 var targetPath = path.join(temp, "dir");
237 var symlinkPath = path.join(temp, "linkdir");
238 createDir(targetPath);
239 return createSymlink(targetPath, symlinkPath).then((_) {
240 deleteEntry(targetPath);
241 expect(predicate(symlinkPath), equals(forBrokenSymlink));
242 });
243 }), completes);
244 });
245
246 test('returns $forMultiLevelBrokenSymlink for a multi-level broken symlink',
247 () {
248 expect(withTempDir((temp) {
249 var targetPath = path.join(temp, "dir");
250 var symlink1Path = path.join(temp, "link1dir");
251 var symlink2Path = path.join(temp, "link2dir");
252 createDir(targetPath);
253 return createSymlink(targetPath, symlink1Path)
254 .then((_) => createSymlink(symlink1Path, symlink2Path))
255 .then((_) {
256 deleteEntry(targetPath);
257 expect(predicate(symlink2Path), equals(forMultiLevelBrokenSymlink));
258 });
259 }), completes);
260 });
261
262 // Windows doesn't support symlinking to files.
263 if (Platform.operatingSystem != 'windows') {
264 test('returns $forFileSymlink for a symlink to a file', () {
265 expect(withTempDir((temp) {
266 var targetPath = path.join(temp, "test.txt");
267 var symlinkPath = path.join(temp, "link.txt");
268 writeTextFile(targetPath, "contents");
269 return createSymlink(targetPath, symlinkPath).then((_) {
270 expect(predicate(symlinkPath), equals(forFileSymlink));
271 });
272 }), completes);
273 });
274
275 test('returns $forMultiLevelFileSymlink for a multi-level symlink to a '
276 'file', () {
277 expect(withTempDir((temp) {
278 var targetPath = path.join(temp, "test.txt");
279 var symlink1Path = path.join(temp, "link1.txt");
280 var symlink2Path = path.join(temp, "link2.txt");
281 writeTextFile(targetPath, "contents");
282 return createSymlink(targetPath, symlink1Path)
283 .then((_) => createSymlink(symlink1Path, symlink2Path))
284 .then((_) {
285 expect(predicate(symlink2Path), equals(forMultiLevelFileSymlink));
286 });
287 }), completes);
288 });
289 }
290 });
291 }
OLDNEW
« no previous file with comments | « utils/tests/pub/install/pub_install_test.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698