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

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

Issue 12504006: Make IOSink implement StringSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed second round of review comments Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/tests/pub/pub_uploader_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) 2013, 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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub
6 /// tests are integration tests that stage some stuff on the file system, run 6 /// tests are integration tests that stage some stuff on the file system, run
7 /// pub, and then validate the results. This library provides an API to build 7 /// pub, and then validate the results. This library provides an API to build
8 /// tests like that. 8 /// tests like that.
9 library test_pub; 9 library test_pub;
10 10
11 import 'dart:async'; 11 import 'dart:async';
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } catch (e) { 114 } catch (e) {
115 response.statusCode = 404; 115 response.statusCode = 404;
116 response.contentLength = 0; 116 response.contentLength = 0;
117 response.close(); 117 response.close();
118 return; 118 return;
119 } 119 }
120 120
121 stream.toBytes().then((data) { 121 stream.toBytes().then((data) {
122 response.statusCode = 200; 122 response.statusCode = 200;
123 response.contentLength = data.length; 123 response.contentLength = data.length;
124 response.add(data); 124 response.writeBytes(data);
125 response.close(); 125 response.close();
126 }).catchError((e) { 126 }).catchError((e) {
127 print("Exception while handling ${request.uri}: $e"); 127 print("Exception while handling ${request.uri}: $e");
128 response.statusCode = 500; 128 response.statusCode = 500;
129 response.reasonPhrase = e.message; 129 response.reasonPhrase = e.message;
130 response.close(); 130 response.close();
131 }); 131 });
132 }); 132 });
133 _portCompleter.complete(_server.port); 133 _portCompleter.complete(_server.port);
134 _scheduleCleanup((_) => _closeServer()); 134 _scheduleCleanup((_) => _closeServer());
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 return timeout(_stderrFuture.then((stream) => stream.toList()) 1432 return timeout(_stderrFuture.then((stream) => stream.toList())
1433 .then((lines) => lines.join("\n")), 1433 .then((lines) => lines.join("\n")),
1434 _SCHEDULE_TIMEOUT, 1434 _SCHEDULE_TIMEOUT,
1435 "waiting for the last stderr line from process $name"); 1435 "waiting for the last stderr line from process $name");
1436 }); 1436 });
1437 } 1437 }
1438 1438
1439 /// Writes [line] to the process as stdin. 1439 /// Writes [line] to the process as stdin.
1440 void writeLine(String line) { 1440 void writeLine(String line) {
1441 _schedule((_) => _processFuture.then( 1441 _schedule((_) => _processFuture.then(
1442 (p) => p.stdin.add('$line\n'.codeUnits))); 1442 (p) => p.stdin.writeln('$line')));
1443 } 1443 }
1444 1444
1445 /// Kills the process, and waits until it's dead. 1445 /// Kills the process, and waits until it's dead.
1446 void kill() { 1446 void kill() {
1447 _endScheduled = true; 1447 _endScheduled = true;
1448 _schedule((_) { 1448 _schedule((_) {
1449 _endExpected = true; 1449 _endExpected = true;
1450 _process.kill(); 1450 _process.kill();
1451 timeout(_exitCodeFuture, _SCHEDULE_TIMEOUT, 1451 timeout(_exitCodeFuture, _SCHEDULE_TIMEOUT,
1452 "waiting for process $name to die"); 1452 "waiting for process $name to die");
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 /// calling [completion] is unnecessary. 1633 /// calling [completion] is unnecessary.
1634 void expectLater(Future actual, matcher, {String reason, 1634 void expectLater(Future actual, matcher, {String reason,
1635 FailureHandler failureHandler, bool verbose: false}) { 1635 FailureHandler failureHandler, bool verbose: false}) {
1636 _schedule((_) { 1636 _schedule((_) {
1637 return actual.then((value) { 1637 return actual.then((value) {
1638 expect(value, matcher, reason: reason, failureHandler: failureHandler, 1638 expect(value, matcher, reason: reason, failureHandler: failureHandler,
1639 verbose: false); 1639 verbose: false);
1640 }); 1640 });
1641 }); 1641 });
1642 } 1642 }
OLDNEW
« no previous file with comments | « utils/tests/pub/pub_uploader_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698