• R/O
  • SSH

kink: Commit

Kink runtime


Commit MetaInfo

Revisione7d752a47681652f229805a9ca42256625a0e233 (tree)
Zeit2020-09-21 20:29:40
Autormiyakawataku
Commitermiyakawataku

Log Message

add tests of test listeners

Ändern Zusammenfassung

Diff

diff -r dcc74d830d07 -r e7d752a47681 src/test/kink/test/TOOL_test.kn
--- a/src/test/kink/test/TOOL_test.kn Mon Sep 21 19:59:08 2020 +0900
+++ b/src/test/kink/test/TOOL_test.kn Mon Sep 21 20:29:40 2020 +0900
@@ -1,4 +1,5 @@
11 :CONTROL.require_from('kink/')
2+:TRACE.require_from('kink/')
23 :TOOL.require_from('kink/test/')
34 :TEST.require_from('kink/test/')
45 :STR_PRINTER.require_from('kink/io/')
@@ -141,6 +142,175 @@
141142
142143 } # }}}
143144
145+TEST.group('TOOL._make_counting_listener'){ # {{{
146+ :make_test = {
147+ TEST.collect_in{
148+ TEST.test('test'){}
149+ }.front
150+ }
151+
152+ TEST.test('do counting'){
153+ [:Printer :gen_str] = STR_PRINTER.new_pair("\n")
154+ :L = TOOL._make_counting_listener(Printer)
155+ :T = make_test
156+
157+ L.on_all_start
158+
159+ L.on_test_start(T)
160+ L.on_test_success(T)
161+
162+ 2.times.each{
163+ L.on_test_start(T)
164+ L.on_test_skipped(T)
165+ }
166+
167+ 3.times.each{
168+ L.on_test_start(T)
169+ L.on_test_failure(T 'bang!' [])
170+ }
171+
172+ L.on_all_end
173+ :Output = gen_str
174+ Output == "\nSuccess 1 Failure 3 Skipped 2\n" || raise('got {}'.format(Output.repr))
175+ }
176+} # }}}
177+
178+TEST.group('TOOL._make_quiet_progress_listener'){ # {{{
179+ :make_test = {
180+ TEST.collect_in{
181+ TEST.test('test'){}
182+ }.front
183+ }
184+
185+ TEST.test('do counting'){
186+ [:Printer :gen_str] = STR_PRINTER.new_pair("\n")
187+ :L = TOOL._make_quiet_progress_listener(Printer)
188+ :T = make_test
189+
190+ L.on_all_start
191+
192+ 3.times.each{
193+ L.on_test_start(T)
194+ L.on_test_success(T)
195+ }
196+
197+ L.on_test_start(T)
198+ L.on_test_failure(T 'bang!' [
199+ TRACE.new{(:C) C.sym('foo') }
200+ ]
201+ )
202+
203+ 3.times.each{
204+ L.on_test_start(T)
205+ L.on_test_skipped(T)
206+ }
207+
208+ L.on_all_end
209+
210+ :Output = gen_str
211+ Output == "...!\nFailure: @all; test\n exception traces: from oldest to newest\n [foo]\n exception message: bang!\n\n---"
212+ || raise('got {}'.format(Output.repr))
213+ }
214+} # }}}
215+
216+TEST.group('TOOL._make_verbose_progress_listener'){ # {{{
217+ :make_test = {
218+ TEST.collect_in{
219+ TEST.test('test'){}
220+ }.front
221+ }
222+
223+ TEST.test('do counting'){
224+ [:Printer :gen_str] = STR_PRINTER.new_pair("\n")
225+ :L = TOOL._make_verbose_progress_listener(Printer)
226+ :T = make_test
227+
228+ L.on_all_start
229+
230+ L.on_test_start(T)
231+ L.on_test_success(T)
232+
233+ L.on_test_start(T)
234+ L.on_test_failure(T 'bang!' [
235+ TRACE.new{(:C) C.sym('foo') }
236+ ]
237+ )
238+
239+ L.on_test_start(T)
240+ L.on_test_skipped(T)
241+
242+ L.on_all_end
243+
244+ :Output = gen_str
245+ :Expected = "@all; test : Success\n"
246+ + "@all; test : Failure\n"
247+ + " exception traces: from oldest to newest\n"
248+ + " [foo]\n"
249+ + " exception message: bang!\n"
250+ + "\n"
251+ + "@all; test : Skipped\n"
252+ Output == Expected || raise('got {}'.format(Output.repr))
253+ }
254+} # }}}
255+
256+TEST.group('TEST._make_exit_listener'){ # {{{
257+ :make_test = {
258+ TEST.collect_in{
259+ TEST.test('test'){}
260+ }.front
261+ }
262+
263+ TEST.test('exit with 1 when a test fails'){
264+ :T = make_test
265+
266+ :Exit_status = CONTROL.with_break{(:exit)
267+ :L = TOOL._make_exit_listener($exit)
268+
269+ L.on_all_start
270+
271+ L.on_test_start(T)
272+ L.on_test_success(T)
273+
274+ L.on_test_start(T)
275+ L.on_test_failure(T 'bang!' [
276+ TRACE.new{(:C) C.sym('foo') }
277+ ]
278+ )
279+
280+ L.on_test_start(T)
281+ L.on_test_skipped(T)
282+
283+ L.on_all_end
284+
285+ raise('must not reach here')
286+ }
287+
288+ Exit_status == 1 || raise('got {}'.format(Exit_status.repr))
289+ }
290+
291+ TEST.test('exit with 0 when no test fails'){
292+ :T = make_test
293+
294+ :Exit_status = CONTROL.with_break{(:exit)
295+ :L = TOOL._make_exit_listener($exit)
296+
297+ L.on_all_start
298+
299+ L.on_test_start(T)
300+ L.on_test_success(T)
301+
302+ L.on_test_start(T)
303+ L.on_test_skipped(T)
304+
305+ L.on_all_end
306+
307+ raise('must not reach here')
308+ }
309+
310+ Exit_status == 0 || raise('got {}'.format(Exit_status.repr))
311+ }
312+} # }}}
313+
144314 TEST.group('TOOL._run_tests'){ # {{{
145315 :make_tests = {
146316 TEST.collect_in{
Show on old repository browser