blob: 9cf3f694cadbcb8823c71575b54c08dfad51c052 [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 Moolenaar9c0cec62019-06-06 13:38:15 +02004 func Count(match, type)
5 if a:type ==# 'executed'
6 let g:executed += (a:match+0)
7 elseif a:type ==# 'failed'
Bram Moolenaar150f0552019-06-07 21:29:50 +02008 let g:failed += a:match+0
Bram Moolenaar9c0cec62019-06-06 13:38:15 +02009 elseif a:type ==# 'skipped'
10 let g:skipped += 1
Bram Moolenaara7f6c3c2019-09-27 15:34:16 +020011 call extend(g:skipped_output, ["\t" .. a:match])
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020012 endif
13 endfunc
14
15 let g:executed = 0
16 let g:skipped = 0
17 let g:failed = 0
18 let g:skipped_output = []
19 let g:failed_output = []
20 let output = [""]
21
Bram Moolenaara7f6c3c2019-09-27 15:34:16 +020022 if $TEST_FILTER != ''
23 call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"])
24 endif
25
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020026 try
27 " This uses the :s command to just fetch and process the output of the
Bram Moolenaar60b1bcf2019-08-30 19:05:32 +020028 " tests, it doesn't actually replace anything.
Bram Moolenaarf1e05442019-08-20 21:25:46 +020029 " And it uses "silent" to avoid reporting the number of matches.
Bram Moolenaar60b1bcf2019-08-30 19:05:32 +020030 silent %s/^Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn
Bram Moolenaarf1e05442019-08-20 21:25:46 +020031 silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn
32 silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020033
34 call extend(output, ["Skipped:"])
35 call extend(output, skipped_output)
36
37 call extend(output, [
38 \ "",
39 \ "-------------------------------",
40 \ printf("Executed: %5d Tests", g:executed),
41 \ printf(" Skipped: %5d Tests", g:skipped),
42 \ printf(" %s: %5d Tests", g:failed == 0 ? 'Failed' : 'FAILED', g:failed),
43 \ "",
Bram Moolenaarf1e05442019-08-20 21:25:46 +020044 \ ])
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020045 if filereadable('test.log')
46 " outputs and indents the failed test result
47 call extend(output, ["", "Failures: "])
48 let failed_output = filter(readfile('test.log'), { v,k -> !empty(k)})
49 call extend(output, map(failed_output, { v,k -> "\t".k}))
50 " Add a final newline
51 call extend(output, [""])
52 endif
53
54 catch " Catch-all
55 finally
56 call writefile(output, 'test_result.log') " overwrites an existing file
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020057 endtry
58endif
59
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020060q!