| Index: tests/standalone/debugger/debug_lib.dart
|
| diff --git a/tests/standalone/debugger/debug_lib.dart b/tests/standalone/debugger/debug_lib.dart
|
| index ff51f9ba5c2ae5bfedb7324459bb7af176d7b503..50aee1cfd87ec8cd70be9255fce14b174f8d2a86 100644
|
| --- a/tests/standalone/debugger/debug_lib.dart
|
| +++ b/tests/standalone/debugger/debug_lib.dart
|
| @@ -488,16 +488,33 @@ class Debugger {
|
| }
|
|
|
| void close({killDebugee: false}) {
|
| + void exit() {
|
| + if (errorsDetected) throw "Errors detected";
|
| + exit(errors.length);
|
| + }
|
| if (errorsDetected) {
|
| for (int i = 0; i < errors.length; i++) print(errors[i]);
|
| }
|
| - if (socket != null) socket.close();
|
| + if (socket != null) {
|
| + socket.close().catchError((error) {
|
| + print("Error occured while closing socket: $error");
|
| + };
|
| + }
|
| if (killDebugee) {
|
| - targetProcess.kill();
|
| - print("Target process killed");
|
| + if (!targetProcess.kill()) {
|
| + print("Could not send kill signal to target process.");
|
| + } else {
|
| + print("Successfully sent kill signal to target process.");
|
| + }
|
| + // If the process was already dead exitCode is already
|
| + // available and we call exit() in the next event loop cycle.
|
| + // Otherwise this will wait for the process to exit.
|
| + targetProcess.exitCode.then((exitCode) {
|
| + exit();
|
| + });
|
| + } else {
|
| + exit();
|
| }
|
| - if (errorsDetected) throw "Errors detected";
|
| - exit(errors.length);
|
| }
|
| }
|
|
|
| @@ -508,7 +525,7 @@ bool RunScript(List script) {
|
| return false;
|
| }
|
| verboseWire = options.arguments.contains("--wire");
|
| -
|
| +
|
| // Pick a port in the upper half of the port number range.
|
| var seed = new DateTime.now().millisecondsSinceEpoch;
|
| Random random = new Random(seed);
|
| @@ -536,11 +553,11 @@ bool RunScript(List script) {
|
| });
|
| },
|
| onError: (e) {
|
| - if (++retries >= 3) {
|
| + if (++retries >= 3) {
|
| print('unable to find unused port: $e');
|
| var trace = getAttachedStackTrace(e);
|
| if (trace != null) print("StackTrace: $trace");
|
| - return -1;
|
| + return -1;
|
| } else {
|
| // Retry with another random port.
|
| RunScript(script);
|
|
|