| Index: test/version_solver_test.dart
|
| diff --git a/test/version_solver_test.dart b/test/version_solver_test.dart
|
| index 5fba6da5e52f51d46dadaff04630aad4b44686e1..dcb05d14e5be98b76bd41c007eb5c365fc5ef818 100644
|
| --- a/test/version_solver_test.dart
|
| +++ b/test/version_solver_test.dart
|
| @@ -10,6 +10,7 @@ import 'package:pub/src/package.dart';
|
| import 'package:pub/src/pubspec.dart';
|
| import 'package:pub/src/sdk.dart' as sdk;
|
| import 'package:pub/src/solver/version_solver.dart';
|
| +import 'package:pub/src/source.dart';
|
| import 'package:pub/src/source/cached.dart';
|
| import 'package:pub/src/system_cache.dart';
|
| import 'package:pub/src/utils.dart';
|
| @@ -1109,11 +1110,12 @@ testResolve(String description, Map packages, {
|
| if (maxTries == null) maxTries = 1;
|
|
|
| test(description, () {
|
| - var cache = new SystemCache('.');
|
| source1 = new MockSource('mock1');
|
| source2 = new MockSource('mock2');
|
| - cache.register(source1);
|
| - cache.register(source2);
|
| +
|
| + var cache = new SystemCache(rootDir: '.');
|
| + cache.sources.register(source1);
|
| + cache.sources.register(source2);
|
| cache.sources.setDefault(source1.name);
|
|
|
| // Build the test package graph.
|
| @@ -1128,8 +1130,8 @@ testResolve(String description, Map packages, {
|
| // remote server.
|
| root = package;
|
| } else {
|
| - (cache.sources[id.source] as MockSource).addPackage(
|
| - id.description, package);
|
| + (cache.liveSource(id.source) as LiveMockSource)
|
| + .addPackage(id.description, package);
|
| }
|
| });
|
|
|
| @@ -1158,7 +1160,7 @@ testResolve(String description, Map packages, {
|
| log.verbosity = log.Verbosity.NONE;
|
| var future = resolveVersions(
|
| downgrade ? SolveType.DOWNGRADE : SolveType.GET,
|
| - cache.sources, root, lockFile: realLockFile);
|
| + cache, root, lockFile: realLockFile);
|
|
|
| var matcher;
|
| if (result != null) {
|
| @@ -1347,24 +1349,14 @@ class SolveFailMatcher implements Matcher {
|
| /// descriptions, a package's name is calculated by taking the description
|
| /// string and stripping off any trailing hyphen followed by non-hyphen
|
| /// characters.
|
| -class MockSource extends CachedSource {
|
| - final _packages = <String, Map<Version, Package>>{};
|
| -
|
| - /// Keeps track of which package version lists have been requested. Ensures
|
| - /// that a source is only hit once for a given package and that pub
|
| - /// internally caches the results.
|
| - final _requestedVersions = new Set<String>();
|
| -
|
| - /// Keeps track of which package pubspecs have been requested. Ensures that a
|
| - /// source is only hit once for a given package and that pub internally
|
| - /// caches the results.
|
| - final _requestedPubspecs = new Map<String, Set<Version>>();
|
| -
|
| +class MockSource extends Source {
|
| final String name;
|
| final hasMultipleVersions = true;
|
|
|
| MockSource(this.name);
|
|
|
| + LiveSource bind(SystemCache cache) => new LiveMockSource(this, cache);
|
| +
|
| PackageRef parseRef(String name, description, {String containingPath}) =>
|
| new PackageRef(name, this.name, description);
|
|
|
| @@ -1373,6 +1365,26 @@ class MockSource extends CachedSource {
|
|
|
| bool descriptionsEqual(description1, description2) =>
|
| description1 == description2;
|
| +}
|
| +
|
| +class LiveMockSource extends CachedSource {
|
| + final SystemCache systemCache;
|
| +
|
| + final MockSource source;
|
| +
|
| + final _packages = <String, Map<Version, Package>>{};
|
| +
|
| + /// Keeps track of which package version lists have been requested. Ensures
|
| + /// that a source is only hit once for a given package and that pub
|
| + /// internally caches the results.
|
| + final _requestedVersions = new Set<String>();
|
| +
|
| + /// Keeps track of which package pubspecs have been requested. Ensures that a
|
| + /// source is only hit once for a given package and that pub internally
|
| + /// caches the results.
|
| + final _requestedPubspecs = new Map<String, Set<Version>>();
|
| +
|
| + LiveMockSource(this.source, this.systemCache);
|
|
|
| String getDirectory(PackageId id) => '${id.name}-${id.version}';
|
|
|
| @@ -1392,7 +1404,7 @@ class MockSource extends CachedSource {
|
|
|
| return _packages[ref.description].values.map((package) {
|
| return new PackageId(
|
| - ref.name, this.name, package.version, ref.description);
|
| + ref.name, source.name, package.version, ref.description);
|
| }).toList();
|
| }
|
|
|
|
|