Bram Moolenaar | c7500f9 | 2019-06-06 14:08:50 +0200 | [diff] [blame] | 1 | set nocp |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 2 | if 1 |
| 3 | " This is executed with the eval feature |
| 4 | set nocp |
| 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 |
| 12 | call extend(g:skipped_output, ["\t".a:match]) |
| 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 | |
| 23 | try |
| 24 | " This uses the :s command to just fetch and process the output of the |
| 25 | " tests, it doesn't acutally replay anything |
| 26 | %s/^Executed\s\+\zs\d\+\ze\s\+tests/\=Count(submatch(0),'executed')/egn |
| 27 | %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn |
| 28 | %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn |
| 29 | |
| 30 | call extend(output, ["Skipped:"]) |
| 31 | call extend(output, skipped_output) |
| 32 | |
| 33 | call extend(output, [ |
| 34 | \ "", |
| 35 | \ "-------------------------------", |
| 36 | \ printf("Executed: %5d Tests", g:executed), |
| 37 | \ printf(" Skipped: %5d Tests", g:skipped), |
| 38 | \ printf(" %s: %5d Tests", g:failed == 0 ? 'Failed' : 'FAILED', g:failed), |
| 39 | \ "", |
| 40 | \ ]) |
| 41 | if filereadable('test.log') |
| 42 | " outputs and indents the failed test result |
| 43 | call extend(output, ["", "Failures: "]) |
| 44 | let failed_output = filter(readfile('test.log'), { v,k -> !empty(k)}) |
| 45 | call extend(output, map(failed_output, { v,k -> "\t".k})) |
| 46 | " Add a final newline |
| 47 | call extend(output, [""]) |
| 48 | endif |
| 49 | |
| 50 | catch " Catch-all |
| 51 | finally |
| 52 | call writefile(output, 'test_result.log') " overwrites an existing file |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 53 | endtry |
| 54 | endif |
| 55 | |
Bram Moolenaar | 9c0cec6 | 2019-06-06 13:38:15 +0200 | [diff] [blame] | 56 | q! |