-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOutputFormat.ipf
executable file
·370 lines (303 loc) · 10.1 KB
/
OutputFormat.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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#ifndef IGORUNIT_OUTPUTFORMAT
#define IGORUNIT_OUTPUTFORMAT
// OutputFormat -- a component of IgorUnit
// This data type handles formats for displaying test results
Static Strconstant OF_DEFAULT_PREFIX = "OFnull"
Structure OutputFormat
String name
FUNCREF OFnull_GroupStart groupstart_func
FUNCREF OFnull_TestStart teststart_func
FUNCREF OFnull_TestSuccess testsuccess_func
FUNCREF OFnull_TestFailure testfail_func
FUNCREF OFnull_TestError testerror_func
FUNCREF OFnull_TestIgnore testignore_func
FUNCREF OFnull_AssertSuccess assertsuccess_func
FUNCREF OFnull_AssertFailure assertfail_func
FUNCREF OFnull_TestSuiteSummary ts_summ_func
FUNCREF OFnull_TestOutcomeSummary to_summ_func
FUNCREF OFnull_AssertionSummary assert_summ_func
EndStructure
#include "OutputFormat_Basic"
#include "OutputFormat_Verbose"
Function OutputFormat_factory(verbosity, of_out)
Variable verbosity
STRUCT OutputFormat &of_out
switch (verbosity)
case VERBOSITY_HIGH:
OFVerbose_init(of_out)
break
case VERBOSITY_LOW:
default:
OFBasic_init(of_out)
break
endswitch
return 0
End
Function OF_init(of)
STRUCT OutputFormat &of
of.name = ""
OF_setFuncPointers(of, OF_DEFAULT_PREFIX)
End
Function OF_setFuncPointers(of, prefix)
STRUCT OutputFormat &of
String prefix
String funcname
funcname = prefix+"_GroupStart"
if (isFunctionExists(funcname))
FUNCREF OFnull_Groupstart of.groupstart_func = $(funcname)
endif
funcname = prefix+"_TestStart"
if (isFunctionExists(funcname))
FUNCREF OFnull_TestStart of.teststart_func = $(funcname)
endif
funcname = prefix+"_TestSuccess"
if (isFunctionExists(funcname))
FUNCREF OFnull_TestSuccess of.testsuccess_func = $(funcname)
endif
funcname = prefix+"_TestFailure"
if (isFunctionExists(funcname))
FUNCREF OFnull_TestFailure of.testfail_func = $(funcname)
endif
funcname = prefix+"_TestError"
if (isFunctionExists(funcname))
FUNCREF OFnull_TestError of.testerror_func = $(funcname)
endif
funcname = prefix+"_TestIgnore"
if (isFunctionExists(funcname))
FUNCREF OFnull_TestIgnore of.testignore_func = $(funcname)
endif
funcname = prefix+"_AssertSuccess"
if (isFunctionExists(funcname))
FUNCREF OFnull_AssertSuccess of.assertsuccess_func = $(funcname)
endif
funcname = prefix+"_AssertFailure"
if (isFunctionExists(funcname))
FUNCREF OFnull_AssertFailure of.assertfail_func = $(funcname)
endif
funcname = prefix+"_TestSuiteSummary"
if (isFunctionExists(funcname))
FUNCREF OFnull_TestSuiteSummary of.ts_summ_func = $(funcname)
endif
funcname = prefix+"_TestOutcomeSummary"
if (isFunctionExists(funcname))
FUNCREF OFnull_TestOutcomeSummary of.to_summ_func = $(funcname)
endif
funcname = prefix+"_AssertionSummary"
if (isFunctionExists(funcname))
FUNCREF OFnull_AssertionSummary of.assert_summ_func = $(funcname)
endif
End
Function OF_persist(of, to_dfref)
STRUCT OutputFormat &of
DFREF to_dfref
if (!isDataFolderExists(to_dfref))
NewDataFolder to_dfref
endif
String/G to_dfref:name = of.name
String funcinfo
funcinfo = FuncRefInfo(of.groupstart_func)
String/G to_dfref:groupstart_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.teststart_func)
String/G to_dfref:teststart_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.testsuccess_func)
String/G to_dfref:testsuccess_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.testfail_func)
String/G to_dfref:testfail_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.testerror_func)
String/G to_dfref:testerror_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.testignore_func)
String/G to_dfref:testignore_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.assertsuccess_func)
String/G to_dfref:assertsuccess_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.assertfail_func)
String/G to_dfref:assertfail_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.ts_summ_func)
String/G to_dfref:ts_summ_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.to_summ_func)
String/G to_dfref:to_summ_func = Dict_getItem(funcinfo, "NAME")
funcinfo = FuncRefInfo(of.assert_summ_func)
String/G to_dfref:assert_summ_func = Dict_getItem(funcinfo, "NAME")
End
Function OF_load(of, from_dfref)
STRUCT OutputFormat &of
DFREF from_dfref
SVAR name = from_dfref:name
of.name = name
SVAR groupstart_func = from_dfref:groupstart_func
SVAR teststart_func = from_dfref:teststart_func
SVAR testsuccess_func = from_dfref:testsuccess_func
SVAR testfail_func = from_dfref:testfail_func
SVAR testerror_func = from_dfref:testerror_func
SVAR testignore_func = from_dfref:testignore_func
SVAR assertsuccess_func = from_dfref:assertsuccess_func
SVAR assertfail_func = from_dfref:assertfail_func
SVAR ts_summ_func = from_dfref:ts_summ_func
SVAR to_summ_func = from_dfref:to_summ_func
SVAR assert_summ_func = from_dfref:assert_summ_func
FUNCREF OFnull_GroupStart of.groupstart_func = $(groupstart_func)
FUNCREF OFnull_TestStart of.teststart_func = $(teststart_func)
FUNCREF OFnull_TestSuccess of.testsuccess_func = $(testsuccess_func)
FUNCREF OFnull_TestFailure of.testfail_func = $(testfail_func)
FUNCREF OFnull_TestError of.testerror_func = $(testerror_func)
FUNCREF OFnull_TestIgnore of.testignore_func = $(testignore_func)
FUNCREF OFnull_AssertSuccess of.assertsuccess_func = $(assertsuccess_func)
FUNCREF OFnull_AssertFailure of.assertfail_func = $(assertfail_func)
FUNCREF OFnull_TestSuiteSummary of.ts_summ_func = $(ts_summ_func)
FUNCREF OFnull_TestOutcomeSummary of.to_summ_func = $(to_summ_func)
FUNCREF OFnull_AssertionSummary of.assert_summ_func = $(assert_summ_func)
End
Function/S OutputFormat_getPrefix(verbosity)
Variable verbosity
switch (verbosity)
case VERBOSITY_LOW:
return "OFBasic"
default:
return "OFVerbose"
endswitch
End
Function/S OutputFormat_getFuncName(verbosity, func_suffix)
Variable verbosity
String func_suffix
return OutputFormat_getPrefix(verbosity) +"_"+ func_suffix
End
Function/S OF_GroupStart(of, groupname)
STRUCT OutputFormat &of
String groupname
return of.groupstart_func(of, groupname)
End
Function/S OF_TestStart(of, test)
STRUCT OutputFormat &of
STRUCT UnitTest &test
return of.teststart_func(of, test)
End
Function/S OF_TestSuccess(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return of.testsuccess_func(of, to)
End
Function/S OF_TestFailure(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return of.testfail_func(of, to)
End
Function/S OF_TestError(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return of.testerror_func(of, to)
End
Function/S OF_TestIgnore(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return of.testignore_func(of, to)
End
Function/S OF_AssertSuccess(of, test, assertion)
STRUCT OutputFormat &of
STRUCT UnitTest &test
STRUCT Assertion &assertion
return of.assertsuccess_func(of, test, assertion)
End
Function/S OF_AssertFailure(of, test, assertion)
STRUCT OutputFormat &of
STRUCT UnitTest &test
STRUCT Assertion &assertion
return of.assertfail_func(of, test, assertion)
End
Function/S OF_TestSuiteSummary(of, tr, ts)
STRUCT OutputFormat &of
STRUCT TestResult &tr
STRUCT TestSuite &ts
return of.ts_summ_func(of, tr, ts)
End
Function/S OF_TestOutcomeSummary(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return of.to_summ_func(of, to)
End
Function/S OF_AssertionSummary(of, to, assertion)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
STRUCT Assertion &assertion
return of.assert_summ_func(of, to, assertion)
End
Function/S OFnull_GroupStart(of, groupname)
STRUCT OutputFormat &of
String groupname
return ""
End
Function/S OFnull_TestStart(of, test)
STRUCT OutputFormat &of
STRUCT UnitTest &test
return ""
End
Function/S OFnull_TestOutcome(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return ""
End
Function/S OFnull_TestSuccess(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return ""
End
Function/S OFnull_TestFailure(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return ""
End
Function/S OFnull_TestError(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return ""
End
Function/S OFnull_TestIgnore(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return ""
End
Function/S OFnull_AssertSuccess(of, test, assertion)
STRUCT OutputFormat &of
STRUCT UnitTest &test
STRUCT Assertion &assertion
return ""
End
Function/S OFnull_AssertFailure(of, test, assertion)
STRUCT OutputFormat &of
STRUCT UnitTest &test
STRUCT Assertion &assertion
return ""
End
Function/S OFnull_TestSuiteSummary(of, tr, ts)
STRUCT OutputFormat &of
STRUCT TestResult &tr
STRUCT TestSuite &ts
return ""
End
Function/S OFnull_TestOutcomeSummary(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return ""
End
Function/S OFnull_AssertionSummary(of, to, assertion)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
STRUCT Assertion &assertion
return ""
End
Function/S formatSectionHeader(header_text)
String header_text
String section_header = ""
section_header += header_text + "\r"
section_header += "======================================\r"
return section_header
End
Function/S formatSectionFooter()
String section_footer = ""
section_footer += "--------------------------------------\r"
return section_footer
End
Function/S formatDefectFooter()
String defect_footer = ""
defect_footer += "--------------------------------------\r"
return defect_footer
End
#endif