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

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

Issue 10916190: Support both new and old style package layouts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 8 years, 3 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/io.dart ('K') | « utils/tests/pub/pub_update_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 08b3e178e8ac410e0ba5b1a46e0fd6ff7f645e35..b6e7fcb470c0c4f442864a5609684e74fecd8100 100644
--- a/utils/tests/pub/test_pub.dart
+++ b/utils/tests/pub/test_pub.dart
@@ -203,7 +203,7 @@ void servePackages(List<Map> pubspecs) {
file('$version.yaml', _servedPackages[name][version]),
tar('$version.tar.gz', [
file('pubspec.yaml', _servedPackages[name][version]),
- file('$name.dart', 'main() => print("$name $version");')
+ libDir(name, '$name $version')
])
];
})))
@@ -248,6 +248,21 @@ Descriptor libPubspec(String name, String version, [List dependencies]) =>
pubspec(package(name, version, dependencies));
/**
+ * Describes a directory named `lib` containing a single dart file named
+ * `<name>.dart` that contains a line of Dart code.
+ */
+Descriptor libDir(String name, [String code]) {
+ // Default to printing the name if no other code was given.
+ if (code == null) {
+ code = name;
+ }
+
+ return dir("lib", [
+ file("$name.dart", 'main() => "$code";')
+ ]);
+}
+
+/**
* Describes a map representing a library package with the given [name],
* [version], and [dependencies].
*/
@@ -271,22 +286,12 @@ Map dependency(String name, [String versionConstraint]) {
}
/**
- * Describes a directory for a package installed from the mock package repo.
- * This directory is of the form found in the `packages/` directory.
- */
-DirectoryDescriptor packageDir(String name, String version) {
- return dir(name, [
- file("$name.dart", 'main() => print("$name $version");')
- ]);
-}
-
-/**
* Describes a directory for a package installed from the mock package server.
* This directory is of the form found in the global package cache.
*/
DirectoryDescriptor packageCacheDir(String name, String version) {
return dir("$name-$version", [
- file("$name.dart", 'main() => print("$name $version");')
+ libDir(name, '$name $version')
]);
}
@@ -298,7 +303,7 @@ DirectoryDescriptor gitPackageRevisionCacheDir(String name, [int modifier]) {
var value = name;
if (modifier != null) value = "$name $modifier";
return dir(new RegExp("$name${@'-[a-f0-9]+'}"), [
- file('$name.dart', 'main() => "$value";')
+ libDir(name, value)
]);
}
@@ -329,7 +334,9 @@ DirectoryDescriptor packagesDir(Map<String, String> packages) {
if (version == null) {
contents.add(nothing(name));
} else {
- contents.add(packageDir(name, version));
+ contents.add(dir(name, [
+ file("$name.dart", 'main() => "$name $version";')
+ ]));
}
});
return dir(packagesPath, contents);
« utils/pub/io.dart ('K') | « utils/tests/pub/pub_update_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698