Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 1 | if 1 |
Bram Moolenaar | f1e0544 | 2019-08-20 21:25:46 +0200 | [diff] [blame] | 2 | " This is executed only with the eval feature |
| 3 | set nocompatible |
Bram Moolenaar | eb698d0 | 2019-12-30 00:07:57 +0100 | [diff] [blame] | 4 | set viminfo= |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 5 | func Count(match, type) |
| 6 | if a:type ==# 'executed' |
| 7 | let g:executed += (a:match+0) |
| 8 | elseif a:type ==# 'failed' |
Bram Moolenaar | 150f055 | 2019-06-07 21:29:50 +0200 | [diff] [blame] | 9 | let g:failed += a:match+0 |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 10 | elseif a:type ==# 'skipped' |
| 11 | let g:skipped += 1 |
Bram Moolenaar | a7f6c3c | 2019-09-27 15:34:16 +0200 | [diff] [blame] | 12 | call extend(g:skipped_output, ["\t" .. a:match]) |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 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 | |
Bram Moolenaar | a7f6c3c | 2019-09-27 15:34:16 +0200 | [diff] [blame] | 23 | if $TEST_FILTER != '' |
| 24 | call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"]) |
| 25 | endif |
| 26 | |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 27 | try |
| 28 | " This uses the :s command to just fetch and process the output of the |
Bram Moolenaar | 60b1bcf | 2019-08-30 19:05:32 +0200 | [diff] [blame] | 29 | " tests, it doesn't actually replace anything. |
Bram Moolenaar | f1e0544 | 2019-08-20 21:25:46 +0200 | [diff] [blame] | 30 | " And it uses "silent" to avoid reporting the number of matches. |
Bram Moolenaar | 60b1bcf | 2019-08-30 19:05:32 +0200 | [diff] [blame] | 31 | silent %s/^Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn |
Bram Moolenaar | f1e0544 | 2019-08-20 21:25:46 +0200 | [diff] [blame] | 32 | silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn |
| 33 | silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 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 | \ "", |
Bram Moolenaar | f1e0544 | 2019-08-20 21:25:46 +0200 | [diff] [blame] | 45 | \ ]) |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 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 |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 58 | endtry |
| 59 | endif |
| 60 | |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 61 | q! |