-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestListener.ipf
executable file
·354 lines (296 loc) · 10.3 KB
/
TestListener.ipf
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#pragma rtGlobals=1 // Use modern global access method.
// TestListener -- a component of IgorUnit
// This interface can listen to events emitted by TestResult
#ifndef IGORUNIT_TESTLISTENER
#define IGORUNIT_TESTLISTENER
Constant LISTENERTYPE_DEFAULT = 0
Constant LISTENERTYPE_PRINTER = 1
Constant VERBOSITY_LOW = 1
Constant VERBOSITY_HIGH = 2
Static Strconstant TL_DEFAULT_PREFIX = "TLnull"
Structure TestListener
Variable listener_type
Variable verbosity
String output
FUNCREF TLnull_output output_func
FUNCREF TLnull_addTestFailure testfail_func
FUNCREF TLnull_addTestSuccess testsuccess_func
FUNCREF TLnull_addTestError testerror_func
FUNCREF TLnull_addTestIgnore testignore_func
FUNCREF TLnull_addGroupStart groupstart_func
FUNCREF TLnull_addTestStart teststart_func
FUNCREF TLnull_addTestEnd testend_func
FUNCREF TLnull_addAssertSuccess assertsuccess_func
FUNCREF TLnull_addAssertFailure assertfail_func
FUNCREF TLnull_addTestSuiteStart ts_start_func
FUNCREF TLnull_addTestSuiteEnd ts_end_func
EndStructure
Function TL_persist(tl, to_dfref)
STRUCT TestListener &tl
DFREF to_dfref
if (!isDataFolderExists(to_dfref))
NewDataFolder to_dfref
endif
Variable/G to_dfref:listener_type = tl.listener_type
Variable/G to_dfref:verbosity = tl.verbosity
String/G to_dfref:output = tl.output
String funcinfo
funcinfo = FuncRefInfo(tl.output_func)
String/G to_dfref:output_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.testfail_func)
String/G to_dfref:testfail_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.testsuccess_func)
String/G to_dfref:testsuccess_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.testerror_func)
String/G to_dfref:testerror_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.testignore_func)
String/G to_dfref:testignore_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.groupstart_func)
String/G to_dfref:groupstart_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.teststart_func)
String/G to_dfref:teststart_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.testend_func)
String/G to_dfref:testend_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.assertsuccess_func)
String/G to_dfref:assertsuccess_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.assertfail_func)
String/G to_dfref:assertfail_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.ts_start_func)
String/G to_dfref:ts_start_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(tl.ts_end_func)
String/G to_dfref:ts_end_func = Dict_getItem(funcinfo, "NAME")
End
Function TL_load(tl, from_dfref)
STRUCT TestListener &tl
DFREF from_dfref
NVAR listener_type = from_dfref:listener_type
NVAR verbosity = from_dfref:verbosity
SVAR output = from_dfref:output
tl.listener_type = listener_type
tl.verbosity = verbosity
tl.output = output
SVAR output_func = from_dfref:output_func
SVAR testfail_func = from_dfref:testfail_func
SVAR testsuccess_func = from_dfref:testsuccess_func
SVAR testerror_func = from_dfref:testerror_func
SVAR testignore_func = from_dfref:testignore_func
SVAR groupstart_func = from_dfref:groupstart_func
SVAR teststart_func = from_dfref:teststart_func
SVAR testend_func = from_dfref:testend_func
SVAR assertsuccess_func = from_dfref:assertsuccess_func
SVAR assertfail_func = from_dfref:assertfail_func
SVAR ts_start_func = from_dfref:ts_start_func
SVAR ts_end_func = from_dfref:ts_end_func
FUNCREF TLnull_output tl.output_func = $(output_func)
FUNCREF TLnull_addTestFailure tl.testfail_func = $(testfail_func)
FUNCREF TLnull_addTestSuccess tl.testsuccess_func = $(testsuccess_func)
FUNCREF TLnull_addTestError tl.testerror_func = $(testerror_func)
FUNCREF TLnull_addTestIgnore tl.testignore_func = $(testignore_func)
FUNCREF TLnull_addGroupStart tl.groupstart_func = $(groupstart_func)
FUNCREF TLnull_addTestStart tl.teststart_func = $(teststart_func)
FUNCREF TLnull_addTestEnd tl.testend_func = $(testend_func)
FUNCREF TLnull_addAssertSuccess tl.assertsuccess_func = $(assertsuccess_func)
FUNCREF TLnull_addAssertFailure tl.assertfail_func = $(assertfail_func)
FUNCREF TLnull_addTestSuiteStart tl.ts_start_func = $(ts_start_func)
FUNCREF TLnull_addTestSuiteEnd tl.ts_end_func = $(ts_end_func)
End
Function TL_init(tl)
STRUCT TestListener &tl
tl.listener_type = LISTENERTYPE_DEFAULT
tl.verbosity = VERBOSITY_LOW
tl.output = ""
TL_setFuncPointers(tl, TL_DEFAULT_PREFIX)
End
Function TL_setFuncPointers(tl, prefix)
STRUCT TestListener &tl
String prefix
String funcname
funcname = prefix+"_output"
if (isFunctionExists(funcname))
FUNCREF TLnull_output tl.output_func = $(funcname)
endif
funcname = prefix+"_addTestFailure"
if (isFunctionExists(funcname))
FUNCREF TLnull_addTestFailure tl.testfail_func = $(funcname)
endif
funcname = prefix+"_addTestSuccess"
if (isFunctionExists(funcname))
FUNCREF TLnull_addTestSuccess tl.testsuccess_func = $(funcname)
endif
funcname = prefix+"_addTestError"
if (isFunctionExists(funcname))
FUNCREF TLnull_addTestError tl.testerror_func = $(funcname)
endif
funcname = prefix+"_addTestIgnore"
if (isFunctionExists(funcname))
FUNCREF TLnull_addTestIgnore tl.testignore_func = $(funcname)
endif
funcname = prefix+"_addGroupStart"
if (isFunctionExists(funcname))
FUNCREF TLnull_addGroupStart tl.groupstart_func = $(funcname)
endif
funcname = prefix+"_addTestStart"
if (isFunctionExists(funcname))
FUNCREF TLnull_addTestStart tl.teststart_func = $(funcname)
endif
funcname = prefix+"_addTestEnd"
if (isFunctionExists(funcname))
FUNCREF TLnull_addTestEnd tl.testend_func = $(funcname)
endif
funcname = prefix+"_addAssertSuccess"
if (isFunctionExists(funcname))
FUNCREF TLnull_addAssertSuccess tl.assertsuccess_func = $(funcname)
endif
funcname = prefix+"_addAssertFailure"
if (isFunctionExists(funcname))
FUNCREF TLnull_addAssertFailure tl.assertfail_func = $(funcname)
endif
funcname = prefix+"_addTestSuiteStart"
if (isFunctionExists(funcname))
FUNCREF TLnull_addTestSuiteStart tl.ts_start_func = $(funcname)
endif
funcname = prefix+"_addTestSuiteEnd"
if (isFunctionExists(funcname))
FUNCREF TLnull_addTestSuiteEnd tl.ts_end_func = $(funcname)
endif
End
Function TL_setVerbosity(tl, verbosity)
STRUCT TestListener &tl
Variable verbosity
tl.verbosity = verbosity
End
Function/S TL_output(tl, out_string)
STRUCT TestListener &tl
String out_string
return tl.output_func(tl, out_string)
End
Function TL_addTestSuiteStart(tl, tr, ts)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestSuite &ts
return tl.ts_start_func(tl, tr, ts)
End
Function TL_addTestSuiteEnd(tl, tr, ts)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestSuite &ts
return tl.ts_end_func(tl, tr, ts)
End
Function TL_addTestFailure(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
return tl.testfail_func(tl, tr, to)
End
Function TL_addTestSuccess(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
return tl.testsuccess_func(tl, tr, to)
End
Function TL_addTestError(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
return tl.testerror_func(tl, tr, to)
End
Function TL_addTestIgnore(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
return tl.testignore_func(tl, tr, to)
End
Function TL_addGroupStart(tl, tr, groupname)
STRUCT TestListener &tl
STRUCT TestResult &tr
String groupname
return tl.groupstart_func(tl, tr, groupname)
End
Function TL_addTestStart(tl, tr, test)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT UnitTest &test
return tl.teststart_func(tl, tr, test)
End
Function TL_addTestEnd(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
return tl.testend_func(tl, tr, to)
End
Function TL_addAssertFailure(tl, tr, test, assertion)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT UnitTest &test
STRUCT Assertion &assertion
return tl.assertfail_func(tl, tr, test, assertion)
End
Function TL_addAssertSuccess(tl, tr, test, assertion)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT UnitTest &test
STRUCT Assertion &assertion
return tl.assertsuccess_func(tl, tr, test, assertion)
End
Function/S TLnull_output(tl, out_string)
STRUCT TestListener &tl
String out_string
End
Function TLnull_addTestSuiteStart(tl, tr, ts)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestSuite &ts
End
Function TLnull_addTestSuiteEnd(tl, tr, ts)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestSuite &ts
End
Function TLnull_addTestFailure(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
End
Function TLnull_addTestSuccess(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
End
Function TLnull_addTestError(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
End
Function TLnull_addTestIgnore(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
End
Function TLnull_addGroupStart(tl, tr, groupname)
STRUCT TestListener &tl
STRUCT TestResult &tr
String groupname
End
Function TLnull_addTestStart(tl, tr, test)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT UnitTest &test
End
Function TLnull_addTestEnd(tl, tr, to)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT TestOutcome &to
End
Function TLnull_addAssertFailure(tl, tr, test, assertion)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT UnitTest &test
STRUCT Assertion &assertion
End
Function TLnull_addAssertSuccess(tl, tr, test, assertion)
STRUCT TestListener &tl
STRUCT TestResult &tr
STRUCT UnitTest &test
STRUCT Assertion &assertion
End
#endif