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