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

Unified Diff: utils/testrunner/pipeline_utils.dart

Issue 11091070: Change Process.start to return a future that completes with a (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Restructure to get rid of _onStart and _onError Created 8 years, 2 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/testrunner/layout_test_controller.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/testrunner/pipeline_utils.dart
diff --git a/utils/testrunner/pipeline_utils.dart b/utils/testrunner/pipeline_utils.dart
index bfe600c26166adcdf8dccefeb3dae75e854715be..c1ecb39f4e3bc8b72e0bda3a248af85ec7bf0f32 100644
--- a/utils/testrunner/pipeline_utils.dart
+++ b/utils/testrunner/pipeline_utils.dart
@@ -60,38 +60,39 @@ void writeFile(String fileName, String contents) {
*/
Future _processHelper(String command, List<String> args,
[int timeout = 300, int procId = 0, Function outputMonitor]) {
- var completer = new Completer();
+ var completer = procId == 0 ? new Completer() : null;
log.add('Running $command ${Strings.join(args, " ")}');
var timer = null;
var stdoutHandler, stderrHandler;
- var process = Process.start(command, args);
- if (procId != 0) {
+ var processFuture = Process.start(command, args);
+ processFuture.then((process) {
_procs[procId] = process;
- }
- process.onStart = () {
+
timer = new Timer(1000 * timeout, (t) {
timer = null;
process.kill();
});
- };
- process.onExit = (exitCode) {
- if (timer != null) {
- timer.cancel();
- }
- process.close();
- if (completer != null) {
- completer.complete(exitCode);
- }
- };
- process.onError = (e) {
+
+ process.onExit = (exitCode) {
+ if (timer != null) {
+ timer.cancel();
+ }
+ process.close();
+ if (completer != null) {
+ completer.complete(exitCode);
+ }
+ };
+
+ _pipeStream(process.stdout, stdout, outputMonitor);
+ _pipeStream(process.stderr, stderr, outputMonitor);
+ });
+ processFuture.handleException((e) {
stderr.add("Error starting process:");
stderr.add(" Command: $command");
stderr.add(" Error: $e");
completePipeline(-1);
- };
-
- _pipeStream(process.stdout, stdout, outputMonitor);
- _pipeStream(process.stderr, stderr, outputMonitor);
+ return true;
+ });
return completer.future;
}
« no previous file with comments | « utils/testrunner/layout_test_controller.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698