blob: 4a88935a40aac97cd8ae625df13b772d796bbfe3 [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
11 call extend(g:skipped_output, ["\t".a:match])
12 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
22 try
23 " This uses the :s command to just fetch and process the output of the
Bram Moolenaarf1e05442019-08-20 21:25:46 +020024 " tests, it doesn't acutally replace anything.
25 " And it uses "silent" to avoid reporting the number of matches.
26 silent %s/^Executed\s\+\zs\d\+\ze\s\+tests/\=Count(submatch(0),'executed')/egn
27 silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn
28 silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020029
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 \ "",
Bram Moolenaarf1e05442019-08-20 21:25:46 +020040 \ ])
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020041 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 Moolenaar9c0cec62019-06-06 13:38:15 +020053 endtry
54endif
55
Bram Moolenaar9c0cec62019-06-06 13:38:15 +020056q!