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

Side by Side Diff: utils/tests/pub/test_pub.dart

Issue 11348285: Work around issue 6984. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« pkg/http/test/utils.dart ('K') | « utils/tests/pub/pub_lish_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub
7 * tests are integration tests that stage some stuff on the file system, run 7 * tests are integration tests that stage some stuff on the file system, run
8 * pub, and then validate the results. This library provides an API to build 8 * pub, and then validate the results. This library provides an API to build
9 * tests like that. 9 * tests like that.
10 */ 10 */
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 _server = new HttpServer(); 98 _server = new HttpServer();
99 _server.defaultRequestHandler = (request, response) { 99 _server.defaultRequestHandler = (request, response) {
100 var path = request.uri.replaceFirst("/", "").split("/"); 100 var path = request.uri.replaceFirst("/", "").split("/");
101 response.persistentConnection = false; 101 response.persistentConnection = false;
102 var stream; 102 var stream;
103 try { 103 try {
104 stream = baseDir.load(path); 104 stream = baseDir.load(path);
105 } catch (e) { 105 } catch (e) {
106 response.statusCode = 404; 106 response.statusCode = 404;
107 response.contentLength = 0; 107 response.contentLength = 0;
108 response.outputStream.close(); 108 closeHttpResponse(request, response);
109 return; 109 return;
110 } 110 }
111 111
112 var future = consumeInputStream(stream); 112 var future = consumeInputStream(stream);
113 future.then((data) { 113 future.then((data) {
114 response.statusCode = 200; 114 response.statusCode = 200;
115 response.contentLength = data.length; 115 response.contentLength = data.length;
116 response.outputStream.write(data); 116 response.outputStream.write(data);
117 response.outputStream.close(); 117 closeHttpResponse(request, response);
118 }); 118 });
119 119
120 future.handleException((e) { 120 future.handleException((e) {
121 print("Exception while handling ${request.uri}: $e"); 121 print("Exception while handling ${request.uri}: $e");
122 response.statusCode = 500; 122 response.statusCode = 500;
123 response.reasonPhrase = e.message; 123 response.reasonPhrase = e.message;
124 response.outputStream.close(); 124 closeHttpResponse(request, response);
125 }); 125 });
126 }; 126 };
127 _server.listen("127.0.0.1", 0); 127 _server.listen("127.0.0.1", 0);
128 _portCompleter.complete(_server.port); 128 _portCompleter.complete(_server.port);
129 _scheduleCleanup((_) => _closeServer()); 129 _scheduleCleanup((_) => _closeServer());
130 return null; 130 return null;
131 }); 131 });
132 }); 132 });
133 } 133 }
134 134
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 /// calling [completion] is unnecessary. 1528 /// calling [completion] is unnecessary.
1529 void expectLater(Future actual, matcher, {String reason, 1529 void expectLater(Future actual, matcher, {String reason,
1530 FailureHandler failureHandler, bool verbose: false}) { 1530 FailureHandler failureHandler, bool verbose: false}) {
1531 _schedule((_) { 1531 _schedule((_) {
1532 return actual.transform((value) { 1532 return actual.transform((value) {
1533 expect(value, matcher, reason: reason, failureHandler: failureHandler, 1533 expect(value, matcher, reason: reason, failureHandler: failureHandler,
1534 verbose: false); 1534 verbose: false);
1535 }); 1535 });
1536 }); 1536 });
1537 } 1537 }
OLDNEW
« pkg/http/test/utils.dart ('K') | « utils/tests/pub/pub_lish_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698