Display CoffeeScript line numbers in stack traces

Use coffeestack to convert stack traces to have CoffeeScript
line and column numbers in the output instead of JavaScript line
and column numbers.
This commit is contained in:
Kevin Sawicki 2013-07-06 14:15:04 -07:00
parent adebae6c47
commit e34d8e4c42
2 changed files with 17 additions and 14 deletions

View File

@ -35,6 +35,7 @@
"semver": "1.1.4",
"guid": "0.0.10",
"tantamount": "0.3.0",
"coffeestack": "0.4.0",
"c-tmbundle": "1.0.0",
"coffee-script-tmbundle": "2.0.0",
"css-tmbundle": "1.0.0",

View File

@ -1,6 +1,19 @@
$ = require 'jquery'
{View, $$} = require 'space-pen'
_ = require 'underscore'
{convertStackTrace} = require 'coffeestack'
sourceMaps = {}
formatStackTrace = (stackTrace) ->
return stackTrace unless stackTrace
jasminePath = require.resolve('jasmine')
jasminePattern = new RegExp("\\(#{_.escapeRegExp(jasminePath)}:\\d+:\\d+\\)\\s*$")
convertedLines = []
for line in stackTrace.split('\n')
convertedLines.push(line) unless jasminePattern.test(line)
convertStackTrace(convertedLines.join('\n'), sourceMaps)
module.exports =
class AtomReporter extends View
@ -42,6 +55,7 @@ class AtomReporter extends View
reportSpecResults: (spec) ->
@completeSpecCount++
spec.endedAt = new Date().getTime()
@specComplete(spec)
@updateStatusView(spec)
@ -99,7 +113,7 @@ class AtomReporter extends View
rootSuite = rootSuite.parentSuite while rootSuite.parentSuite
@message.text rootSuite.description
time = "#{Math.round((new Date().getTime() - @startedAt.getTime()) / 10)}"
time = "#{Math.round((spec.endedAt - @startedAt.getTime()) / 10)}"
time = "0#{time}" if time.length < 3
@time.text "#{time[0...-2]}.#{time[-2..]}s"
@ -166,7 +180,7 @@ class SpecResultView extends View
@description.html @spec.description
for result in @spec.results().getItems() when not result.passed()
stackTrace = @formatStackTrace(result.trace.stack)
stackTrace = formatStackTrace(result.trace.stack)
@specFailures.append $$ ->
@div result.message, class: 'resultMessage fail'
@div stackTrace, class: 'stackTrace' if stackTrace
@ -174,18 +188,6 @@ class SpecResultView extends View
attach: ->
@parentSuiteView().append this
formatStackTrace: (stackTrace) ->
return stackTrace unless stackTrace
jasminePath = require.resolve('jasmine')
jasminePattern = new RegExp("\\(#{_.escapeRegExp(jasminePath)}:\\d+:\\d+\\)\\s*$")
convertedLines = []
for line in stackTrace.split('\n')
unless jasminePattern.test(line)
convertedLines.push(line)
convertedLines.join('\n')
parentSuiteView: ->
if not suiteView = $(".suite-view-#{@spec.suite.id}").view()
suiteView = new SuiteResultView(@spec.suite)