Mercurial > vim
view src/testdir/summarize.vim @ 17922:4d63d47d87ef v8.1.1957
patch 8.1.1957: more code can be moved to evalvars.c
Commit: https://github.com/vim/vim/commit/da6c03342117fb7f4a8110bd9e8627b612a05a64
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 1 16:01:30 2019 +0200
patch 8.1.1957: more code can be moved to evalvars.c
Problem: More code can be moved to evalvars.c.
Solution: Move code to where it fits better. (Yegappan Lakshmanan,
closes #4883)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Sep 2019 16:15:03 +0200 |
parents | 14122cb0ea3d |
children | ef35a3a70c24 |
line wrap: on
line source
if 1 " This is executed only with the eval feature set nocompatible func Count(match, type) if a:type ==# 'executed' let g:executed += (a:match+0) elseif a:type ==# 'failed' let g:failed += a:match+0 elseif a:type ==# 'skipped' let g:skipped += 1 call extend(g:skipped_output, ["\t".a:match]) endif endfunc let g:executed = 0 let g:skipped = 0 let g:failed = 0 let g:skipped_output = [] let g:failed_output = [] let output = [""] try " This uses the :s command to just fetch and process the output of the " tests, it doesn't actually replace anything. " And it uses "silent" to avoid reporting the number of matches. silent %s/^Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn call extend(output, ["Skipped:"]) 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), \ "", \ ]) 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!