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

Side by Side Diff: tests/standalone/io/link_async_test.dart

Issue 25471003: Modify tests to use Directory.systemTemp (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 7 years, 2 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 | « tests/standalone/io/http_headers_test.dart ('k') | tests/standalone/io/link_test.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) 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 import "dart:async"; 5 import "dart:async";
6 import "dart:io"; 6 import "dart:io";
7 7
8 import "package:async_helper/async_helper.dart"; 8 import "package:async_helper/async_helper.dart";
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import "package:path/path.dart"; 10 import "package:path/path.dart";
(...skipping 11 matching lines...) Expand all
22 result.then((value) => Expect.listEquals(expected, value)); 22 result.then((value) => Expect.listEquals(expected, value));
23 static Future throws(Future result) => 23 static Future throws(Future result) =>
24 result.then((value) { 24 result.then((value) {
25 throw new ExpectException( 25 throw new ExpectException(
26 "FutureExpect.throws received $value instead of an exception"); 26 "FutureExpect.throws received $value instead of an exception");
27 }, onError: (_) => null); 27 }, onError: (_) => null);
28 } 28 }
29 29
30 30
31 Future testCreate() { 31 Future testCreate() {
32 return new Directory('').createTemp().then((baseDir) { 32 return Directory.systemTemp.createTemp('dart_link_async').then((baseDir) {
33 if (isRelative(baseDir.path)) {
34 Expect.fail(
35 'Link tests expect absolute paths to system temporary directories. '
36 'A relative path in TMPDIR gives relative paths to them.');
37 }
33 String base = baseDir.path; 38 String base = baseDir.path;
34 String link = join(base, 'link'); 39 String link = join(base, 'link');
35 String target = join(base, 'target'); 40 String target = join(base, 'target');
36 return new Directory(target).create() 41 return new Directory(target).create()
37 .then((_) => new Link(link).create(target)) 42 .then((_) => new Link(link).create(target))
38 43
39 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY, 44 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
40 FileSystemEntity.type(link))) 45 FileSystemEntity.type(link)))
41 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY, 46 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
42 FileSystemEntity.type(target))) 47 FileSystemEntity.type(target)))
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 139 }
135 return Future.wait(futures); 140 return Future.wait(futures);
136 }) 141 })
137 .then((_) => baseDir.delete(recursive: true)); 142 .then((_) => baseDir.delete(recursive: true));
138 }); 143 });
139 }); 144 });
140 } 145 }
141 146
142 147
143 Future testCreateLoopingLink(_) { 148 Future testCreateLoopingLink(_) {
144 return new Directory('').createTemp() 149 return Directory.systemTemp.createTemp('dart_link_async')
145 .then((dir) => dir.path) 150 .then((dir) => dir.path)
146 .then((String base) => 151 .then((String base) =>
147 new Directory(join(base, 'a', 'b', 'c')).create(recursive: true) 152 new Directory(join(base, 'a', 'b', 'c')).create(recursive: true)
148 .then((_) => new Link(join(base, 'a', 'b', 'c', 'd')) 153 .then((_) => new Link(join(base, 'a', 'b', 'c', 'd'))
149 .create(join(base, 'a', 'b'))) 154 .create(join(base, 'a', 'b')))
150 .then((_) => new Link(join(base, 'a', 'b', 'c', 'e')) 155 .then((_) => new Link(join(base, 'a', 'b', 'c', 'e'))
151 .create(join(base, 'a'))) 156 .create(join(base, 'a')))
152 .then((_) => new Directory(join(base, 'a')) 157 .then((_) => new Directory(join(base, 'a'))
153 .list(recursive: true, followLinks: false).last) 158 .list(recursive: true, followLinks: false).last)
154 // This directory listing must terminate, even though it contains loops. 159 // This directory listing must terminate, even though it contains loops.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 .then((Link link) { 198 .then((Link link) {
194 Expect.isTrue(link1.existsSync()); 199 Expect.isTrue(link1.existsSync());
195 Expect.isTrue(link.existsSync()); 200 Expect.isTrue(link.existsSync());
196 return FutureExpect.equals(target2, link.target()) 201 return FutureExpect.equals(target2, link.target())
197 .then((_) => FutureExpect.equals(target2, link1.target())) 202 .then((_) => FutureExpect.equals(target2, link1.target()))
198 .then((_) => link.delete()); 203 .then((_) => link.delete());
199 }) 204 })
200 .then((_) => Expect.isFalse(link1.existsSync())); 205 .then((_) => Expect.isFalse(link1.existsSync()));
201 } 206 }
202 207
203 return new Directory('').createTemp().then((baseDir) { 208 return Directory.systemTemp.createTemp('dart_link_async').then((baseDir) {
204 String base = baseDir.path; 209 String base = baseDir.path;
205 var targetsFutures = []; 210 var targetsFutures = [];
206 targetsFutures.add(new Directory(join(base, 'a')).create()); 211 targetsFutures.add(new Directory(join(base, 'a')).create());
207 if (Platform.isWindows) { 212 if (Platform.isWindows) {
208 // Currently only links to directories are supported on Windows. 213 // Currently only links to directories are supported on Windows.
209 targetsFutures.add( 214 targetsFutures.add(
210 new Directory(join(base, 'b')).create()); 215 new Directory(join(base, 'b')).create());
211 } else { 216 } else {
212 targetsFutures.add(new File(join(base, 'b')).create()); 217 targetsFutures.add(new File(join(base, 'b')).create());
213 } 218 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 ); 273 );
269 } 274 }
270 } 275 }
271 return Future.wait(futures); 276 return Future.wait(futures);
272 } 277 }
273 278
274 Future checkExists(String filePath) => 279 Future checkExists(String filePath) =>
275 new File(filePath).exists().then(Expect.isTrue); 280 new File(filePath).exists().then(Expect.isTrue);
276 281
277 Future testRelativeLinks(_) { 282 Future testRelativeLinks(_) {
278 return new Directory('').createTemp().then((tempDirectory) { 283 return Directory.systemTemp
284 .createTemp('dart_link_async')
285 .then((tempDirectory) {
279 String temp = tempDirectory.path; 286 String temp = tempDirectory.path;
280 String oldWorkingDirectory = Directory.current.path; 287 String oldWorkingDirectory = Directory.current.path;
281 // Make directories and files to test links. 288 // Make directories and files to test links.
282 return new Directory(join(temp, 'dir1', 'dir2')).create(recursive: true) 289 return new Directory(join(temp, 'dir1', 'dir2')).create(recursive: true)
283 .then((_) => new File(join(temp, 'dir1', 'file1')).create()) 290 .then((_) => new File(join(temp, 'dir1', 'file1')).create())
284 .then((_) => new File(join(temp, 'dir1', 'dir2', 'file2')).create()) 291 .then((_) => new File(join(temp, 'dir1', 'dir2', 'file2')).create())
285 // Make links whose path and/or target is given by a relative path. 292 // Make links whose path and/or target is given by a relative path.
286 .then((_) => new Link(join(temp, 'dir1', 'link1_2')).create('dir2')) 293 .then((_) => new Link(join(temp, 'dir1', 'link1_2')).create('dir2'))
287 .then((_) => Directory.current = temp) 294 .then((_) => Directory.current = temp)
288 .then((_) => new Link('link0_2').create(join('dir1', 'dir2'))) 295 .then((_) => new Link('link0_2').create(join('dir1', 'dir2')))
(...skipping 17 matching lines...) Expand all
306 } 313 }
307 314
308 main() { 315 main() {
309 asyncStart(); 316 asyncStart();
310 testCreate() 317 testCreate()
311 .then(testCreateLoopingLink) 318 .then(testCreateLoopingLink)
312 .then(testRename) 319 .then(testRename)
313 .then(testRelativeLinks) 320 .then(testRelativeLinks)
314 .then((_) => asyncEnd()); 321 .then((_) => asyncEnd());
315 } 322 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_headers_test.dart ('k') | tests/standalone/io/link_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698