-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathruntest.vim
37 lines (33 loc) · 835 Bytes
/
runtest.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
let s:testfile = expand('%')
let s:has_errors = 0
try
execute 'cd' fnamemodify(resolve(expand('<sfile>:p')), ':h')
source plugin/strip_trailing_whitespace.vim
source %
" Query list of functions matching ^Test_
let s:tests = map(split(execute('function /^Test_'), "\n"), 'matchstr(v:val, ''^function \zs\k\+\ze()'')')
for s:test_function in s:tests
let v:errors = []
echo 'Test' s:test_function
try
execute 'call' s:test_function '()'
catch
call add(v:errors, "Uncaught exception in test: " .. v:exception .. " at " .. v:throwpoint)
endtry
if !empty(v:errors)
echo s:testfile .. ':1:Error'
for s:error in v:errors
echo s:error
endfor
let s:has_errors = 1
endif
endfor
catch
echo v:exception
let s:has_errors = 1
endtry
if s:has_errors
cquit! " Quit with an error code
else
quit!
endif