Revision: 2695 Author: [email protected] Date: Mon Aug 17 02:31:58 2009 Log: Fix issue 420: accept truncated log files.
http://code.google.com/p/v8/issues/detail?id=420 Review URL: http://codereview.chromium.org/171038 http://code.google.com/p/v8/source/detail?r=2695 Modified: /branches/bleeding_edge/test/mjsunit/mjsunit.js /branches/bleeding_edge/test/mjsunit/tools/logreader.js /branches/bleeding_edge/tools/logreader.js ======================================= --- /branches/bleeding_edge/test/mjsunit/mjsunit.js Fri Apr 24 01:13:09 2009 +++ /branches/bleeding_edge/test/mjsunit/mjsunit.js Mon Aug 17 02:31:58 2009 @@ -179,9 +179,13 @@ function assertDoesNotThrow(code) { try { - eval(code); + if (typeof code == 'function') { + code(); + } else { + eval(code); + } } catch (e) { - assertTrue(false, "threw an exception"); + assertTrue(false, "threw an exception: " + (e.message || e)); } } ======================================= --- /branches/bleeding_edge/test/mjsunit/tools/logreader.js Thu Jun 18 00:59:13 2009 +++ /branches/bleeding_edge/test/mjsunit/tools/logreader.js Mon Aug 17 02:31:58 2009 @@ -80,3 +80,19 @@ assertEquals('bbbbaaaa', reader.expandBackRef_('bbbb#2:4')); assertEquals('"#1:1"', reader.expandBackRef_('"#1:1"')); })(); + + +// See http://code.google.com/p/v8/issues/detail?id=420 +(function testReadingTruncatedLog() { + // Having an incorrect event in the middle of a log should throw an exception. + var reader1 = new devtools.profiler.LogReader({}); + assertThrows(function() { + reader1.processLogChunk('alias,a,b\nxxxx\nalias,c,d\n'); + }); + + // But having it as the last record should not. + var reader2 = new devtools.profiler.LogReader({}); + assertDoesNotThrow(function() { + reader2.processLogChunk('alias,a,b\nalias,c,d\nxxxx'); + }); +})(); ======================================= --- /branches/bleeding_edge/tools/logreader.js Thu Jun 18 00:59:13 2009 +++ /branches/bleeding_edge/tools/logreader.js Mon Aug 17 02:31:58 2009 @@ -294,8 +294,11 @@ this.dispatchLogRow_(fields); } } catch (e) { - this.printError('line ' + (i + 1) + ': ' + (e.message || e)); - throw e; + // An error on the last line is acceptable since log file can be truncated. + if (i < n - 1) { + this.printError('line ' + (i + 1) + ': ' + (e.message || e)); + throw e; + } } }; --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
