2020-08-13 16:11:29 -07:00
|
|
|
set cpo&vim
|
2019-08-19 20:04:15 -07:00
|
|
|
if 1
|
2019-08-20 12:56:57 -07:00
|
|
|
" This is executed only with the eval feature
|
|
|
|
set nocompatible
|
2019-12-29 20:43:38 -07:00
|
|
|
set viminfo=
|
2019-08-19 20:04:15 -07:00
|
|
|
func Count(match, type)
|
|
|
|
if a:type ==# 'executed'
|
|
|
|
let g:executed += (a:match+0)
|
|
|
|
elseif a:type ==# 'failed'
|
2019-08-19 23:30:13 -07:00
|
|
|
let g:failed += a:match+0
|
2019-08-19 20:04:15 -07:00
|
|
|
elseif a:type ==# 'skipped'
|
|
|
|
let g:skipped += 1
|
2019-12-29 20:42:51 -07:00
|
|
|
call extend(g:skipped_output, ["\t" .. a:match])
|
2019-08-19 20:04:15 -07:00
|
|
|
endif
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
let g:executed = 0
|
|
|
|
let g:skipped = 0
|
|
|
|
let g:failed = 0
|
|
|
|
let g:skipped_output = []
|
|
|
|
let g:failed_output = []
|
|
|
|
let output = [""]
|
|
|
|
|
2019-12-29 20:42:51 -07:00
|
|
|
if $TEST_FILTER != ''
|
|
|
|
call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"])
|
|
|
|
endif
|
|
|
|
|
2019-08-19 20:04:15 -07:00
|
|
|
try
|
|
|
|
" This uses the :s command to just fetch and process the output of the
|
2019-08-30 13:48:46 -07:00
|
|
|
" tests, it doesn't actually replace anything.
|
2019-08-20 12:56:57 -07:00
|
|
|
" And it uses "silent" to avoid reporting the number of matches.
|
2020-06-23 08:55:56 -07:00
|
|
|
silent %s/Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn
|
2019-08-20 12:56:57 -07:00
|
|
|
silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn
|
|
|
|
silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn
|
2019-08-19 20:04:15 -07:00
|
|
|
|
2024-07-16 19:19:31 -07:00
|
|
|
call extend(output, ["Skipped:"])
|
2019-08-19 20:04:15 -07:00
|
|
|
call extend(output, skipped_output)
|
|
|
|
|
|
|
|
call extend(output, [
|
|
|
|
\ "",
|
|
|
|
\ "-------------------------------",
|
|
|
|
\ printf("Executed: %5d Tests", g:executed),
|
|
|
|
\ printf(" Skipped: %5d Tests", g:skipped),
|
|
|
|
\ printf(" %s: %5d Tests", g:failed == 0 ? 'Failed' : 'FAILED', g:failed),
|
|
|
|
\ "",
|
2019-08-20 12:56:57 -07:00
|
|
|
\ ])
|
2019-08-19 20:04:15 -07:00
|
|
|
if filereadable('test.log')
|
|
|
|
" outputs and indents the failed test result
|
|
|
|
call extend(output, ["", "Failures: "])
|
|
|
|
let failed_output = filter(readfile('test.log'), { v,k -> !empty(k)})
|
|
|
|
call extend(output, map(failed_output, { v,k -> "\t".k}))
|
|
|
|
" Add a final newline
|
|
|
|
call extend(output, [""])
|
|
|
|
endif
|
|
|
|
|
|
|
|
catch " Catch-all
|
|
|
|
finally
|
|
|
|
call writefile(output, 'test_result.log') " overwrites an existing file
|
|
|
|
endtry
|
|
|
|
endif
|
|
|
|
|
|
|
|
q!
|