| 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/lock_file.dart'); | 10 #import('../../pub/lock_file.dart'); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 Package mockPackage(String description, String version, | 400 Package mockPackage(String description, String version, |
| 401 Map dependencyStrings) { | 401 Map dependencyStrings) { |
| 402 // Build the pubspec dependencies. | 402 // Build the pubspec dependencies. |
| 403 var dependencies = <PackageRef>[]; | 403 var dependencies = <PackageRef>[]; |
| 404 dependencyStrings.forEach((name, constraint) { | 404 dependencyStrings.forEach((name, constraint) { |
| 405 var parsed = parseSource(name); | 405 var parsed = parseSource(name); |
| 406 dependencies.add(new PackageRef( | 406 dependencies.add(new PackageRef( |
| 407 parsed.last, new VersionConstraint.parse(constraint), parsed.first)); | 407 parsed.last, new VersionConstraint.parse(constraint), parsed.first)); |
| 408 }); | 408 }); |
| 409 | 409 |
| 410 var pubspec = new Pubspec(new Version.parse(version), dependencies); | 410 var pubspec = new Pubspec( |
| 411 return new Package.inMemory(description, pubspec); | 411 description, new Version.parse(version), dependencies); |
| 412 return new Package.inMemory(pubspec); |
| 412 } | 413 } |
| 413 | 414 |
| 414 void addPackage(Package package) { | 415 void addPackage(Package package) { |
| 415 _packages.putIfAbsent(package.name, () => new Map<Version, Package>()); | 416 _packages.putIfAbsent(package.name, () => new Map<Version, Package>()); |
| 416 _packages[package.name][package.version] = package; | 417 _packages[package.name][package.version] = package; |
| 417 } | 418 } |
| 418 | 419 |
| 419 String packageName(String description) => | 420 String packageName(String description) => |
| 420 description.replaceFirst(new RegExp(@"-[^-]+$"), ""); | 421 description.replaceFirst(new RegExp(@"-[^-]+$"), ""); |
| 421 } | 422 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 Pair<String, Source> parseSource(String name) { | 459 Pair<String, Source> parseSource(String name) { |
| 459 var match = new RegExp(@"(.*) from (.*)").firstMatch(name); | 460 var match = new RegExp(@"(.*) from (.*)").firstMatch(name); |
| 460 if (match == null) return new Pair<String, Source>(name, source1); | 461 if (match == null) return new Pair<String, Source>(name, source1); |
| 461 switch (match[2]) { | 462 switch (match[2]) { |
| 462 case 'mock1': return new Pair<String, Source>(match[1], source1); | 463 case 'mock1': return new Pair<String, Source>(match[1], source1); |
| 463 case 'mock2': return new Pair<String, Source>(match[1], source2); | 464 case 'mock2': return new Pair<String, Source>(match[1], source2); |
| 464 case 'versionless': | 465 case 'versionless': |
| 465 return new Pair<String, Source>(match[1], versionlessSource); | 466 return new Pair<String, Source>(match[1], versionlessSource); |
| 466 } | 467 } |
| 467 } | 468 } |
| OLD | NEW |