diff --git a/lib/stack-trace.js b/lib/stack-trace.js index 2a01a87..cbadd58 100644 --- a/lib/stack-trace.js +++ b/lib/stack-trace.js @@ -39,7 +39,7 @@ exports.parse = function(err) { }); } - var lineMatch = line.match(/at (?:(.+)\s+\()?(?:(.+?):(\d+):(\d+)|([^)]+))\)?/); + var lineMatch = line.match(/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/); if (!lineMatch) { return; } diff --git a/test/integration/test-parse.js b/test/integration/test-parse.js index 6f3cf3c..6b93815 100644 --- a/test/integration/test-parse.js +++ b/test/integration/test-parse.js @@ -53,6 +53,19 @@ var stackTrace = require(common.dir.lib + '/stack-trace'); assert.equal(trace.length, 2); })(); +(function testTraceWitoutColumnNumbers() { + var err = {}; + err.stack = +'AssertionError: true == false\n' + +' at Test.fn (/Users/felix/code/node-fast-or-slow/test/fast/example/test-example.js:6)\n' + +' at Test.run (/Users/felix/code/node-fast-or-slow/lib/test.js:45)'; + + var trace = stackTrace.parse(err); + assert.strictEqual(trace[0].getFileName(), "/Users/felix/code/node-fast-or-slow/test/fast/example/test-example.js"); + assert.strictEqual(trace[0].getLineNumber(), 6); + assert.strictEqual(trace[0].getColumnNumber(), null); +})(); + (function testCompareRealWithParsedStackTrace() { var realTrace, err; function TestClass() {