@@ -6,19 +6,27 @@ for processor in g:ultest#processors
6
6
endif
7
7
endfor
8
8
9
+ function ! s: CallProcessor (event , args ) abort
10
+ for processor in g: ultest #active_processors
11
+ let func = get (processor, a: event , " " )
12
+ if func != " "
13
+ if get (processor, " lua" )
14
+ call luaeval (func ." (unpack(_A))" , a: args )
15
+ else
16
+ call call (func , a: args )
17
+ endif
18
+ endif
19
+ endfor
20
+ endfunction
21
+
9
22
function ultest#process#new (test) abort
10
23
call ultest#process#pre (a: test )
11
24
if index (g: ultest_buffers , a: test .file ) == -1
12
25
let g: ultest_buffers = add (g: ultest_buffers , a: test .file )
13
26
endif
14
27
let tests = getbufvar (a: test .file , " ultest_tests" , {})
15
28
let tests[a: test .id] = a: test
16
- for processor in g: ultest #active_processors
17
- let new = get (processor, " new" , " " )
18
- if new != " "
19
- call function (new )(a: test )
20
- endif
21
- endfor
29
+ call s: CallProcessor (" new" , [a: test ])
22
30
endfunction
23
31
24
32
function ultest#process#start (test) abort
@@ -29,24 +37,14 @@ function ultest#process#start(test) abort
29
37
if has_key (results, a: test .id)
30
38
call remove (results, a: test .id)
31
39
endif
32
- for processor in g: ultest #active_processors
33
- let start = get (processor, " start" , " " )
34
- if start != " "
35
- call function (start )(a: test )
36
- endif
37
- endfor
40
+ call s: CallProcessor (" start" , [a: test ])
38
41
endfunction
39
42
40
43
function ultest#process#move (test) abort
41
44
call ultest#process#pre (a: test )
42
45
let tests = getbufvar (a: test .file , " ultest_tests" )
43
46
let tests[a: test .id] = a: test
44
- for processor in g: ultest #active_processors
45
- let start = get (processor, " move" , " " )
46
- if start != " "
47
- call function (start )(a: test )
48
- endif
49
- endfor
47
+ call s: CallProcessor (" move" , [a: test ])
50
48
endfunction
51
49
52
50
function ultest#process#replace (test, result) abort
@@ -55,12 +53,7 @@ function ultest#process#replace(test, result) abort
55
53
let tests[a: test .id] = a: test
56
54
let results = getbufvar (a: result .file , " ultest_results" )
57
55
let results[a: result .id] = a: result
58
- for processor in g: ultest #active_processors
59
- let exit = get (processor, " replace" , " " )
60
- if exit != " "
61
- call function (exit )(a: result )
62
- endif
63
- endfor
56
+ call s: CallProcessor (" replace" , [a: result ])
64
57
endfunction
65
58
66
59
function ultest#process#clear (test) abort
@@ -73,12 +66,7 @@ function ultest#process#clear(test) abort
73
66
if has_key (results, a: test .id)
74
67
call remove (results, a: test .id)
75
68
endif
76
- for processor in g: ultest #active_processors
77
- let clear = get (processor, " clear" , " " )
78
- if clear != " "
79
- call function (clear )(a: test )
80
- endif
81
- endfor
69
+ call s: CallProcessor (" clear" , [a: test ])
82
70
endfunction
83
71
84
72
function ultest#process#exit (test, result) abort
@@ -90,12 +78,7 @@ function ultest#process#exit(test, result) abort
90
78
let tests[a: test .id] = a: test
91
79
let results = getbufvar (a: result .file , " ultest_results" )
92
80
let results[a: result .id] = a: result
93
- for processor in g: ultest #active_processors
94
- let exit = get (processor, " exit" , " " )
95
- if exit != " "
96
- call function (exit )(a: result )
97
- endif
98
- endfor
81
+ call s: CallProcessor (" exit" , [a: result ])
99
82
endfunction
100
83
101
84
function ultest#process#pre (test) abort
0 commit comments