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

Unified Diff: utils/tests/pub/test_pub.dart

Issue 10867070: Support removing dead packages with `pub install`. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« utils/pub/entrypoint.dart ('K') | « utils/tests/pub/pub_update_repo_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/test_pub.dart
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart
index 9fe67f0e00c7c46015046011d3081f8f37d96f8f..010a8e465ac40bac5978f4451a7912fda746a074 100644
--- a/utils/tests/pub/test_pub.dart
+++ b/utils/tests/pub/test_pub.dart
@@ -56,6 +56,11 @@ TarFileDescriptor tar(Pattern name, [List<Descriptor> contents]) =>
new TarFileDescriptor(name, contents);
/**
+ * Creates a new [NothingDescriptor] with [name].
+ */
+NothingDescriptor nothing(String name) => new NothingDescriptor(name);
+
+/**
* The current [HttpServer] created using [serve].
*/
var _server;
@@ -301,11 +306,17 @@ DirectoryDescriptor gitPackageCacheDir(String name, [int modifier]) {
* Describes the `packages/` directory containing all the given [packages],
* which should be name/version pairs. The packages will be validated against
* the format produced by the mock package server.
+ *
+ * A package with a null version should not be installed.
*/
DirectoryDescriptor packagesDir(Map<String, String> packages) {
var contents = <Descriptor>[];
packages.forEach((name, version) {
- contents.add(packageDir(name, version));
+ if (version == null) {
+ contents.add(nothing(name));
+ } else {
+ contents.add(packageDir(name, version));
+ }
});
return dir(packagesPath, contents);
}
@@ -1022,6 +1033,31 @@ class TarFileDescriptor extends Descriptor {
}
/**
+ * A descriptor that validates that no file exists with the given name.
+ */
+class NothingDescriptor extends Descriptor {
+ NothingDescriptor(String name) : super(name);
+
+ Future create(dir) => new Future.immediate(null);
+ Future delete(dir) => new Future.immediate(null);
+
+ Future validate(String dir) {
+ return exists(join(dir, name)).transform((exists) {
+ if (exists) Expect.fail('File $name in $dir should not exist.');
+ });
+ }
+
+ InputStream load(List<String> path) {
+ if (path.isEmpty()) {
+ throw "Can't load the contents of $name: it doesn't exist.";
+ } else {
+ throw "Can't load ${Strings.join(path, '/')} from within $name: $name "
+ "doesn't exist.";
+ }
+ }
+}
+
+/**
* Takes a simple data structure (composed of [Map]s, [List]s, scalar objects,
* and [Future]s) and recursively resolves all the [Future]s contained within.
* Completes with the fully resolved structure.
« utils/pub/entrypoint.dart ('K') | « utils/tests/pub/pub_update_repo_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698