Skip to content

Commit 7117b21

Browse files
committed
Clean up output and conceal namespaces
1 parent ba29609 commit 7117b21

File tree

2 files changed

+50
-12
lines changed

2 files changed

+50
-12
lines changed

autoload/OmniSharp/testrunner.vim

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,34 @@ function! s:Paint() abort
6666
for testproject in sort(keys(job.tests))
6767
call add(lines, testproject)
6868
for testfile in sort(keys(job.tests[testproject]))
69-
call add(lines, ' ' . fnamemodify(testfile, ':.'))
69+
call add(lines, ' ' . fnamemodify(testfile, ':.'))
7070
let tests = job.tests[testproject][testfile]
7171
for name in sort(keys(tests), {a,b -> tests[a].lnum > tests[b].lnum})
7272
let test = tests[name]
7373
let state = s:utils.state2char[test.state]
74-
call add(lines, printf('%s %s', state, name))
74+
call add(lines, printf('%s %s', state, name))
7575
if state ==# '-' && !has_key(test, 'spintimer')
7676
call s:spinner.start(test, len(lines))
7777
endif
7878
let message = get(test, 'message', [])
7979
if len(message)
8080
for messageline in message
81-
call add(lines, '> ' . trim(messageline, ' ', 2))
81+
call add(lines, '> ' . trim(messageline, ' ', 2))
8282
endfor
8383
endif
8484
let stacktrace = get(test, 'stacktrace', [])
8585
if len(stacktrace)
86-
for stacktraceline in stacktrace
87-
call add(lines, '> ' . trim(stacktraceline, ' ', 2))
86+
for st in stacktrace
87+
let line = trim(st.text)
88+
if has_key(st, 'filename')
89+
let line = '__ ' . line . ' __'
90+
else
91+
let line = '_._ ' . line . ' _._'
92+
endif
93+
if has_key(st, 'lnum')
94+
let line .= ' line ' . st.lnum
95+
endif
96+
call add(lines, '> ' . line)
8897
endfor
8998
endif
9099
let output = get(test, 'output', [])
@@ -137,13 +146,32 @@ endfunction
137146

138147
function! s:UpdateState(bufnr, testnames, state, ...) abort
139148
let message = a:0 ? a:1 : []
140-
let stacktrace = a:0 > 1 ? a:2 : []
149+
let stacktraceraw = a:0 > 1 ? a:2 : []
141150
let output = a:0 > 2 ? a:3 : []
142151
let projectname = s:utils.getProjectName(a:bufnr)
143152
let filename = fnamemodify(bufname(a:bufnr), ':p')
144153
let tests = OmniSharp#GetHost(a:bufnr).job.tests[projectname][filename]
145154
for testname in a:testnames
146155
if has_key(tests, testname)
156+
let stacktrace = []
157+
for st in stacktraceraw
158+
let parsed = matchlist(st, 'at \(.\+\) in \([^:]\+\)\(:line \(\d\+\)\)\?')
159+
if len(parsed)
160+
call add(stacktrace, {
161+
\ 'text': parsed[1],
162+
\ 'filename': parsed[2],
163+
\ 'lnum': str2nr(parsed[4])
164+
\})
165+
else
166+
let parsed = matchlist(st, 'at \(.\+\)')
167+
if len(parsed)
168+
call add(stacktrace, {'text': parsed[1]})
169+
else
170+
call add(stacktrace, {'text': st})
171+
endif
172+
endif
173+
endfor
174+
147175
let tests[testname].state = a:state
148176
let tests[testname].message = message
149177
let tests[testname].stacktrace = stacktrace

syntax/omnisharptest.vim

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,30 @@ syn region ostIntro start="\%1l" end="^$" contains=ostIntroDelim transparent
99
syn match ostIntroDelim "^=\+$" contained
1010

1111
syn region ostProject matchgroup=ostProjectName start="^\a.*" end="^$"me=s-1 contains=TOP transparent fold
12-
syn region ostFile matchgroup=ostFileName start="^ \S.*" end="^__$"me=s-1 contains=TOP transparent fold
12+
syn region ostFile start="^ \S.*" end="^__$"me=s-1 contains=TOP transparent fold
13+
syn match ostFileName "^ \S.*" contains=ostFilePath,ostFileExt
14+
syn match ostFilePath "^ \zs\%(\%(\w\+\.\)*\w\+\/\)*\ze\w\+\." conceal contained
15+
syn match ostFileExt "\%(\.\w\+\)\+" conceal contained
1316
syn match ostFileDivider "^__$" conceal
1417

15-
syn match ostStateNotRun "^|.*" contains=ostStatePrefix
16-
syn match ostStateRunning "^-.*" contains=ostStatePrefix,ostRunningSuffix
17-
syn match ostStatePassed "^\*.*" contains=ostStatePrefix
18-
syn match ostStateFailed "^!.*" contains=ostStatePrefix
18+
syn match ostStateNotRun "^|.*" contains=ostStatePrefix,ostTestNamespace
19+
syn match ostStateRunning "^-.*" contains=ostStatePrefix,ostTestNamespace,ostRunningSuffix
20+
syn match ostStatePassed "^\*.*" contains=ostStatePrefix,ostTestNamespace
21+
syn match ostStateFailed "^!.*" contains=ostStatePrefix,ostTestNamespace
1922
syn match ostStatePrefix "^[|\*!-]" conceal contained
23+
syn match ostTestNamespace "\%(\w\+\.\)*\ze\w\+" conceal contained
2024

2125
syn match ostRunningSuffix " -- .*" contained contains=ostRunningSpinner,ostRunningSuffixDivider
2226
syn match ostRunningSuffixDivider " \zs--" conceal contained
2327
syn match ostRunningSpinner " -- \zs.*" contained
2428

25-
syn region ostFailure start="^>" end="^[^>]"me=s-1 contains=ostFailurePrefix fold
29+
syn region ostFailure start="^>" end="^[^>]"me=s-1 contains=ostFailurePrefix,ostStackFile,ostStackFileNoLoc fold
2630
syn match ostFailurePrefix "^>" conceal contained
31+
syn region ostStackFile start=" __ "hs=e+1 end=" __" contains=ostStackFileDelimiter,ostStackFileNamespace contained keepend
32+
syn match ostStackFileDelimiter " __" conceal contained
33+
syn region ostStackFileNoLoc start=" _._ "hs=e+1 end=" _._" contains=ostStackFileNoLocDelimiter,ostStackFileNamespace contained keepend
34+
syn match ostStackFileNoLocDelimiter " _._" conceal contained
35+
syn match ostStackFileNamespace "\%(\w\+\.\)*\ze\w\+\.\w\+(" conceal contained
2736
syn region ostOutput start="^//" end="^[^/]"me=s-1 contains=ostOutputPrefix fold
2837
syn match ostOutputPrefix "^//" conceal contained
2938

@@ -35,6 +44,7 @@ hi def link ostStateRunning Identifier
3544
hi def link ostRunningSpinner Normal
3645
hi def link ostStatePassed Title
3746
hi def link ostStateFailed WarningMsg
47+
hi def link ostStackFile Underlined
3848
hi def link ostOutput Comment
3949

4050
let b:current_syntax = 'omnisharptest'

0 commit comments

Comments
 (0)