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

Unified Diff: tests/standalone/debugger/basic_debugger_test.dart

Issue 12796012: Use random debug port in basic_debugger_test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | « no previous file | tests/standalone/debugger/debug_lib.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(),
];
« no previous file with comments | « no previous file | tests/standalone/debugger/debug_lib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698