blob: 7f8f758a7185b4e217a661cc10cb135e42c67f24 [file] [log] [blame]
Bram Moolenaar9c0cec62019-06-06 13:38:15 +02001if 1
Bram Moolenaarf1e05442019-08-20 21:25:46 +02002 " This is executed only with the eval feature
3 set nocompatible
Bram Moolenaareb698d02019-12-30 00:07:57 +01004 set viminfo=
Bram Moolenaar9c0cec62019-06-06 13:38:15 +02005 func Count(match, type)
6 if a:type ==# 'executed'
7 let g:executed += (a:match+0)
8 elseif a:type ==# 'failed'
Bram Moolenaar150f0552019-06-07 21:29:50 +02009 let g:failed += a:match+0
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020010 elseif a:type ==# 'skipped'
11 let g:skipped += 1
Bram Moolenaara7f6c3c2019-09-27 15:34:16 +020012 call extend(g:skipped_output, ["\t" .. a:match])
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020013 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 Moolenaara7f6c3c2019-09-27 15:34:16 +020023 if $TEST_FILTER != ''
24 call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"])
25 endif
26
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020027 try
28 " This uses the :s command to just fetch and process the output of the
Bram Moolenaar60b1bcf2019-08-30 19:05:32 +020029 " tests, it doesn't actually replace anything.
Bram Moolenaarf1e05442019-08-20 21:25:46 +020030 " And it uses "silent" to avoid reporting the number of matches.
Bram Moolenaar7eaafe62020-06-22 22:10:06 +020031 silent %s/Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn
Bram Moolenaarf1e05442019-08-20 21:25:46 +020032 silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn
33 silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020034
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 Moolenaarf1e05442019-08-20 21:25:46 +020045 \ ])
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020046 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 Moolenaar9c0cec62019-06-06 13:38:15 +020058 endtry
59endif
60
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020061q!