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

Unified Diff: utils/testrunner/pipeline_utils.dart

Issue 11103015: Added the ability for testrunner to start the HTTP server with a random port and communicate that p… (Closed) Base URL: http://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
===================================================================
--- utils/testrunner/pipeline_utils.dart (revision 13499)
+++ utils/testrunner/pipeline_utils.dart (working copy)
@@ -58,14 +58,12 @@
*/
Future _processHelper(String command, List<String> args,
[int timeout = 300, int procId = 0]) {
- var completer = null;
+ var completer = new Completer();
log.add('Running $command ${Strings.join(args, " ")}');
var timer = null;
var stdoutHandler, stderrHandler;
var process = Process.start(command, args);
- if (procId == 0) {
- completer = new Completer();
- } else {
+ if (procId != 0) {
_procs[procId] = process;
}
process.onStart = () {
@@ -93,7 +91,7 @@
_pipeStream(process.stdout, stdout);
_pipeStream(process.stderr, stderr);
- return (completer == null) ? null : completer.future;
+ return completer.future;
}
void _pipeStream(InputStream stream, List<String> destination) {
@@ -128,17 +126,26 @@
*/
int startProcess(String command, List<String> args) {
int id = _procId++;
- _processHelper(command, args, 3000, id);
+ _processHelper(command, args, 3000, id).then((e) {
+ _procs.remove(id);
+ });
return id;
}
+/** Checks if a process is still running. */
+bool isProcessRunning(int id) {
+ return _procs.containsKey(id);
+}
+
/**
* Stop a process previously started with [startProcess] or [runCommand],
* given the id string.
*/
void stopProcess(int id) {
- Process p = _procs.remove(id);
- p.kill();
+ if (_procs.containsKey(id)) {
+ Process p = _procs.remove(id);
+ p.kill();
+ }
}
/** Delete a file named [fname] if it exists. */

Powered by Google App Engine
This is Rietveld 408576698