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

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

Issue 13741025: Add more error detection to debugger test (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | tools/ddbg.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/debugger/debug_lib.dart
===================================================================
--- tests/standalone/debugger/debug_lib.dart (revision 21113)
+++ tests/standalone/debugger/debug_lib.dart (working copy)
@@ -46,7 +46,22 @@
return msg;
}
- // Returns the character length of the newxt json message in the
+ bool haveGarbage() {
+ if (buffer == null || buffer.length == 0) return false;
+ var i = 0, char = " ";
+ while (i < buffer.length) {
+ char = buffer[i];
+ if (char != " " && char != "\n" && char != "\r" && char != "\t") break;
+ i++;
+ }
+ if (i >= buffer.length) {
+ return false;
+ } else {
+ return char != "{";
+ }
+ }
+
+ // Returns the character length of the next json message in the
// buffer, or 0 if there is only a partial message in the buffer.
// The object value must start with '{' and continues to the
// matching '}'. No attempt is made to otherwise validate the contents
@@ -376,6 +391,12 @@
var msg = responses.getNextMessage();
while (msg != null) {
if (verboseWire) print("RECV: $msg");
+ if (responses.haveGarbage()) {
+ error("Error: leftover text after message: '${responses.buffer}'");
+ error("Previous message may be malformed, was: '$msg'");
+ close(killDebugee: true);
+ return;
+ }
var msgObj = JSON.parse(msg);
handleMessage(msgObj);
if (errorsDetected) {
« no previous file with comments | « no previous file | tools/ddbg.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698