| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 throw 'no'; | 462 throw 'no'; |
| 463 } | 463 } |
| 464 | 464 |
| 465 Package mockPackage(String description, String version, | 465 Package mockPackage(String description, String version, |
| 466 Map dependencyStrings) { | 466 Map dependencyStrings) { |
| 467 // Build the pubspec dependencies. | 467 // Build the pubspec dependencies. |
| 468 var dependencies = <PackageRef>[]; | 468 var dependencies = <PackageRef>[]; |
| 469 dependencyStrings.forEach((name, constraint) { | 469 dependencyStrings.forEach((name, constraint) { |
| 470 var parsed = parseSource(name); | 470 var parsed = parseSource(name); |
| 471 var description = parsed.first; | 471 var description = parsed.first; |
| 472 var packageName = description.replaceFirst(new RegExp(@"-[^-]+$"), ""); | 472 var packageName = description.replaceFirst(new RegExp(r"-[^-]+$"), ""); |
| 473 dependencies.add(new PackageRef(packageName, parsed.last, | 473 dependencies.add(new PackageRef(packageName, parsed.last, |
| 474 new VersionConstraint.parse(constraint), description)); | 474 new VersionConstraint.parse(constraint), description)); |
| 475 }); | 475 }); |
| 476 | 476 |
| 477 var pubspec = new Pubspec( | 477 var pubspec = new Pubspec( |
| 478 description, new Version.parse(version), dependencies); | 478 description, new Version.parse(version), dependencies); |
| 479 return new Package.inMemory(pubspec); | 479 return new Package.inMemory(pubspec); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void addPackage(Package package) { | 482 void addPackage(Package package) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 Future fakeAsync(callback()) { | 514 Future fakeAsync(callback()) { |
| 515 var completer = new Completer(); | 515 var completer = new Completer(); |
| 516 new Timer(0, (_) { | 516 new Timer(0, (_) { |
| 517 completer.complete(callback()); | 517 completer.complete(callback()); |
| 518 }); | 518 }); |
| 519 | 519 |
| 520 return completer.future; | 520 return completer.future; |
| 521 } | 521 } |
| 522 | 522 |
| 523 Pair<String, Source> parseSource(String name) { | 523 Pair<String, Source> parseSource(String name) { |
| 524 var match = new RegExp(@"(.*) from (.*)").firstMatch(name); | 524 var match = new RegExp(r"(.*) from (.*)").firstMatch(name); |
| 525 if (match == null) return new Pair<String, Source>(name, source1); | 525 if (match == null) return new Pair<String, Source>(name, source1); |
| 526 switch (match[2]) { | 526 switch (match[2]) { |
| 527 case 'mock1': return new Pair<String, Source>(match[1], source1); | 527 case 'mock1': return new Pair<String, Source>(match[1], source1); |
| 528 case 'mock2': return new Pair<String, Source>(match[1], source2); | 528 case 'mock2': return new Pair<String, Source>(match[1], source2); |
| 529 case 'root': return new Pair<String, Source>(match[1], rootSource); | 529 case 'root': return new Pair<String, Source>(match[1], rootSource); |
| 530 case 'versionless': | 530 case 'versionless': |
| 531 return new Pair<String, Source>(match[1], versionlessSource); | 531 return new Pair<String, Source>(match[1], versionlessSource); |
| 532 } | 532 } |
| 533 } | 533 } |
| OLD | NEW |