Skip to content

Commit

Permalink
Add success/failure glyph beside completed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nickspoons committed Jul 16, 2022
1 parent 95c0005 commit 8a7d482
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
16 changes: 13 additions & 3 deletions autoload/OmniSharp/testrunner.vim
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,16 @@ function! s:buffer.painttest(test, lnum) abort
endif
let lines = []
let state = s:utils.state2char[a:test.state]
call add(lines, printf('%s %s', state, a:test.name))
let glyph = ''
if state ==# '*' && get(g:, 'OmniSharp_testrunner_glyph', 1)
let glyph = get(g:, 'OmniSharp_testrunner_glyph_passed', '')
elseif state ==# '!' && get(g:, 'OmniSharp_testrunner_glyph', 1)
let glyph = get(g:, 'OmniSharp_testrunner_glyph_failed', '')
endif
if glyph !=# ''
let glyph = printf('|| %s || ', glyph)
endif
call add(lines, printf('%s %s%s', state, glyph, a:test.name))
if state ==# '-' && !has_key(a:test, 'spintimer')
call s:spinner.start(a:test, a:lnum)
endif
Expand Down Expand Up @@ -434,7 +443,7 @@ function! s:UpdateState(bufnr, state, ...) abort
let lines = getbufline(s:runner.bufnr, 1, '$')
let pattern = '^ ' . substitute(filename, '/', '\\/', 'g')
let fileline = match(lines, pattern) + 1
let pattern = '^[-|*!] ' . testname
let pattern = '^[-|*!] \%(|| .\{-} || \)\?' . testname
let testline = match(lines, pattern, fileline) + 1

let patterns = ['^[-|*!] \S', '^__$', '^$']
Expand Down Expand Up @@ -593,7 +602,8 @@ function! s:utils.findTest() abort
let testline = search(testpattern, 'bcnWz')
endif
if testline > 0
let testname = matchlist(getline(testline), '[-|*!] \zs.*$')[0]
let line = getline(testline)
let testname = matchlist(line, '[-|*!] \%(|| .\{-} || \)\?\zs.*$')[0]
let projectline = search('^;', 'bcnWz')
let projectkey = matchlist(getline(projectline), '^\S\+')[0]
let fileline = search('^ \f', 'bcnWz')
Expand Down
11 changes: 9 additions & 2 deletions syntax/omnisharptest.vim
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ syn match ostFileDivider "^__$" conceal

syn match ostStateNotRun "^|.*" contains=ostStatePrefix,ostTestNamespace
syn match ostStateRunning "^-.*" contains=ostStatePrefix,ostTestNamespace,ostRunningSuffix
syn match ostStatePassed "^\*.*" contains=ostStatePrefix,ostTestNamespace
syn match ostStateFailed "^!.*" contains=ostStatePrefix,ostTestNamespace
syn match ostStatePassed "^\*.*" contains=ostStatePrefix,ostTestNamespace,ostStatePassedGlyph,ostCompletePrefixDivider
syn match ostStateFailed "^!.*" contains=ostStatePrefix,ostTestNamespace,ostStateFailedGlyph,ostCompletePrefixDivider
syn match ostStatePrefix "^[|\*!-]" conceal contained
syn match ostTestNamespace "\%(\w\+\.\)*\ze\w\+" conceal contained

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

syn match ostStatePassedGlyph "\%(|| \)\@<=.\{-}\ze || " contained
syn match ostStateFailedGlyph "\%(|| \)\@<=.\{-}\ze || " contained
syn match ostCompletePrefixDivider "|| " conceal contained

syn region ostFailure start="^>" end="^[^>]"me=s-1 contains=ostFailurePrefix,ostStackLoc,ostStackNoLoc fold
syn match ostFailurePrefix "^>" conceal contained
syn region ostStackLoc start=" __ "hs=e+1 end=" __ "he=e-1 contains=ostStackFile,ostStackDelimiter,ostStackNamespace contained keepend
Expand All @@ -66,7 +70,9 @@ hi def link ostStateNotRun Comment
hi def link ostStateRunning Identifier
hi def link ostRunningSpinner Normal
hi def link ostStatePassed Title
hi def link ostStatePassedGlyph Title
hi def link ostStateFailed WarningMsg
hi def link ostStateFailedGlyph WarningMsg
hi def link ostStackLoc Identifier
hi def link ostOutput Comment

Expand All @@ -78,6 +84,7 @@ hi def link ostFileDivider NonText
hi def link ostStatePrefix NonText
hi def link ostFailurePrefix NonText
hi def link ostRunningSuffixDivider NonText
hi def link ostCompletePrefixDivider NonText
hi def link ostStackDelimiter NonText
hi def link ostStackFileDelimiter NonText
hi def link ostStackNoLocDelimiter NonText
Expand Down

0 comments on commit 8a7d482

Please sign in to comment.