Skip to content

Commit a59a323

Browse files
committed
Display failure message and exception stack trace
1 parent 00ec883 commit a59a323

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

autoload/OmniSharp/actions/test.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ function! s:run.process(Callback, bufnr, tests, response) abort
305305
if result.Outcome =~? 'failed'
306306
let location.type = 'E'
307307
let location.text = location.name . ': ' . result.ErrorMessage
308+
let location.message = split(result.ErrorMessage, '\r\?\n')
309+
let location.stacktrace = split(result.ErrorStackTrace, '\r\?\n')
308310
let st = result.ErrorStackTrace
309311
let parsed = matchlist(st, '.* in \(.\+\):line \(\d\+\)')
310312
if len(parsed) > 0

autoload/OmniSharp/testrunner.vim

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,27 @@ function! s:Paint() abort
6969
let tests = job.tests[testproject][testfile]
7070
for name in sort(keys(tests), {a,b -> tests[a].lnum > tests[b].lnum})
7171
let test = tests[name]
72-
let state = s:utils.state2char[test.state]
72+
let state = s:utils.state2char[test.state]
7373
call add(lines, printf('%s %s', state, name))
7474
if state ==# '-' && !has_key(test, 'spintimer')
7575
call s:spinner.start(test, len(lines))
7676
endif
77+
let message = get(test, 'message', [])
78+
if len(message)
79+
for messageline in message
80+
call add(lines, '> ' . trim(messageline, ' ', 2))
81+
endfor
82+
endif
83+
let stacktrace = get(test, 'stacktrace', [])
84+
if len(stacktrace)
85+
for stacktraceline in stacktrace
86+
call add(lines, '> ' . trim(stacktraceline, ' ', 2))
87+
endfor
88+
endif
7789
let output = get(test, 'output', [])
7890
if len(output)
7991
for outputline in output
80-
call add(lines, '// ' . outputline)
92+
call add(lines, '// ' . trim(outputline, ' ', 2))
8193
endfor
8294
endif
8395
endfor
@@ -122,14 +134,19 @@ function! OmniSharp#testrunner#SetTests(bufferTests) abort
122134
call win_gotoid(winid)
123135
endfunction
124136

125-
function! s:UpdateState(bufnr, testnames, state, output) abort
137+
function! s:UpdateState(bufnr, testnames, state, ...) abort
138+
let message = a:0 ? a:1 : []
139+
let stacktrace = a:0 > 1 ? a:2 : []
140+
let output = a:0 > 2 ? a:3 : []
126141
let projectname = s:utils.getProjectName(a:bufnr)
127142
let filename = fnamemodify(bufname(a:bufnr), ':p')
128143
let tests = OmniSharp#GetHost(a:bufnr).job.tests[projectname][filename]
129144
for testname in a:testnames
130145
if has_key(tests, testname)
131146
let tests[testname].state = a:state
132-
let tests[testname].output = a:output
147+
let tests[testname].message = message
148+
let tests[testname].stacktrace = stacktrace
149+
let tests[testname].output = output
133150
endif
134151
endfor
135152
call s:Repaint()
@@ -138,7 +155,7 @@ endfunction
138155
function! OmniSharp#testrunner#StateRunning(bufnr, testnames) abort
139156
let testnames = type(a:testnames) == type([]) ? a:testnames : [a:testnames]
140157
let s:lasttestnames = testnames
141-
call s:UpdateState(a:bufnr, testnames, 'Running', [])
158+
call s:UpdateState(a:bufnr, testnames, 'Running')
142159
endfunction
143160

144161
function! OmniSharp#testrunner#StateComplete(location) abort
@@ -149,12 +166,14 @@ function! OmniSharp#testrunner#StateComplete(location) abort
149166
else
150167
let state = 'Passed'
151168
endif
152-
let output = get(a:location, 'output', [])
153-
call s:UpdateState(a:.location.bufnr, [a:location.fullname], state, output)
169+
call s:UpdateState(a:.location.bufnr, [a:location.fullname], state,
170+
\ get(a:location, 'message', []),
171+
\ get(a:location, 'stacktrace', []),
172+
\ get(a:location, 'output', []))
154173
endfunction
155174

156175
function! OmniSharp#testrunner#StateSkipped(bufnr) abort
157-
call s:UpdateState(a:bufnr, s:lasttestnames, 'Not run', [])
176+
call s:UpdateState(a:bufnr, s:lasttestnames, 'Not run')
158177
endfunction
159178

160179

syntax/omnisharptest.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ syn match ostRunningSuffix " -- .*" contained contains=ostRunningSpinner,ostRun
2222
syn match ostRunningSuffixDivider " \zs--" conceal contained
2323
syn match ostRunningSpinner " -- \zs.*" contained
2424

25+
syn region ostFailure start="^>" end="^[^>]"me=s-1 contains=ostFailurePrefix fold
26+
syn match ostFailurePrefix "^>" conceal contained
2527
syn region ostOutput start="^//" end="^[^/]"me=s-1 contains=ostOutputPrefix fold
2628
syn match ostOutputPrefix "^//" conceal contained
2729

0 commit comments

Comments
 (0)