26 "{ Package: 'stx:libtool' }" |
26 "{ Package: 'stx:libtool' }" |
27 |
27 |
28 "{ NameSpace: Tools }" |
28 "{ NameSpace: Tools }" |
29 |
29 |
30 AbstractTestRunner subclass:#TestRunnerEmbedded |
30 AbstractTestRunner subclass:#TestRunnerEmbedded |
31 instanceVariableNames:'runnerPanel selectedTestCases selectedClassesHolder |
31 instanceVariableNames:'runnerPanel selectedClassesHolder selectedProtocolsHolder |
32 selectedProtocolsHolder selectedMethodsHolder |
32 selectedMethodsHolder methodGeneratorHolder resultHolder |
33 methodGeneratorHolder resultHolder resultInfoHolder |
33 resultInfoHolder resultBackgroundColorHolder runningHolder |
34 resultBackgroundColorHolder runningHolder progressHolder |
34 progressHolder infoHolder testProcess allTestCases' |
35 infoHolder' |
|
36 classVariableNames:'' |
35 classVariableNames:'' |
37 poolDictionaries:'' |
36 poolDictionaries:'' |
38 category:'SUnit-UI' |
37 category:'SUnit-UI' |
39 ! |
38 ! |
40 |
39 |
155 adjust: left |
154 adjust: left |
156 ) |
155 ) |
157 (LabelSpec |
156 (LabelSpec |
158 name: 'ResultInfo' |
157 name: 'ResultInfo' |
159 layout: (LayoutFrame 0 0 -10 1 0 1 0 1) |
158 layout: (LayoutFrame 0 0 -10 1 0 1 0 1) |
160 style: (FontDescription helvetica medium roman 8) |
159 style: (FontDescription helvetica medium roman 8 #'iso10646-1') |
161 backgroundChannel: resultBackgroundColorAspect |
160 backgroundChannel: resultBackgroundColorAspect |
162 foregroundColor: (Color 100.0 100.0 100.0) |
161 foregroundColor: (Color 100.0 100.0 100.0) |
163 translateLabel: true |
162 translateLabel: true |
164 labelChannel: resultInfoAspect |
163 labelChannel: resultInfoAspect |
165 adjust: left |
164 adjust: left |
182 ) |
181 ) |
183 ) |
182 ) |
184 ) |
183 ) |
185 |
184 |
186 ) |
185 ) |
187 extent: (Point 151 30) |
186 extent: (Point 336 30) |
188 ) |
187 ) |
189 (ActionButtonSpec |
188 (ActionButtonSpec |
190 label: 'Debug' |
189 label: 'Debug' |
191 name: 'DebugButton' |
190 name: 'DebugButton' |
192 initiallyInvisible: true |
191 initiallyInvisible: true |
193 visibilityChannel: debugVisibleAspect |
|
194 translateLabel: true |
192 translateLabel: true |
195 model: debug |
193 model: debug |
196 extent: (Point 60 25) |
194 extent: (Point 60 25) |
197 ) |
195 ) |
198 (ActionButtonSpec |
196 (ActionButtonSpec |
|
197 label: 'Stop' |
|
198 name: 'Button2' |
|
199 visibilityChannel: runningHolder |
|
200 translateLabel: true |
|
201 model: stop |
|
202 extent: (Point 60 25) |
|
203 ) |
|
204 (ActionButtonSpec |
199 label: 'Run' |
205 label: 'Run' |
200 name: 'Run' |
206 name: 'Run' |
|
207 visibilityChannel: notRunningHolder |
201 translateLabel: true |
208 translateLabel: true |
202 model: run |
209 model: run |
203 enableChannel: runEnabledHolder |
210 enableChannel: runEnabledHolder |
|
211 extent: (Point 60 25) |
|
212 ) |
|
213 (ActionButtonSpec |
|
214 label: 'Run Failed' |
|
215 name: 'Button1' |
|
216 translateLabel: true |
|
217 model: runFailed |
|
218 enableChannel: runFailedEnabledHolder |
204 extent: (Point 60 25) |
219 extent: (Point 60 25) |
205 ) |
220 ) |
206 (ActionButtonSpec |
221 (ActionButtonSpec |
207 label: 'Run all' |
222 label: 'Run all' |
208 name: 'RunAll' |
223 name: 'RunAll' |
286 |
301 |
287 methods := Set new. |
302 methods := Set new. |
288 generator := self methodGeneratorHolder value. |
303 generator := self methodGeneratorHolder value. |
289 selectedClass := self theSingleTestCase. |
304 selectedClass := self theSingleTestCase. |
290 |
305 |
291 generator ifNotNil: |
306 generator notNil ifTrue:[ |
292 [ generator do: |
307 generator do: [:cls :cat :sel :mthd | |
293 [:cls :cat :sel :mthd | |
308 (mthd notNil |
294 (mthd notNil |
309 and:[ (self isTestCaseLike:(selectedClass ? cls)) |
295 and:[ (self isTestCaseLike:(selectedClass ? cls)) and:[ (selectedClass ? cls) isTestSelector:sel ] ]) |
310 and:[ (selectedClass ? cls) isTestSelector:sel ] ]) |
296 ifTrue:[ methods add:mthd ] ] ] |
311 ifTrue:[ methods add:mthd ] |
297 ifNil: |
312 ] |
298 [ selectedTestCases do: |
313 ] ifFalse:[ |
299 [:cls | |
314 allTestCases do: [:cls | |
300 cls methodsDo: |
315 cls methodsDo: [:mthd | |
301 [:mthd | |
316 ((protocols includes:mthd category) and:[ cls isTestSelector:mthd selector ]) |
302 ((protocols includes:mthd category) |
317 ifTrue:[ |
303 and:[ cls isTestSelector:mthd selector ]) ifTrue:[ methods add:mthd ] ] ] ]. |
318 methods add:mthd |
|
319 ] |
|
320 ] |
|
321 ] |
|
322 ]. |
304 ^ methods |
323 ^ methods |
305 |
324 |
306 "Created: / 15-03-2010 / 19:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
325 "Created: / 15-03-2010 / 19:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
307 "Modified: / 22-07-2011 / 15:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
326 "Modified: / 22-07-2011 / 15:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
327 "Modified (format): / 04-06-2012 / 19:05:32 / cg" |
308 ! |
328 ! |
309 |
329 |
310 theSingleTestCase |
330 theSingleTestCase |
311 |
331 |
312 selectedTestCases isEmptyOrNil ifTrue:[^nil]. |
332 allTestCases isEmptyOrNil ifTrue:[^nil]. |
313 selectedTestCases size > 1 ifTrue:[^nil]. |
333 allTestCases size > 1 ifTrue:[^nil]. |
314 |
334 |
315 ^selectedTestCases anyOne. |
335 ^allTestCases anyOne. |
316 |
336 |
317 "Created: / 22-07-2011 / 15:44:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
337 "Created: / 22-07-2011 / 15:44:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
318 ! ! |
338 ! ! |
319 |
339 |
320 !TestRunnerEmbedded methodsFor:'actions'! |
340 !TestRunnerEmbedded methodsFor:'actions'! |
357 "Modified: / 22-08-2011 / 09:58:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
377 "Modified: / 22-08-2011 / 09:58:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
358 "Modified: / 09-10-2011 / 10:56:39 / cg" |
378 "Modified: / 09-10-2011 / 10:56:39 / cg" |
359 ! |
379 ! |
360 |
380 |
361 run:suite |
381 run:suite |
362 |process suiteAndResult numTests| |
382 |suiteAndResult numTests| |
363 |
383 |
364 numTests := suite tests size. |
384 numTests := suite tests size. |
365 numTests == 0 ifTrue:[ |
385 numTests == 0 ifTrue:[ |
366 ^ self |
386 ^ self |
367 ]. |
387 ]. |
368 |
388 |
369 process := [ |
389 self stop. |
|
390 |
|
391 testProcess := [ |
370 |result incr run| |
392 |result incr run| |
371 |
393 |
372 [ |
394 [ |
|
395 self runningHolder value:true. |
373 self progressHolder value:0. |
396 self progressHolder value:0. |
374 self runningHolder value:true. |
|
375 incr := 100 / numTests. |
397 incr := 100 / numTests. |
376 run := 0. |
398 run := 0. |
377 result := suite |
399 result := suite |
378 runBeforeEachDo:[:test :result | |
400 runBeforeEachDo:[:test :result | |
379 infoHolder notNil ifTrue:[ |
401 infoHolder notNil ifTrue:[ |
393 ] ensure:[ |
415 ] ensure:[ |
394 self resultHolder value:suiteAndResult. |
416 self resultHolder value:suiteAndResult. |
395 self runningHolder value:false. |
417 self runningHolder value:false. |
396 ] |
418 ] |
397 ] newProcess. |
419 ] newProcess. |
398 process resume. |
420 |
|
421 testProcess priority:(Processor userBackgroundPriority). |
|
422 testProcess resume. |
399 |
423 |
400 "Created: / 11-03-2010 / 10:22:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
424 "Created: / 11-03-2010 / 10:22:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
401 "Modified: / 06-09-2010 / 21:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
425 "Modified: / 06-09-2010 / 21:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
402 "Modified: / 06-07-2011 / 14:28:02 / cg" |
426 "Modified: / 04-06-2012 / 19:08:40 / cg" |
403 ! |
427 ! |
404 |
428 |
405 runAll |
429 runAll |
406 |
430 |
407 self run: self suiteForRunAll. |
431 self run: (self suiteForRunAll). |
408 |
432 |
409 "Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
433 "Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
410 "Modified: / 15-03-2010 / 13:12:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
434 "Modified: / 15-03-2010 / 13:12:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
435 "Modified: / 04-06-2012 / 19:00:14 / cg" |
|
436 ! |
|
437 |
|
438 runFailed |
|
439 self run: self suiteForRunFailed. |
|
440 |
|
441 "Created: / 04-06-2012 / 18:32:19 / cg" |
411 ! |
442 ! |
412 |
443 |
413 runWithDebug |
444 runWithDebug |
414 "/ cg: I really do not want to run them twice to get a debugger |
445 "/ cg: I really do not want to run them twice to get a debugger |
415 "/ - I want to run them either with a debugger coming right away, or not. |
446 "/ - I want to run them either with a debugger coming right away, or not. |
431 "/ [suiteAndResult suite tests anyOne debug] fork |
462 "/ [suiteAndResult suite tests anyOne debug] fork |
432 |
463 |
433 "Created: / 05-07-2011 / 18:45:43 / cg" |
464 "Created: / 05-07-2011 / 18:45:43 / cg" |
434 "Modified: / 22-08-2011 / 09:59:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
465 "Modified: / 22-08-2011 / 09:59:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
435 "Modified: / 09-10-2011 / 10:55:46 / cg" |
466 "Modified: / 09-10-2011 / 10:55:46 / cg" |
|
467 ! |
|
468 |
|
469 stop |
|
470 |p| |
|
471 |
|
472 (p := testProcess) notNil ifTrue:[ |
|
473 testProcess := nil. |
|
474 p terminate |
|
475 ]. |
|
476 |
|
477 "Created: / 04-06-2012 / 18:34:07 / cg" |
436 ! ! |
478 ! ! |
437 |
479 |
438 !TestRunnerEmbedded methodsFor:'aspects'! |
480 !TestRunnerEmbedded methodsFor:'aspects'! |
439 |
481 |
440 debugVisibleAspect |
482 debugVisibleAspect |
475 ]. |
517 ]. |
476 newValue := methodGeneratorHolder value. |
518 newValue := methodGeneratorHolder value. |
477 oldValue ~~ newValue ifTrue:[ |
519 oldValue ~~ newValue ifTrue:[ |
478 self update:#value with:newValue from:methodGeneratorHolder. |
520 self update:#value with:newValue from:methodGeneratorHolder. |
479 ]. |
521 ]. |
|
522 ! |
|
523 |
|
524 notRunningHolder |
|
525 ^ BlockValue forLogicalNot:(self runningHolder) |
|
526 |
|
527 "Created: / 04-06-2012 / 18:38:48 / cg" |
480 ! |
528 ! |
481 |
529 |
482 progressHolder |
530 progressHolder |
483 "return/create the 'progressHolder' value holder (automatically generated)" |
531 "return/create the 'progressHolder' value holder (automatically generated)" |
484 |
532 |
542 "Modified: / 02-08-2011 / 18:20:38 / cg" |
590 "Modified: / 02-08-2011 / 18:20:38 / cg" |
543 ! |
591 ! |
544 |
592 |
545 runAllEnabledHolder |
593 runAllEnabledHolder |
546 |
594 |
547 ^true |
595 ^ self notRunningHolder |
548 |
596 |
549 "Created: / 07-09-2010 / 09:15:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
597 "Created: / 07-09-2010 / 09:15:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
598 "Modified: / 04-06-2012 / 18:40:46 / cg" |
550 ! |
599 ! |
551 |
600 |
552 runEnabledHolder |
601 runEnabledHolder |
553 |
|
554 ^BlockValue |
602 ^BlockValue |
555 with: |
603 with: |
556 [:resultHolder | | result | |
604 [:result :running | |
557 (result := resultHolder value) notNil and:[result testCount > 0 ]] |
605 |
|
606 running not |
|
607 and:[ result notNil |
|
608 and:[ result testCount > 0 ]] |
|
609 ] |
558 argument: self resultHolder |
610 argument: self resultHolder |
|
611 argument: self runningHolder |
559 |
612 |
560 "Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
613 "Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
614 "Modified: / 04-06-2012 / 18:52:41 / cg" |
|
615 ! |
|
616 |
|
617 runFailedEnabledHolder |
|
618 ^BlockValue |
|
619 with: |
|
620 [:running | |
|
621 |
|
622 |result| |
|
623 |
|
624 result := (self resultForSuite:self suiteForRunAll). |
|
625 running not |
|
626 and:[ result notNil |
|
627 and:[ result hasFailuresOrErrors ]] |
|
628 ] |
|
629 "/ argument: self resultHolder |
|
630 argument: self runningHolder |
|
631 |
|
632 "Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
633 "Created: / 04-06-2012 / 18:28:12 / cg" |
561 ! |
634 ! |
562 |
635 |
563 runningHolder |
636 runningHolder |
564 "return/create the 'runningHolder' value holder (automatically generated)" |
|
565 |
|
566 runningHolder isNil ifTrue:[ |
637 runningHolder isNil ifTrue:[ |
567 runningHolder := ValueHolder with: false. |
638 runningHolder := ValueHolder with: false. |
568 ]. |
639 ]. |
569 ^ runningHolder |
640 ^ runningHolder |
570 |
641 |
571 "Modified: / 15-03-2010 / 20:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
642 "Modified: / 15-03-2010 / 20:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
643 "Modified (comment): / 04-06-2012 / 18:38:52 / cg" |
572 ! |
644 ! |
573 |
645 |
574 selectedClassesHolder |
646 selectedClassesHolder |
575 "return/create the 'selectedClassesHolder' value holder (automatically generated)" |
647 "return/create the 'selectedClassesHolder' value holder (automatically generated)" |
576 |
648 |
654 ]. |
726 ]. |
655 newValue := selectedProtocolsHolder value. |
727 newValue := selectedProtocolsHolder value. |
656 oldValue ~~ newValue ifTrue:[ |
728 oldValue ~~ newValue ifTrue:[ |
657 self update:#value with:newValue from:selectedProtocolsHolder. |
729 self update:#value with:newValue from:selectedProtocolsHolder. |
658 ]. |
730 ]. |
|
731 ! |
|
732 |
|
733 stopEnabledHolder |
|
734 ^ self runningHolder |
|
735 |
|
736 "Created: / 04-06-2012 / 18:29:01 / cg" |
659 ! ! |
737 ! ! |
660 |
738 |
661 !TestRunnerEmbedded methodsFor:'change & update'! |
739 !TestRunnerEmbedded methodsFor:'change & update'! |
662 |
740 |
663 update:aspect with:param from: sender |
741 update:aspect with:param from: sender |
696 |
774 |
697 |
775 |
698 super update:aspect with:param from: sender |
776 super update:aspect with:param from: sender |
699 |
777 |
700 "Modified: / 20-11-2011 / 12:40:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
778 "Modified: / 20-11-2011 / 12:40:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
779 "Modified: / 04-06-2012 / 19:03:34 / cg" |
701 ! |
780 ! |
702 |
781 |
703 updateTestCases |
782 updateTestCases |
704 selectedTestCases := ((self selectedClassesHolder value ? #()) |
783 allTestCases := ((self selectedClassesHolder value ? #()) |
705 select:[:cls | self isTestCaseLike:cls ]). |
784 select:[:cls | self isTestCaseLike:cls ]). |
706 selectedTestCases := selectedTestCases isEmpty |
785 allTestCases := allTestCases asArray |
707 ifTrue:[ nil ] |
|
708 ifFalse:[ selectedTestCases asArray ] |
|
709 |
786 |
710 "Created: / 11-03-2010 / 10:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
787 "Created: / 11-03-2010 / 10:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
711 "Modified: / 24-01-2012 / 22:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
788 "Modified: / 24-01-2012 / 22:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
789 "Modified: / 04-06-2012 / 19:02:52 / cg" |
712 ! |
790 ! |
713 |
791 |
714 updateTestSuiteAndResult |
792 updateTestSuiteAndResult |
715 |
793 |
716 | suite suiteAndResult | |
794 | suite suiteAndResult | |
717 self runningHolder value ifTrue:[^self]. |
795 self runningHolder value ifTrue:[^self]. |
718 selectedTestCases ifNil:[^self]. |
796 allTestCases isEmptyOrNil ifTrue:[^self]. |
719 suiteAndResult := SuiteAndResult |
797 suiteAndResult := SuiteAndResult |
720 suite: (suite := self suiteForRun) |
798 suite: (suite := self suiteForRun) |
721 result: (self resultForSuite: suite). |
799 result: (self resultForSuite: suite). |
722 self resultHolder value: suiteAndResult. |
800 self resultHolder value: suiteAndResult. |
723 |
801 |
724 "Created: / 15-03-2010 / 19:41:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
802 "Created: / 15-03-2010 / 19:41:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
725 "Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
803 "Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
804 "Modified: / 04-06-2012 / 19:03:15 / cg" |
726 ! |
805 ! |
727 |
806 |
728 updateVisibility |
807 updateVisibility |
729 |
808 |
730 self hasTestCaseSelected |
809 self hasTestCaseSelected |
802 |
881 |
803 !TestRunnerEmbedded methodsFor:'queries'! |
882 !TestRunnerEmbedded methodsFor:'queries'! |
804 |
883 |
805 hasTestCaseSelected |
884 hasTestCaseSelected |
806 |
885 |
807 ^selectedTestCases notEmptyOrNil |
886 ^allTestCases notEmptyOrNil |
808 |
887 |
809 "Created: / 11-03-2010 / 09:06:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
888 "Created: / 11-03-2010 / 09:06:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
810 "Modified: / 15-03-2010 / 20:54:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
889 "Modified: / 15-03-2010 / 20:54:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
811 "Modified: / 04-08-2011 / 20:42:10 / cg" |
890 "Modified: / 04-08-2011 / 20:42:10 / cg" |
812 ! ! |
891 ! ! |
872 "Modified: / 04-08-2011 / 19:06:42 / cg" |
951 "Modified: / 04-08-2011 / 19:06:42 / cg" |
873 ! |
952 ! |
874 |
953 |
875 suiteForRunAll |
954 suiteForRunAll |
876 |suite| |
955 |suite| |
877 suite := TestSuite named:(self suiteNameFromClasses: selectedTestCases). |
956 suite := TestSuite named:(self suiteNameFromClasses: allTestCases). |
878 selectedTestCases do:[:testCase | |
957 allTestCases isNil ifTrue:[ |
|
958 self updateTestCases. |
|
959 ]. |
|
960 |
|
961 allTestCases do:[:testCase | |
879 suite addTests:(self buildSuiteFromClass:testCase) tests |
962 suite addTests:(self buildSuiteFromClass:testCase) tests |
880 ]. |
963 ]. |
881 ^suite |
964 ^suite |
882 |
965 |
883 "Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
966 "Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
967 "Modified: / 04-06-2012 / 19:01:48 / cg" |
|
968 ! |
|
969 |
|
970 suiteForRunFailed |
|
971 |suite| |
|
972 |
|
973 suite := TestSuite named:(self suiteNameFromClasses: allTestCases). |
|
974 allTestCases do:[:testCase | |
|
975 (self buildSuiteFromClass:testCase) tests do:[:eachTest | |
|
976 | sel cls | |
|
977 |
|
978 sel := eachTest selector. |
|
979 cls := eachTest class. |
|
980 (cls testSelectorPassed:sel) ifFalse:[ |
|
981 suite addTest:eachTest |
|
982 ] |
|
983 ] |
|
984 ]. |
|
985 ^suite |
|
986 |
|
987 "Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
988 "Created: / 04-06-2012 / 18:32:40 / cg" |
884 ! ! |
989 ! ! |
885 |
990 |
886 !TestRunnerEmbedded::SuiteAndResult class methodsFor:'instance creation'! |
991 !TestRunnerEmbedded::SuiteAndResult class methodsFor:'instance creation'! |
887 |
992 |
888 suite: suite result: result |
993 suite: suite result: result |