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

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: 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
Index: utils/testrunner/pipeline_utils.dart
diff --git a/utils/testrunner/pipeline_utils.dart b/utils/testrunner/pipeline_utils.dart
index bfe600c26166adcdf8dccefeb3dae75e854715be..95ca04fba7d71b5cbed4888d1f971b2120f30176 100644
--- a/utils/testrunner/pipeline_utils.dart
+++ b/utils/testrunner/pipeline_utils.dart
@@ -60,38 +60,37 @@ 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) {
+ Process.start(command, args).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) {
- 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);
+ process.onExit = (exitCode) {
+ if (timer != null) {
+ timer.cancel();
+ }
+ process.close();
+ if (completer != null) {
+ completer.complete(exitCode);
+ }
+ };
+ process.onError = (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 completer.future;
}
« utils/testrunner/layout_test_controller.dart ('K') | « utils/testrunner/layout_test_controller.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698