Chromium Code Reviews| Index: tests/standalone/debugger/basic_debugger_test.dart |
| =================================================================== |
| --- tests/standalone/debugger/basic_debugger_test.dart (revision 20550) |
| +++ tests/standalone/debugger/basic_debugger_test.dart (working copy) |
| @@ -10,7 +10,13 @@ |
| // of the debug target process. |
| import "debug_lib.dart"; |
| +import "dart:io"; |
| +import "dart:math"; |
| +var debugPort; |
| +var retries = 0; |
| +var random = new Random(); |
|
hausner
2013/03/28 00:31:21
Does this generate a different random number each
Tom Ball
2013/03/28 18:19:43
Updated to use current time in milliseconds as see
|
| + |
| bar(x) { |
| print(x); |
| } |
| @@ -20,13 +26,36 @@ |
| print(i); |
| } |
| -main() { |
| - if (RunScript(testScript)) return; |
| +void runTest() { |
| + if (RunScript(testScript, debugPort)) return; |
| print("Hello from debuggee"); |
| foo(42); |
| print("Hello again"); |
| } |
| +void main() { |
|
hausner
2013/03/28 00:31:21
It might be more convenient to put this functional
Tom Ball
2013/03/28 18:19:43
Done -- this reverted all changes to this specific
|
| + var options = new Options(); |
| + if (options.arguments.contains("--debuggee")) { |
| + runTest(); |
| + } else { |
| + // Pick a port in the upper half of the port number range. |
| + debugPort = random.nextInt(32000) + 32000; |
| + print('using debug port $debugPort ...'); |
| + ServerSocket.bind('127.0.0.1', debugPort).then((ServerSocket s) { |
| + s.close(); |
| + runTest(); |
| + }, |
| + onError: (e) { |
| + if (++retries >= 3) { |
| + print('unable to find unused port: $e'); |
| + return -1; |
| + } else { |
| + // Retry with another random port. |
| + main(); |
| + } |
| + }); |
| + } |
| +} |
| // Expected debugger events and commands. |
| var testScript = [ |
| @@ -34,10 +63,10 @@ |
| MatchFrame(0, "main"), // Top frame in trace is function "main". |
| Step(), |
| Breakpoint(function: "main"), |
| - SetBreakpoint(15), // Set breakpoint a line 15, in function bar. |
| + SetBreakpoint(21), // Set breakpoint a line 21, in function bar. |
| Resume(), |
| Breakpoint(function: "bar"), |
| - MatchFrames(["bar", "foo", "main"]), |
| + MatchFrames(["bar", "foo", "runTest", "main"]), |
| MatchFrame(1, "foo"), |
| Resume(), |
| ]; |