robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
8634ec3827
master
1set cpo & vim 2if 1 3" This is executed only with the eval feature 4set nocompatible 5set viminfo = 6func Count ( match , type ) 7if a: type ==# 'executed' 8let g: executed += ( a: match + 0 ) 9elseif a: type ==# 'failed' 10let g: failed += a: match + 0 11elseif a: type ==# 'skipped' 12let g: skipped += 1 13call extend ( g: skipped_output , [ "\t" .. a: match ]) 14endif 15endfunc 16 17let g: executed = 0 18let g: skipped = 0 19let g: failed = 0 20let g: skipped_output = [] 21let g: failed_output = [] 22let output = [ "" ] 23 24if $ TEST_FILTER != '' 25call extend ( g: skipped_output , [ "\tAll tests not matching $TEST_FILTER: '" .. $ TEST_FILTER .. "'" ]) 26endif 27 28try 29" This uses the :s command to just fetch and process the output of the 30" tests, it doesn't actually replace anything. 31" And it uses "silent" to avoid reporting the number of matches. 32silent %s /Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn 33silent %s /^SKIPPED \zs. * /\=Count(submatch(0), 'skipped')/egn 34silent %s /^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn 35 36call extend ( output , [ "Skipped:" ]) 37call extend ( output , skipped_output ) 38 39call 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 \"" , 46 \]) 47if filereadable ( 'test.log' ) 48" outputs and indents the failed test result 49call extend ( output , [ "" , "Failures: " ]) 50let failed_output = filter ( readfile ( 'test.log' ), { v , k ->! empty ( k )}) 51call extend ( output , map ( failed_output , { v , k ->"\t" . k })) 52" Add a final newline 53call extend ( output , [ "" ]) 54endif 55 56catch " Catch-all 57finally 58call writefile ( output , 'test_result.log' ) " overwrites an existing file 59endtry 60endif 61 62q !