Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Unified Diff: test/version_solver_test.dart

Issue 2079303003: Track Source objects in PackageNames. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/test_pub.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/version_solver_test.dart
diff --git a/test/version_solver_test.dart b/test/version_solver_test.dart
index 7d8da5d532a0d01f62a64651d2cd41816f10076a..da890621771fb360d7b4ffcbca2ab8b7893c168c 100644
--- a/test/version_solver_test.dart
+++ b/test/version_solver_test.dart
@@ -12,6 +12,7 @@ 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/source_registry.dart';
import 'package:pub/src/system_cache.dart';
import 'package:pub/src/utils.dart';
import 'package:pub_semver/pub_semver.dart';
@@ -652,7 +653,7 @@ backtracking() {
'c 5.0.0': {},
}, result: {
'myapp from root': '0.0.0',
- 'a': '1.0.0',
+ 'a-x': '1.0.0',
'b': '1.0.0',
'c': '5.0.0'
}, maxTries: 2);
@@ -1121,8 +1122,8 @@ testResolve(String description, Map packages, {
// Build the test package graph.
var root;
packages.forEach((description, dependencies) {
- var id = parseSpec(description);
- var package = mockPackage(id, dependencies,
+ var id = parseSpec(cache.sources, description);
+ var package = mockPackage(cache.sources, id, dependencies,
id.name == 'myapp' ? overrides : null);
if (id.name == 'myapp') {
// Don't add the root package to the server, so we can verify that Pub
@@ -1139,7 +1140,7 @@ testResolve(String description, Map packages, {
if (result != null) {
var newResult = {};
result.forEach((description, version) {
- var id = parseSpec(description, version);
+ var id = parseSpec(cache.sources, description, version);
newResult[id.name] = id;
});
result = newResult;
@@ -1148,12 +1149,12 @@ testResolve(String description, Map packages, {
// Parse the lockfile.
var realLockFile;
if (lockfile == null) {
- realLockFile = new LockFile.empty(cache.sources);
+ realLockFile = new LockFile.empty();
} else {
realLockFile = new LockFile(lockfile.keys.map((name) {
var version = new Version.parse(lockfile[name]);
- return new PackageId(name, source1.name, version, name);
- }), cache.sources);
+ return new PackageId(name, source1, version, name);
+ }));
}
// Resolve the versions.
@@ -1358,13 +1359,15 @@ class MockSource extends Source {
BoundSource bind(SystemCache cache) => new BoundMockSource(this, cache);
PackageRef parseRef(String name, description, {String containingPath}) =>
- new PackageRef(name, this.name, description);
+ new PackageRef(name, this, description);
PackageId parseId(String name, Version version, description) =>
- new PackageId(name, this.name, version, description);
+ new PackageId(name, this, version, description);
bool descriptionsEqual(description1, description2) =>
description1 == description2;
+
+ int hashDescription(description) => description.hashCode;
}
class BoundMockSource extends CachedSource {
@@ -1403,8 +1406,7 @@ class BoundMockSource extends CachedSource {
}
return _packages[ref.description].values.map((package) {
- return new PackageId(
- ref.name, source.name, package.version, ref.description);
+ return new PackageId(ref.name, source, package.version, ref.description);
}).toList();
}
@@ -1438,7 +1440,8 @@ class BoundMockSource extends CachedSource {
}
}
-Package mockPackage(PackageId id, Map dependencyStrings, Map overrides) {
+Package mockPackage(SourceRegistry sources, PackageId id, Map dependencyStrings,
+ Map overrides) {
var sdkConstraint = null;
// Build the pubspec dependencies.
@@ -1451,7 +1454,7 @@ Package mockPackage(PackageId id, Map dependencyStrings, Map overrides) {
spec = spec.substring("(dev) ".length);
}
- var dep = parseSpec(spec).withConstraint(
+ var dep = parseSpec(sources, spec).withConstraint(
new VersionConstraint.parse(constraint));
if (dep.name == 'sdk') {
@@ -1469,8 +1472,8 @@ Package mockPackage(PackageId id, Map dependencyStrings, Map overrides) {
var dependencyOverrides = <PackageDep>[];
if (overrides != null) {
overrides.forEach((spec, constraint) {
- dependencyOverrides.add(parseSpec(spec).withConstraint(
- new VersionConstraint.parse(constraint)));
+ dependencyOverrides.add(parseSpec(sources, spec)
+ .withConstraint(new VersionConstraint.parse(constraint)));
});
}
@@ -1497,7 +1500,7 @@ Package mockPackage(PackageId id, Map dependencyStrings, Map overrides) {
///
/// The "from mock" optional suffix is the name of a source for the package.
/// If omitted, it defaults to "mock1".
-PackageId parseSpec(String text, [String version]) {
+PackageId parseSpec(SourceRegistry sources, String text, [String version]) {
var pattern = new RegExp(r"(([a-z_]*)(-[a-z_]+)?)( ([^ ]+))?( from (.*))?$");
var match = pattern.firstMatch(text);
if (match == null) {
@@ -1523,11 +1526,8 @@ PackageId parseSpec(String text, [String version]) {
}
}
- var source = "mock1";
- if (match[7] != null) {
- source = match[7];
- if (source == "root") source = null;
- }
+ var source = sources["mock1"];
+ if (match[7] != null) source = match[7] == "root" ? null : sources[match[7]];
return new PackageId(name, source, parsedVersion, description);
}
« no previous file with comments | « test/test_pub.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698