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

Unified Diff: test/test_pub.dart

Issue 1281043004: Make LockFile immutable. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 years, 4 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/lock_file_test.dart ('k') | test/version_solver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/test_pub.dart
diff --git a/test/test_pub.dart b/test/test_pub.dart
index 86376eafb1ba80e3a73f529d41504c4444e9bb97..368770aa1ccf8ae04cbcbc55dfeba2459eb45ccc 100644
--- a/test/test_pub.dart
+++ b/test/test_pub.dart
@@ -691,21 +691,21 @@ void makeGlobalPackage(String package, String version,
d.dir("$package-$version", contents)
]).create();
- var lockFile = _createLockFile(pkg: pkg, hosted: hosted);
-
- // Add the root package to the lockfile.
- var id = new PackageId(package, "hosted", new Version.parse(version),
- package);
- lockFile.packages[package] = id;
-
// Write the lockfile to the global cache.
var sources = new SourceRegistry();
sources.register(new HostedSource());
sources.register(new PathSource());
+ var lockFile = _createLockFile(sources, pkg: pkg, hosted: hosted);
+
+ // Add the root package to the lockfile.
+ var id = new PackageId(package, "hosted", new Version.parse(version),
+ package);
+ lockFile = lockFile.setPackage(id);
+
d.dir(cachePath, [
d.dir("global_packages", [
- d.file("$package.lock", lockFile.serialize(null, sources))
+ d.file("$package.lock", lockFile.serialize(null))
])
]).create();
}
@@ -721,14 +721,14 @@ void makeGlobalPackage(String package, String version,
/// hosted packages.
void createLockFile(String package, {Iterable<String> sandbox,
Iterable<String> pkg, Map<String, String> hosted}) {
- var lockFile = _createLockFile(sandbox: sandbox, pkg: pkg, hosted: hosted);
-
var sources = new SourceRegistry();
sources.register(new HostedSource());
sources.register(new PathSource());
- d.file(p.join(package, 'pubspec.lock'),
- lockFile.serialize(null, sources)).create();
+ var lockFile = _createLockFile(sources,
+ sandbox: sandbox, pkg: pkg, hosted: hosted);
+
+ d.file(p.join(package, 'pubspec.lock'), lockFile.serialize(null)).create();
}
/// Creates a lock file for [package] without running `pub get`.
@@ -740,8 +740,8 @@ void createLockFile(String package, {Iterable<String> sandbox,
///
/// [hosted] is a list of package names to version strings for dependencies on
/// hosted packages.
-LockFile _createLockFile({Iterable<String> sandbox,
-Iterable<String> pkg, Map<String, String> hosted}) {
+LockFile _createLockFile(SourceRegistry sources, {Iterable<String> sandbox,
+ Iterable<String> pkg, Map<String, String> hosted}) {
var dependencies = {};
if (sandbox != null) {
@@ -778,23 +778,22 @@ Iterable<String> pkg, Map<String, String> hosted}) {
pkg.forEach(_addPackage);
}
- var lockFile = new LockFile.empty();
- dependencies.forEach((name, dependencyPath) {
- var id = new PackageId(name, 'path', new Version(0, 0, 0), {
+ var packages = dependencies.keys.map((name) {
+ var dependencyPath = dependencies[name];
+ return new PackageId(name, 'path', new Version(0, 0, 0), {
'path': dependencyPath,
'relative': p.isRelative(dependencyPath)
});
- lockFile.packages[name] = id;
- });
+ }).toList();
if (hosted != null) {
hosted.forEach((name, version) {
var id = new PackageId(name, 'hosted', new Version.parse(version), name);
- lockFile.packages[name] = id;
+ packages.add(id);
});
}
- return lockFile;
+ return new LockFile(packages, sources);
}
/// Returns the path to the version of [package] used by pub.
« no previous file with comments | « test/lock_file_test.dart ('k') | test/version_solver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698