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

Side by Side Diff: utils/pub/io.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | utils/pub/log.dart » ('j') | 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 * Helper functionality to make working with IO easier. 6 * Helper functionality to make working with IO easier.
7 */ 7 */
8 library io; 8 library io;
9 9
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 598 }
599 599
600 var completer = new Completer<String>(); 600 var completer = new Completer<String>();
601 var buffer = new StringBuffer(); 601 var buffer = new StringBuffer();
602 stream.onClosed = () => completer.complete(buffer.toString()); 602 stream.onClosed = () => completer.complete(buffer.toString());
603 stream.onData = () => buffer.add(stream.read()); 603 stream.onData = () => buffer.add(stream.read());
604 stream.onError = (e) => completer.completeException(e, stackTrace); 604 stream.onError = (e) => completer.completeException(e, stackTrace);
605 return completer.future; 605 return completer.future;
606 } 606 }
607 607
608 /// Wrap an InputStream in a ListInputStream. This eagerly drains the [source]
609 /// input stream. This is useful for spawned processes which will not exit until
610 /// their output streams have been drained.
611 /// TODO(rnystrom): Get rid of this once #7218 is fixed.
612 InputStream wrapInputStream(InputStream source) {
613 var sink = new ListInputStream();
614 // TODO(nweiz): Due to issuee 3657, pipeInputToInput naturally avoids calling
615 // both onClosed and onError. If 3657 gets fixed before 7013, we'll need to do
616 // that explicitly.
617 pipeInputToInput(source, sink);
618 return sink;
619 }
620
608 /// Spawns and runs the process located at [executable], passing in [args]. 621 /// Spawns and runs the process located at [executable], passing in [args].
609 /// Returns a [Future] that will complete with the results of the process after 622 /// Returns a [Future] that will complete with the results of the process after
610 /// it has ended. 623 /// it has ended.
611 /// 624 ///
612 /// The spawned process will inherit its parent's environment variables. If 625 /// The spawned process will inherit its parent's environment variables. If
613 /// [environment] is provided, that will be used to augment (not replace) the 626 /// [environment] is provided, that will be used to augment (not replace) the
614 /// the inherited variables. 627 /// the inherited variables.
615 Future<PubProcessResult> runProcess(String executable, List<String> args, 628 Future<PubProcessResult> runProcess(String executable, List<String> args,
616 {workingDir, Map<String, String> environment}) { 629 {workingDir, Map<String, String> environment}) {
617 return _doProcess(Process.run, executable, args, workingDir, environment) 630 return _doProcess(Process.run, executable, args, workingDir, environment)
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 return new Directory(entry); 1032 return new Directory(entry);
1020 } 1033 }
1021 1034
1022 /** 1035 /**
1023 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 1036 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
1024 */ 1037 */
1025 Uri _getUri(uri) { 1038 Uri _getUri(uri) {
1026 if (uri is Uri) return uri; 1039 if (uri is Uri) return uri;
1027 return new Uri.fromString(uri); 1040 return new Uri.fromString(uri);
1028 } 1041 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/log.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698