blob: d0d4e00b2c16ba54b3502552b56c8b37bf3b544e [file] [log] [blame]
Bram Moolenaarc7719082020-08-13 19:42:39 +02001set cpo&vim
Bram Moolenaar9c0cec62019-06-06 13:38:15 +02002if 1
Bram Moolenaarf1e05442019-08-20 21:25:46 +02003 " This is executed only with the eval feature
4 set nocompatible
Bram Moolenaareb698d02019-12-30 00:07:57 +01005 set viminfo=
Bram Moolenaar9c0cec62019-06-06 13:38:15 +02006 func Count(match, type)
7 if a:type ==# 'executed'
8 let g:executed += (a:match+0)
9 elseif a:type ==# 'failed'
Bram Moolenaar150f0552019-06-07 21:29:50 +020010 let g:failed += a:match+0
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020011 elseif a:type ==# 'skipped'
12 let g:skipped += 1
Bram Moolenaara7f6c3c2019-09-27 15:34:16 +020013 call extend(g:skipped_output, ["\t" .. a:match])
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020014 endif
15 endfunc
16
17 let g:executed = 0
18 let g:skipped = 0
19 let g:failed = 0
20 let g:skipped_output = []
21 let g:failed_output = []
22 let output = [""]
23
Bram Moolenaara7f6c3c2019-09-27 15:34:16 +020024 if $TEST_FILTER != ''
25 call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"])
26 endif
27
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020028 try
29 " This uses the :s command to just fetch and process the output of the
Bram Moolenaar60b1bcf2019-08-30 19:05:32 +020030 " tests, it doesn't actually replace anything.
Bram Moolenaarf1e05442019-08-20 21:25:46 +020031 " And it uses "silent" to avoid reporting the number of matches.
Bram Moolenaar7eaafe62020-06-22 22:10:06 +020032 silent %s/Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn
Bram Moolenaarf1e05442019-08-20 21:25:46 +020033 silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn
34 silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020035
Bram Moolenaar94722c52023-01-28 19:19:03 +000036 call extend(output, ["Skipped:"])
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020037 call extend(output, skipped_output)
38
39 call extend(output, [
40 \ "",
41 \ "-------------------------------",
42 \ printf("Executed: %5d Tests", g:executed),
43 \ printf(" Skipped: %5d Tests", g:skipped),
44 \ printf(" %s: %5d Tests", g:failed == 0 ? 'Failed' : 'FAILED', g:failed),
45 \ "",
Bram Moolenaarf1e05442019-08-20 21:25:46 +020046 \ ])
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020047 if filereadable('test.log')
48 " outputs and indents the failed test result
49 call extend(output, ["", "Failures: "])
50 let failed_output = filter(readfile('test.log'), { v,k -> !empty(k)})
51 call extend(output, map(failed_output, { v,k -> "\t".k}))
52 " Add a final newline
53 call extend(output, [""])
54 endif
55
56 catch " Catch-all
57 finally
58 call writefile(output, 'test_result.log') " overwrites an existing file
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020059 endtry
60endif
61
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020062q!