Mercurial > vim
comparison src/testdir/summarize.vim @ 16951:ebdf6cd89910 v8.1.1476
patch 8.1.1476: no statistics displayed after running tests
commit https://github.com/vim/vim/commit/9c0cec65f891492314caadeef87a50251a21e630
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 6 13:38:15 2019 +0200
patch 8.1.1476: no statistics displayed after running tests
Problem: No statistics displayed after running tests.
Solution: Summarize the test results. (Christian Brabandt, closes https://github.com/vim/vim/issues/4391)
Also make it possible to report a skipped file.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 06 Jun 2019 13:45:05 +0200 |
parents | |
children | 95975a82df42 |
comparison
equal
deleted
inserted
replaced
16950:a8735038f8d5 | 16951:ebdf6cd89910 |
---|---|
1 if 1 | |
2 " This is executed with the eval feature | |
3 set nocp | |
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 try | |
23 " This uses the :s command to just fetch and process the output of the | |
24 " tests, it doesn't acutally replay anything | |
25 %s/^Executed\s\+\zs\d\+\ze\s\+tests/\=Count(submatch(0),'executed')/egn | |
26 %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn | |
27 %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn | |
28 | |
29 call extend(output, ["Skipped:"]) | |
30 call extend(output, skipped_output) | |
31 | |
32 call extend(output, [ | |
33 \ "", | |
34 \ "-------------------------------", | |
35 \ printf("Executed: %5d Tests", g:executed), | |
36 \ printf(" Skipped: %5d Tests", g:skipped), | |
37 \ printf(" %s: %5d Tests", g:failed == 0 ? 'Failed' : 'FAILED', g:failed), | |
38 \ "", | |
39 \ ]) | |
40 if filereadable('test.log') | |
41 " outputs and indents the failed test result | |
42 call extend(output, ["", "Failures: "]) | |
43 let failed_output = filter(readfile('test.log'), { v,k -> !empty(k)}) | |
44 call extend(output, map(failed_output, { v,k -> "\t".k})) | |
45 " Add a final newline | |
46 call extend(output, [""]) | |
47 endif | |
48 | |
49 catch " Catch-all | |
50 finally | |
51 call writefile(output, 'test_result.log') " overwrites an existing file | |
52 q! | |
53 endtry | |
54 endif | |
55 | |
56 " This is executed without the eval feature | |
57 %d | |
58 r test.log | |
59 w test_result.log | |
60 q! |