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

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

Issue 11474046: Make sure to drain stderr in tests so that spawned process doesn't hang. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add bug. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/log.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 ba0ba0e86202c2b299e48abb88e1e2f3bf466eb9..61afc27b73c1eb5168a717b8244615d010a5a43e 100644
--- a/utils/tests/pub/test_pub.dart
+++ b/utils/tests/pub/test_pub.dart
@@ -1268,7 +1268,7 @@ Future<Pair<List<String>, List<String>>> schedulePackageValidation(
});
}
-/// A matcher that matches a Pair.
+/// A matcher that matches a Pair.
Matcher pairOf(Matcher firstMatcher, Matcher lastMatcher) =>
new _PairMatcher(firstMatcher, lastMatcher);
@@ -1334,8 +1334,8 @@ class ScheduledProcess {
/// Wraps a [Process] [Future] in a scheduled process.
ScheduledProcess(this.name, Future<Process> process)
: _process = process,
- _stdout = process.transform((p) => new StringInputStream(p.stdout)),
- _stderr = process.transform((p) => new StringInputStream(p.stderr)) {
+ _stdout = process.transform((p) => _wrapStream(p.stdout)),
+ _stderr = process.transform((p) => _wrapStream(p.stderr)) {
_schedule((_) {
if (!_endScheduled) {
@@ -1466,6 +1466,12 @@ class ScheduledProcess {
});
}
+ /// Wraps [source] and ensures it gets eagerly drained. We do this to make
+ /// sure a process will exit even if we don't care about its output.
+ static Future<StringInputStream> _wrapStream(InputStream source) {
+ return new StringInputStream(wrapInputStream(source));
+ }
+
/// Prints the remaining data in the process's stdout and stderr streams.
/// Prints nothing if the straems are empty.
Future _printStreams() {
« no previous file with comments | « utils/pub/log.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698