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

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

Issue 10704172: Hook in the version solver to pub install. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | « utils/tests/pub/pub_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 6e7f209814306f4b9dbb2f8c4757c524201e992c..fb10858ddcfa9f6f0e562199b43d13975ba20edd 100644
--- a/utils/tests/pub/test_pub.dart
+++ b/utils/tests/pub/test_pub.dart
@@ -11,6 +11,8 @@
#library('test_pub');
#import('dart:io');
+#import('dart:isolate');
+#import('dart:json');
#import('dart:uri');
#import('../../../lib/unittest/unittest.dart');
@@ -57,10 +59,13 @@ void serve(String host, int port, [List<Descriptor> contents]) {
var server = new HttpServer();
server.defaultRequestHandler = (request, response) {
var path = request.uri.replaceFirst("/", "").split("/");
- var stream = baseDir.load(path);
response.persistentConnection = false;
- if (stream == null) {
+ var stream;
+ try {
+ stream = baseDir.load(path);
+ } catch (var e) {
response.statusCode = 404;
+ response.contentLength = 0;
response.outputStream.close();
return;
}
@@ -102,16 +107,23 @@ void servePackages(String host, int port, List<String> pubspecs) {
});
serve(host, port, [
- dir('packages', packages.getKeys().map((name) {
- return dir(name, [
- dir('versions', packages[name].getKeys().map((version) {
- return tar('$version.tar.gz', [
- file('pubspec.yaml', packages[name][version]),
- file('$name.dart', 'main() => print("$name $version");')
- ]);
- }))
- ]);
- }))
+ dir('packages', flatten(packages.getKeys().map((name) {
+ return [
+ file('$name.json',
+ JSON.stringify({'versions': packages[name].getKeys()})),
+ dir(name, [
+ dir('versions', flatten(packages[name].getKeys().map((version) {
+ return [
+ file('$version.yaml', packages[name][version]),
+ tar('$version.tar.gz', [
+ file('pubspec.yaml', packages[name][version]),
+ file('$name.dart', 'main() => print("$name $version");')
+ ])
+ ];
+ })))
+ ])
+ ];
+ })))
]);
}
@@ -510,12 +522,13 @@ class FileDescriptor extends Descriptor {
*/
InputStream load(List<String> path) {
if (!path.isEmpty()) {
- var joinedPath = Strings.join('/', path);
+ var joinedPath = Strings.join(path, '/');
throw "Can't load $joinedPath from within $name: not a directory.";
}
var stream = new ListInputStream();
stream.write(contents.charCodes());
+ stream.markEndOfStream();
return stream;
}
}
@@ -595,7 +608,7 @@ class DirectoryDescriptor extends Descriptor {
}
}
- throw "Directory $name doesn't contain ${Strings.join('/', path)}.";
+ throw "Directory $name doesn't contain ${Strings.join(path, '/')}.";
}
}
@@ -694,7 +707,7 @@ class TarFileDescriptor extends Descriptor {
*/
InputStream load(List<String> path) {
if (!path.isEmpty()) {
- var joinedPath = Strings.join('/', path);
+ var joinedPath = Strings.join(path, '/');
throw "Can't load $joinedPath from within $name: not a directory.";
}
« no previous file with comments | « utils/tests/pub/pub_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698