From ba9769802c3538c1c2036bf50a28bd9c4ceced59 Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 24 Jun 2015 13:52:11 -0700 Subject: [PATCH 1/3] Adjust regex pattern for match file names in Gecko-style traces The pattern for Gecko-style traces can match both URLs that start with a protocol and also local file paths when running scripts in JavaScriptCore. Allow files to start with any non-space character which covers periods, hyphens, and underscores for example. --- lib/stacktrace-parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stacktrace-parser.js b/lib/stacktrace-parser.js index 1453f95..5a3fc7a 100644 --- a/lib/stacktrace-parser.js +++ b/lib/stacktrace-parser.js @@ -9,7 +9,7 @@ var StackTraceParser = { */ parse: function(stackString) { var chrome = /^\s*at (?:(?:(?:Anonymous function)?|((?:\[object object\])?\S+(?: \[as \S+\])?)) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i, - gecko = /^(?:\s*(\S*)(?:\((.*?)\))?@)?((?:\w).*?):(\d+)(?::(\d+))?\s*$/i, + gecko = /^(?:\s*(\S*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i, node = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i, lines = stackString.split('\n'), stack = [], From e32d48a77fe0a6b2c987da1d6598cce56e250b28 Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 24 Jun 2015 14:00:58 -0700 Subject: [PATCH 2/3] Add test cases for io.js stack traces and add 1.x and 2.x engines list --- package.json | 2 +- test/stacktrace_parser_test.js | 46 +++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7e92b1..050a3de 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Parses every stack trace into a nicely formatted array of hashes.", "version": "0.1.1", "engines": { - "node": "~0.10" + "node": "0.10 - 2" }, "dependencies": {}, "devDependencies": { diff --git a/test/stacktrace_parser_test.js b/test/stacktrace_parser_test.js index 8696870..ba6ed09 100644 --- a/test/stacktrace_parser_test.js +++ b/test/stacktrace_parser_test.js @@ -262,7 +262,51 @@ describe('StackTraceParser', function() { methodName: 'Timer.listOnTimeout [as ontimeout]', lineNumber: 110, column: 15 } ] - } + }, + // io.js 2.3.0 + { + from: "ReferenceError: test is not defined\n at repl:1:1\n at REPLServer.defaultEval (repl.js:154:27)\n at bound (domain.js:254:14)\n at REPLServer.runBound [as eval] (domain.js:267:12)\n at REPLServer. (repl.js:308:12)\n at emitOne (events.js:77:13)\n at REPLServer.emit (events.js:169:7)\n at REPLServer.Interface._onLine (readline.js:209:10)\n at REPLServer.Interface._line (readline.js:548:8)\n at REPLServer.Interface._ttyWrite (readline.js:825:14)", + to: [ { file: 'repl', + methodName: '', + lineNumber: 1, + column: 1 }, + { file: 'repl.js', + methodName: 'REPLServer.defaultEval', + lineNumber: 154, + column: 27 }, + { file: 'domain.js', + methodName: 'bound', + lineNumber: 254, + column: 14 }, + { file: 'domain.js', + methodName: 'REPLServer.runBound [as eval]', + lineNumber: 267, + column: 12 }, + { file: 'repl.js', + methodName: 'REPLServer.', + lineNumber: 308, + column: 12 }, + { file: 'events.js', + methodName: 'emitOne', + lineNumber: 77, + column: 13 }, + { file: 'events.js', + methodName: 'REPLServer.emit', + lineNumber: 169, + column: 7 }, + { file: 'readline.js', + methodName: 'REPLServer.Interface._onLine', + lineNumber: 209, + column: 10 }, + { file: 'readline.js', + methodName: 'REPLServer.Interface._line', + lineNumber: 548, + column: 8 }, + { file: 'readline.js', + methodName: 'REPLServer.Interface._ttyWrite', + lineNumber: 825, + column: 14 } ] + }, ] }; From 6f9aa3e545a2dbcef5519bdcd0bc08023558e86a Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 24 Jun 2015 14:07:10 -0700 Subject: [PATCH 3/3] Add .travis.yml file for automatic test runs Run on Node 0.10 and 0.12 and io.js 1.x and 2.x. --- .travis.yml | 6 ++++++ test/stacktrace_parser_test.js | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..80ff4d1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.12" + - "iojs-v2" + - "iojs-v1" diff --git a/test/stacktrace_parser_test.js b/test/stacktrace_parser_test.js index ba6ed09..83b4299 100644 --- a/test/stacktrace_parser_test.js +++ b/test/stacktrace_parser_test.js @@ -263,9 +263,11 @@ describe('StackTraceParser', function() { lineNumber: 110, column: 15 } ] }, - // io.js 2.3.0 + ], + 'io.js': [ + // io.js 2.4.0 { - from: "ReferenceError: test is not defined\n at repl:1:1\n at REPLServer.defaultEval (repl.js:154:27)\n at bound (domain.js:254:14)\n at REPLServer.runBound [as eval] (domain.js:267:12)\n at REPLServer. (repl.js:308:12)\n at emitOne (events.js:77:13)\n at REPLServer.emit (events.js:169:7)\n at REPLServer.Interface._onLine (readline.js:209:10)\n at REPLServer.Interface._line (readline.js:548:8)\n at REPLServer.Interface._ttyWrite (readline.js:825:14)", + from: "ReferenceError: test is not defined\n at repl:1:1\n at REPLServer.defaultEval (repl.js:154:27)\n at bound (domain.js:254:14)\n at REPLServer.runBound [as eval] (domain.js:267:12)\n at REPLServer. (repl.js:308:12)\n at emitOne (events.js:77:13)\n at REPLServer.emit (events.js:169:7)\n at REPLServer.Interface._onLine (readline.js:210:10)\n at REPLServer.Interface._line (readline.js:549:8)\n at REPLServer.Interface._ttyWrite (readline.js:826:14)", to: [ { file: 'repl', methodName: '', lineNumber: 1, @@ -296,15 +298,15 @@ describe('StackTraceParser', function() { column: 7 }, { file: 'readline.js', methodName: 'REPLServer.Interface._onLine', - lineNumber: 209, + lineNumber: 210, column: 10 }, { file: 'readline.js', methodName: 'REPLServer.Interface._line', - lineNumber: 548, + lineNumber: 549, column: 8 }, { file: 'readline.js', methodName: 'REPLServer.Interface._ttyWrite', - lineNumber: 825, + lineNumber: 826, column: 14 } ] }, ]