Chromium Code Reviews| 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('pub_update_test'); | 5 #library('pub_update_test'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('dart:isolate'); | 8 #import('dart:isolate'); |
| 9 | 9 |
| 10 #import('../../pub/package.dart'); | 10 #import('../../pub/package.dart'); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 sources.register(source); | 185 sources.register(source); |
| 186 sources.setDefault(source.name); | 186 sources.setDefault(source.name); |
| 187 | 187 |
| 188 // Build the test package graph. | 188 // Build the test package graph. |
| 189 var root; | 189 var root; |
| 190 packages.forEach((nameVersion, dependencies) { | 190 packages.forEach((nameVersion, dependencies) { |
| 191 var parts = nameVersion.split(' '); | 191 var parts = nameVersion.split(' '); |
| 192 var name = parts[0]; | 192 var name = parts[0]; |
| 193 var version = parts[1]; | 193 var version = parts[1]; |
| 194 var package = source.mockPackage(name, version, dependencies); | 194 var package = source.mockPackage(name, version, dependencies); |
| 195 if (name == 'myapp') root = package; | 195 if (name == 'myapp') { |
| 196 root = package; | |
|
Bob Nystrom
2012/06/26 23:39:09
Can you add a comment here that we specifically do
nweiz
2012/06/27 18:05:12
Done.
| |
| 197 } else { | |
| 198 source.addPackage(package); | |
| 199 } | |
| 196 }); | 200 }); |
| 197 | 201 |
| 198 // Clean up the expectation. | 202 // Clean up the expectation. |
| 199 if (result != null) { | 203 if (result != null) { |
| 200 result.forEach((name, version) { | 204 result.forEach((name, version) { |
| 201 result[name] = new Version.parse(version); | 205 result[name] = new Version.parse(version); |
| 202 }); | 206 }); |
| 203 } | 207 } |
| 204 | 208 |
| 205 // Resolve the versions. | 209 // Resolve the versions. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 | 257 |
| 254 Package mockPackage(String name, String version, Map dependencyStrings) { | 258 Package mockPackage(String name, String version, Map dependencyStrings) { |
| 255 // Build the pubspec dependencies. | 259 // Build the pubspec dependencies. |
| 256 var dependencies = <PackageRef>[]; | 260 var dependencies = <PackageRef>[]; |
| 257 dependencyStrings.forEach((name, constraint) { | 261 dependencyStrings.forEach((name, constraint) { |
| 258 dependencies.add(new PackageRef(name, this, | 262 dependencies.add(new PackageRef(name, this, |
| 259 new VersionConstraint.parse(constraint), name)); | 263 new VersionConstraint.parse(constraint), name)); |
| 260 }); | 264 }); |
| 261 | 265 |
| 262 var pubspec = new Pubspec(new Version.parse(version), dependencies); | 266 var pubspec = new Pubspec(new Version.parse(version), dependencies); |
| 263 var package = new Package.inMemory(name, pubspec); | 267 return new Package.inMemory(name, pubspec); |
| 268 } | |
| 264 | 269 |
| 265 _packages.putIfAbsent(name, () => new Map<Version, Package>()); | 270 void addPackage(Package package) { |
| 266 _packages[name][package.version] = package; | 271 _packages.putIfAbsent(package.name, () => new Map<Version, Package>()); |
| 272 _packages[package.name][package.version] = package; | |
| 267 return package; | 273 return package; |
| 268 } | 274 } |
| 269 } | 275 } |
| 270 | 276 |
| 271 Future fakeAsync(callback()) { | 277 Future fakeAsync(callback()) { |
| 272 var completer = new Completer(); | 278 var completer = new Completer(); |
| 273 new Timer(0, (_) { | 279 new Timer(0, (_) { |
| 274 completer.complete(callback()); | 280 completer.complete(callback()); |
| 275 }); | 281 }); |
| 276 | 282 |
| 277 return completer.future; | 283 return completer.future; |
| 278 } | 284 } |
| OLD | NEW |