1if 1 2 " This is executed only with the eval feature 3 set nocompatible 4 set viminfo= 5 func Count(match, type) 6 if a:type ==# 'executed' 7 let g:executed += (a:match+0) 8 elseif a:type ==# 'failed' 9 let g:failed += a:match+0 10 elseif a:type ==# 'skipped' 11 let g:skipped += 1 12 call extend(g:skipped_output, ["\t" .. a:match]) 13 endif 14 endfunc 15 16 let g:executed = 0 17 let g:skipped = 0 18 let g:failed = 0 19 let g:skipped_output = [] 20 let g:failed_output = [] 21 let output = [""] 22 23 if $TEST_FILTER != '' 24 call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"]) 25 endif 26 27 try 28 " This uses the :s command to just fetch and process the output of the 29 " tests, it doesn't actually replace anything. 30 " And it uses "silent" to avoid reporting the number of matches. 31 silent %s/^Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn 32 silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn 33 silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn 34 35 call extend(output, ["Skipped:"]) 36 call extend(output, skipped_output) 37 38 call extend(output, [ 39 \ "", 40 \ "-------------------------------", 41 \ printf("Executed: %5d Tests", g:executed), 42 \ printf(" Skipped: %5d Tests", g:skipped), 43 \ printf(" %s: %5d Tests", g:failed == 0 ? 'Failed' : 'FAILED', g:failed), 44 \ "", 45 \ ]) 46 if filereadable('test.log') 47 " outputs and indents the failed test result 48 call extend(output, ["", "Failures: "]) 49 let failed_output = filter(readfile('test.log'), { v,k -> !empty(k)}) 50 call extend(output, map(failed_output, { v,k -> "\t".k})) 51 " Add a final newline 52 call extend(output, [""]) 53 endif 54 55 catch " Catch-all 56 finally 57 call writefile(output, 'test_result.log') " overwrites an existing file 58 endtry 59endif 60 61q! 62