| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "package:path/path.dart"; | 6 import "package:path/path.dart"; |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 import "dart:isolate"; | 9 import "dart:isolate"; |
| 10 | 10 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 }) | 174 }) |
| 175 .then((link) { | 175 .then((link) { |
| 176 link2 = link; | 176 link2 = link; |
| 177 Expect.isFalse(link1.existsSync()); | 177 Expect.isFalse(link1.existsSync()); |
| 178 Expect.isTrue(link2.existsSync()); | 178 Expect.isTrue(link2.existsSync()); |
| 179 return link2.delete(); | 179 return link2.delete(); |
| 180 }) | 180 }) |
| 181 .then((_) => Expect.isFalse(link2.existsSync())); | 181 .then((_) => Expect.isFalse(link2.existsSync())); |
| 182 } | 182 } |
| 183 | 183 |
| 184 Future testUpdate(String base , String target1, String target2) { |
| 185 Link link1; |
| 186 return new Link(join(base, 'c')).create(target1) |
| 187 .then((link) { |
| 188 link1 = link; |
| 189 Expect.isTrue(link1.existsSync()); |
| 190 return link1.update(target2); |
| 191 }) |
| 192 .then((Link link) { |
| 193 Expect.isTrue(link1.existsSync()); |
| 194 Expect.isTrue(link.existsSync()); |
| 195 return FutureExpect.equals(target2, link.target()) |
| 196 .then((_) => FutureExpect.equals(target2, link1.target())) |
| 197 .then((_) => link.delete()); |
| 198 }) |
| 199 .then((_) => Expect.isFalse(link1.existsSync())); |
| 200 } |
| 201 |
| 184 return new Directory('').createTemp().then((baseDir) { | 202 return new Directory('').createTemp().then((baseDir) { |
| 185 String base = baseDir.path; | 203 String base = baseDir.path; |
| 186 var targetsFutures = []; | 204 var targetsFutures = []; |
| 187 targetsFutures.add(new Directory(join(base, 'a')).create()); | 205 targetsFutures.add(new Directory(join(base, 'a')).create()); |
| 188 if (Platform.isWindows) { | 206 if (Platform.isWindows) { |
| 189 // Currently only links to directories are supported on Windows. | 207 // Currently only links to directories are supported on Windows. |
| 190 targetsFutures.add( | 208 targetsFutures.add( |
| 191 new Directory(join(base, 'b')).create()); | 209 new Directory(join(base, 'b')).create()); |
| 192 } else { | 210 } else { |
| 193 targetsFutures.add(new File(join(base, 'b')).create()); | 211 targetsFutures.add(new File(join(base, 'b')).create()); |
| 194 } | 212 } |
| 195 return Future.wait(targetsFutures).then((targets) { | 213 return Future.wait(targetsFutures).then((targets) { |
| 196 return testRename(base, targets[0].path) | 214 return testRename(base, targets[0].path) |
| 197 .then((_) => testRename(base, targets[1].path)) | 215 .then((_) => testRename(base, targets[1].path)) |
| 216 .then((_) => testUpdate(base, targets[0].path, targets[1].path)) |
| 198 .then((_) => baseDir.delete(recursive: true)); | 217 .then((_) => baseDir.delete(recursive: true)); |
| 199 }); | 218 }); |
| 200 }); | 219 }); |
| 201 } | 220 } |
| 202 | 221 |
| 203 Future testDirectoryListing(String base, Directory baseDir) { | 222 Future testDirectoryListing(String base, Directory baseDir) { |
| 204 Map makeExpected(bool recursive, bool followLinks) { | 223 Map makeExpected(bool recursive, bool followLinks) { |
| 205 Map expected = new Map(); | 224 Map expected = new Map(); |
| 206 expected['target'] = 'Directory'; | 225 expected['target'] = 'Directory'; |
| 207 expected['link'] = followLinks ? 'Directory' : 'Link'; | 226 expected['link'] = followLinks ? 'Directory' : 'Link'; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return Future.wait(futures); | 270 return Future.wait(futures); |
| 252 } | 271 } |
| 253 | 272 |
| 254 main() { | 273 main() { |
| 255 ReceivePort keepAlive = new ReceivePort(); | 274 ReceivePort keepAlive = new ReceivePort(); |
| 256 testCreate() | 275 testCreate() |
| 257 .then((_) => testCreateLoopingLink()) | 276 .then((_) => testCreateLoopingLink()) |
| 258 .then((_) => testRename()) | 277 .then((_) => testRename()) |
| 259 .then((_) => keepAlive.close()); | 278 .then((_) => keepAlive.close()); |
| 260 } | 279 } |
| OLD | NEW |