Mercurial > vim
annotate src/testdir/summarize.vim @ 19784:39dbaf2eec63
Added tag v8.2.0448 for changeset 546bdeef35f1bb55bbccccad3ee5fecee677d08b
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 25 Mar 2020 22:30:04 +0100 |
parents | c77d7a415e59 |
children | a51ce93f3e6c |
rev | line source |
---|---|
16951
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 if 1 |
17793
7f95fa061abc
patch 8.1.1893: script to summarize test results can be improved
Bram Moolenaar <Bram@vim.org>
parents:
16976
diff
changeset
|
2 " This is executed only with the eval feature |
7f95fa061abc
patch 8.1.1893: script to summarize test results can be improved
Bram Moolenaar <Bram@vim.org>
parents:
16976
diff
changeset
|
3 set nocompatible |
18995
c77d7a415e59
patch 8.2.0058: running tests changes ~/.viminfo
Bram Moolenaar <Bram@vim.org>
parents:
18184
diff
changeset
|
4 set viminfo= |
16951
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 func Count(match, type) |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 if a:type ==# 'executed' |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 let g:executed += (a:match+0) |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 elseif a:type ==# 'failed' |
16976
7160dcd5c1d2
patch 8.1.1488: summary of tests has incorrect failed count
Bram Moolenaar <Bram@vim.org>
parents:
16955
diff
changeset
|
9 let g:failed += a:match+0 |
16951
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 elseif a:type ==# 'skipped' |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 let g:skipped += 1 |
18184
ef35a3a70c24
patch 8.1.2087: cannot easily select one test function to execute
Bram Moolenaar <Bram@vim.org>
parents:
17901
diff
changeset
|
12 call extend(g:skipped_output, ["\t" .. a:match]) |
16951
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 endif |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 endfunc |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 let g:executed = 0 |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 let g:skipped = 0 |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 let g:failed = 0 |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 let g:skipped_output = [] |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 let g:failed_output = [] |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 let output = [""] |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 |
18184
ef35a3a70c24
patch 8.1.2087: cannot easily select one test function to execute
Bram Moolenaar <Bram@vim.org>
parents:
17901
diff
changeset
|
23 if $TEST_FILTER != '' |
ef35a3a70c24
patch 8.1.2087: cannot easily select one test function to execute
Bram Moolenaar <Bram@vim.org>
parents:
17901
diff
changeset
|
24 call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"]) |
ef35a3a70c24
patch 8.1.2087: cannot easily select one test function to execute
Bram Moolenaar <Bram@vim.org>
parents:
17901
diff
changeset
|
25 endif |
ef35a3a70c24
patch 8.1.2087: cannot easily select one test function to execute
Bram Moolenaar <Bram@vim.org>
parents:
17901
diff
changeset
|
26 |
16951
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 try |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 " This uses the :s command to just fetch and process the output of the |
17901
14122cb0ea3d
patch 8.1.1947: when executing one test the report doesn't show it
Bram Moolenaar <Bram@vim.org>
parents:
17793
diff
changeset
|
29 " tests, it doesn't actually replace anything. |
17793
7f95fa061abc
patch 8.1.1893: script to summarize test results can be improved
Bram Moolenaar <Bram@vim.org>
parents:
16976
diff
changeset
|
30 " And it uses "silent" to avoid reporting the number of matches. |
17901
14122cb0ea3d
patch 8.1.1947: when executing one test the report doesn't show it
Bram Moolenaar <Bram@vim.org>
parents:
17793
diff
changeset
|
31 silent %s/^Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn |
17793
7f95fa061abc
patch 8.1.1893: script to summarize test results can be improved
Bram Moolenaar <Bram@vim.org>
parents:
16976
diff
changeset
|
32 silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn |
7f95fa061abc
patch 8.1.1893: script to summarize test results can be improved
Bram Moolenaar <Bram@vim.org>
parents:
16976
diff
changeset
|
33 silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn |
16951
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 call extend(output, ["Skipped:"]) |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 call extend(output, skipped_output) |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 call extend(output, [ |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 \ "", |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 \ "-------------------------------", |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 \ printf("Executed: %5d Tests", g:executed), |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 \ printf(" Skipped: %5d Tests", g:skipped), |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 \ printf(" %s: %5d Tests", g:failed == 0 ? 'Failed' : 'FAILED', g:failed), |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 \ "", |
17793
7f95fa061abc
patch 8.1.1893: script to summarize test results can be improved
Bram Moolenaar <Bram@vim.org>
parents:
16976
diff
changeset
|
45 \ ]) |
16951
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 if filereadable('test.log') |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 " outputs and indents the failed test result |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 call extend(output, ["", "Failures: "]) |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 let failed_output = filter(readfile('test.log'), { v,k -> !empty(k)}) |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 call extend(output, map(failed_output, { v,k -> "\t".k})) |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 " Add a final newline |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 call extend(output, [""]) |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 endif |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 catch " Catch-all |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 finally |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 call writefile(output, 'test_result.log') " overwrites an existing file |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 endtry |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 endif |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 |
ebdf6cd89910
patch 8.1.1476: no statistics displayed after running tests
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 q! |