Chromium Code Reviews| Index: sdk/lib/_internal/pub/test/test_pub.dart |
| diff --git a/sdk/lib/_internal/pub/test/test_pub.dart b/sdk/lib/_internal/pub/test/test_pub.dart |
| index bf6dbcc10f220dc0b03030474e363c4edfbd7f05..f7a6491635068a63b6ff83009a7270927fe4d41c 100644 |
| --- a/sdk/lib/_internal/pub/test/test_pub.dart |
| +++ b/sdk/lib/_internal/pub/test/test_pub.dart |
| @@ -20,6 +20,7 @@ import 'package:scheduled_test/scheduled_process.dart'; |
| import 'package:scheduled_test/scheduled_server.dart'; |
| import 'package:scheduled_test/scheduled_test.dart'; |
| import 'package:unittest/compact_vm_config.dart'; |
| +import 'package:yaml/yaml.dart'; |
| import '../lib/src/entrypoint.dart'; |
| // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
| @@ -28,11 +29,14 @@ import '../lib/src/entrypoint.dart'; |
| import '../lib/src/git.dart' as gitlib; |
| import '../lib/src/http.dart'; |
| import '../lib/src/io.dart'; |
| +import '../lib/src/lock_file.dart'; |
| import '../lib/src/log.dart' as log; |
| +import '../lib/src/package.dart'; |
| import '../lib/src/safe_http_server.dart'; |
| import '../lib/src/system_cache.dart'; |
| import '../lib/src/utils.dart'; |
| import '../lib/src/validator.dart'; |
| +import '../lib/src/version.dart'; |
| import 'descriptor.dart' as d; |
| /// This should be called at the top of a test file to set up an appropriate |
| @@ -599,6 +603,44 @@ void ensureGit() { |
| }, 'ensuring that Git is installed'); |
| } |
| +/// Create a lock file for [package] without running `pub install`. |
| +/// |
| +/// This creates a lock file with only path dependencies. [dependencies] is a |
| +/// map of dependency names to paths. [pkg] is a list of Dart SDK packages; each |
|
Bob Nystrom
2013/08/27 22:12:30
"Dart SDK packages" -> 'packages in the Dart repo'
nweiz
2013/08/28 20:45:23
Done.
|
| +/// package listed here and all its dependencies will be linked to the version |
| +/// in the Dart SDK. |
|
Bob Nystrom
2013/08/27 22:12:30
"SDK" -> "repo".
nweiz
2013/08/28 20:45:23
Done.
|
| +void createLockFile(String package, Map<String, String> dependencies, |
| + {Iterable<String> pkg}) { |
| + if (pkg != null) { |
| + var pkgDir = path.absolute(path.join( |
| + path.dirname(Platform.executable), |
| + '..', '..', '..', '..', 'pkg')); |
| + |
| + _addPackage(String package) { |
| + if (dependencies.containsKey(package)) return; |
| + var packagePath = path.join(pkgDir, package); |
| + dependencies[package] = packagePath; |
| + var pubspec = loadYaml( |
| + readTextFile(path.join(packagePath, 'pubspec.yaml'))); |
|
Bob Nystrom
2013/08/27 22:12:30
How about using Pubspec.parse() here?
nweiz
2013/08/28 20:45:23
That requires setting up a SourceRegistry, which i
Bob Nystrom
2013/08/29 00:12:01
You should be able to just make an empty source re
nweiz
2013/09/04 00:21:58
It requires at least a real default source.
|
| + var packageDeps = pubspec['dependencies']; |
| + if (packageDeps == null) return; |
| + packageDeps.keys.forEach(_addPackage); |
| + } |
| + |
| + pkg.forEach(_addPackage); |
| + } |
| + |
| + var lockFile = new LockFile.empty(); |
| + dependencies.forEach((name, dependencyPath) { |
| + var id = new PackageId(name, 'path', new Version(0, 0, 0), { |
| + 'path': dependencyPath, |
| + 'relative': path.isRelative(dependencyPath) |
| + }); |
| + lockFile.packages[name] = id; |
| + }); |
| + d.file(path.join(package, 'pubspec.lock'), lockFile.serialize()).create(); |
| +} |
| + |
| /// Use [client] as the mock HTTP client for this test. |
| /// |
| /// Note that this will only affect HTTP requests made via http.dart in the |