-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeCoverage.pck.st
More file actions
5954 lines (4138 loc) · 239 KB
/
CodeCoverage.pck.st
File metadata and controls
5954 lines (4138 loc) · 239 KB
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'From Cuis7.7 [latest update: #7880] on 21 April 2026 at 4:36:09 pm'!
'Description Fix system category coverage display bug'!
!provides: 'CodeCoverage' 1 94!
!requires: 'Cuis-Base' 60 5962 nil!
!requires: 'PackageSnapshot' 1 8 nil!
SystemOrganization addCategory: #'CodeCoverage-Model'!
SystemOrganization addCategory: #'CodeCoverage-Tests'!
SystemOrganization addCategory: #'CodeCoverage-UI'!
SystemOrganization addCategory: #CodeCoverage!
!classDefinition: #CodeCoverageResultItem category: #'CodeCoverage-UI'!
ProtoObject subclass: #CodeCoverageResultItem
instanceVariableNames: 'item report label numberOfCharactersToSkip'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-UI'!
!classDefinition: 'CodeCoverageResultItem class' category: #'CodeCoverage-UI'!
CodeCoverageResultItem class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageAnalyzer category: #'CodeCoverage-Model'!
Object subclass: #CodeCoverageAnalyzer
instanceVariableNames: 'compiledMethodsToAnalyze compiledMethodCoverageAnalyzer installedCompiledMethodAnalyzers running report coverageReportBuilders reportBuilderFactory'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CodeCoverageAnalyzer class' category: #'CodeCoverage-Model'!
CodeCoverageAnalyzer class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageAnalyzerReport category: #'CodeCoverage-Model'!
Object subclass: #CodeCoverageAnalyzerReport
instanceVariableNames: 'reportsByClass reportsBySystemCategory reportsByCompiledMethod reportsByClassAndMessageCategory summaryReport'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CodeCoverageAnalyzerReport class' category: #'CodeCoverage-Model'!
CodeCoverageAnalyzerReport class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageReport category: #'CodeCoverage-Model'!
Object subclass: #CodeCoverageReport
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CodeCoverageReport class' category: #'CodeCoverage-Model'!
CodeCoverageReport class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageReportSummary category: #'CodeCoverage-Model'!
CodeCoverageReport subclass: #CodeCoverageReportSummary
instanceVariableNames: 'childReports'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CodeCoverageReportSummary class' category: #'CodeCoverage-Model'!
CodeCoverageReportSummary class
instanceVariableNames: ''!
!classDefinition: #CompiledMethodCoverageReport category: #'CodeCoverage-Model'!
CodeCoverageReport subclass: #CompiledMethodCoverageReport
instanceVariableNames: 'compiledMethod compiledMethodWasExecuted coverageRatioBySourceRange'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CompiledMethodCoverageReport class' category: #'CodeCoverage-Model'!
CompiledMethodCoverageReport class
instanceVariableNames: ''!
!classDefinition: #CompiledMethodCoverageAnalyzer category: #'CodeCoverage-Model'!
Object subclass: #CompiledMethodCoverageAnalyzer
instanceVariableNames: 'originalCompiledMethod sourceCodeGenerator methodClass codeCoverageNotifier installCount'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CompiledMethodCoverageAnalyzer class' category: #'CodeCoverage-Model'!
CompiledMethodCoverageAnalyzer class
instanceVariableNames: ''!
!classDefinition: #CompiledMethodCoverageTracker category: #'CodeCoverage-Model'!
Object subclass: #CompiledMethodCoverageTracker
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CompiledMethodCoverageTracker class' category: #'CodeCoverage-Model'!
CompiledMethodCoverageTracker class
instanceVariableNames: ''!
!classDefinition: #CompiledMethodCoverageNotifier category: #'CodeCoverage-Model'!
CompiledMethodCoverageTracker subclass: #CompiledMethodCoverageNotifier
instanceVariableNames: 'coverageTrackers'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CompiledMethodCoverageNotifier class' category: #'CodeCoverage-Model'!
CompiledMethodCoverageNotifier class
instanceVariableNames: ''!
!classDefinition: #DecisionConditionCoverageReportBuilder category: #'CodeCoverage-Model'!
CompiledMethodCoverageTracker subclass: #DecisionConditionCoverageReportBuilder
instanceVariableNames: 'coveredNonBooleanSourceRanges compiledMethod analyzedSourceRanges booleanValuesByDeclaration usagesByDeclaration compiledMethodWasExecuted decisionSelectors'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'DecisionConditionCoverageReportBuilder class' category: #'CodeCoverage-Model'!
DecisionConditionCoverageReportBuilder class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageTestClass1 category: #'CodeCoverage-Tests'!
Object subclass: #CodeCoverageTestClass1
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Tests'!
!classDefinition: 'CodeCoverageTestClass1 class' category: #'CodeCoverage-Tests'!
CodeCoverageTestClass1 class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageTestClass2 category: #'CodeCoverage-Tests'!
Object subclass: #CodeCoverageTestClass2
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Tests'!
!classDefinition: 'CodeCoverageTestClass2 class' category: #'CodeCoverage-Tests'!
CodeCoverageTestClass2 class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageAnalyzerBuilder category: #'CodeCoverage-UI'!
Object subclass: #CodeCoverageAnalyzerBuilder
instanceVariableNames: 'testSuite systemOrganizer'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-UI'!
!classDefinition: 'CodeCoverageAnalyzerBuilder class' category: #'CodeCoverage-UI'!
CodeCoverageAnalyzerBuilder class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageBrowserMenues category: #'CodeCoverage-UI'!
Object subclass: #CodeCoverageBrowserMenues
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-UI'!
!classDefinition: 'CodeCoverageBrowserMenues class' category: #'CodeCoverage-UI'!
CodeCoverageBrowserMenues class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageTextStylerFactory category: #'CodeCoverage-UI'!
Object subclass: #CodeCoverageTextStylerFactory
instanceVariableNames: 'report'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-UI'!
!classDefinition: 'CodeCoverageTextStylerFactory class' category: #'CodeCoverage-UI'!
CodeCoverageTextStylerFactory class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageSourceCodeGenerator category: #'CodeCoverage-Model'!
ParseNodeVisitor subclass: #CodeCoverageSourceCodeGenerator
instanceVariableNames: 'methodNode rawSourceRanges numberOfSourceRangeTraced tracedSourceRanges declarationSourceRangeByParseNode tracedSourceCode coverageTrackerLiteralName decompilerConstructor encoder coverageTrackerNode receiverTempCount'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Model'!
!classDefinition: 'CodeCoverageSourceCodeGenerator class' category: #'CodeCoverage-Model'!
CodeCoverageSourceCodeGenerator class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageAnalyzerBrowser category: #'CodeCoverage-UI'!
Browser subclass: #CodeCoverageAnalyzerBrowser
instanceVariableNames: 'codeCoverageReport'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-UI'!
!classDefinition: 'CodeCoverageAnalyzerBrowser class' category: #'CodeCoverage-UI'!
CodeCoverageAnalyzerBrowser class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageTextStyler category: #'CodeCoverage-UI'!
SHTextStylerST80 subclass: #CodeCoverageTextStyler
instanceVariableNames: 'codeCoverageReport'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-UI'!
!classDefinition: 'CodeCoverageTextStyler class' category: #'CodeCoverage-UI'!
CodeCoverageTextStyler class
instanceVariableNames: ''!
!classDefinition: #ProgressiveCodeCoverageTestRunner category: #'CodeCoverage-UI'!
ProgressiveTestRunner subclass: #ProgressiveCodeCoverageTestRunner
instanceVariableNames: 'codeCoverageAnalyzer compiledMethodAnalyzersInstallationProgressBar compiledMethodAnalyzersRunIncrement'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-UI'!
!classDefinition: 'ProgressiveCodeCoverageTestRunner class' category: #'CodeCoverage-UI'!
ProgressiveCodeCoverageTestRunner class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageAnalyzerTest category: #'CodeCoverage-Tests'!
TestCase subclass: #CodeCoverageAnalyzerTest
instanceVariableNames: 'codeCoverageAnalyzer originalM1Method'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Tests'!
!classDefinition: 'CodeCoverageAnalyzerTest class' category: #'CodeCoverage-Tests'!
CodeCoverageAnalyzerTest class
instanceVariableNames: ''!
!classDefinition: #CodeCoverageTest category: #'CodeCoverage-Tests'!
TestCase subclass: #CodeCoverageTest
instanceVariableNames: 'codeCoverageAnalyzer instanceVariable otherInstanceVariable coverageReport messageResult messageReceiverUsageCount'
classVariableNames: 'ClassVariable'
poolDictionaries: ''
category: 'CodeCoverage-Tests'!
!classDefinition: 'CodeCoverageTest class' category: #'CodeCoverage-Tests'!
CodeCoverageTest class
instanceVariableNames: ''!
!classDefinition: #CompiledMethodCoverageAnalyzerTest category: #'CodeCoverage-Tests'!
TestCase subclass: #CompiledMethodCoverageAnalyzerTest
instanceVariableNames: 'compiledMethodAnalyzer'
classVariableNames: ''
poolDictionaries: ''
category: 'CodeCoverage-Tests'!
!classDefinition: 'CompiledMethodCoverageAnalyzerTest class' category: #'CodeCoverage-Tests'!
CompiledMethodCoverageAnalyzerTest class
instanceVariableNames: ''!
!CodeCoverageResultItem commentStamp: 'NPM 1/18/2021 01:11:26' prior: 0!
I wrap an item to customize its label (#displayOrText) appending its code coverage percentage.
!
!CodeCoverageAnalyzer commentStamp: 'NPM 1/16/2021 21:04:01' prior: 0!
I monitor the execution of compiled methods to analyze their code coverage, and provide access to the code coverage reports.
Check the 'evaluating' and 'code coverage report' protocols to get you started.!
!CodeCoverageReport commentStamp: 'NPM 1/11/2021 19:52:54' prior: 0!
I model the result of a code coverage analysis execution.
!
!CodeCoverageReportSummary commentStamp: 'NPM 1/16/2021 21:27:27' prior: 0!
I summarize CodeCoverageReport instances!
!CompiledMethodCoverageReport commentStamp: 'NPM 1/16/2021 21:28:04' prior: 0!
I model the result of a code coverage analysis execution for compiled methods.
!
!CompiledMethodCoverageAnalyzer commentStamp: 'NPM 1/10/2021 12:25:56' prior: 0!
I replace and wrap a CompiledMethod to intercept its execution to collect code coverage information.
If code coverage is disabled I execute the wrapped method.
If code coverage is enabled, I compile an traced version of the wrapped method that will collect code coverage information when executed.
I use the Objects as Method Wrappers facility provided by the VM to wrap compiled methods.
My entry point is my #run:with:in: method, which will be executed by the VM when I install myself in the target class's method dictionary.
!
!CodeCoverageAnalyzerBuilder commentStamp: 'NPM 1/18/2021 16:37:38' prior: 0!
I create CodeCoverageAnalyzer instances from a test suite.
To determine the compiled methods that should be analyzed during the test suite run, I find all compiled methods from all system categories that have the same root prefix as the ones from the test cases classes, and discard those that belong to the test cases themselves.!
!CodeCoverageBrowserMenues commentStamp: 'NPM 1/18/2021 01:07:45' prior: 0!
I exists with the sole purpose of defining the menu items to run tests with code coverage.
There are no messages in my instance side, it is intentionally left blank.
See the 'browser menues' protocol in my class side.!
!CodeCoverageTextStylerFactory commentStamp: 'NPM 1/18/2021 18:33:55' prior: 0!
I take the place of a text styler class provided via the #textStylerClassFor: message (e.g. see Browser>>#textStylerClassFor:).
The returned styler class is later used to create an instance of it to style text.
The problem with this is that the code coverage report is needed to highlight the covered source code, and there was no way to attach this information to the text styler instance created from the returned class as instance creation happens, at the time of writing this, in InnterTextMorph>>#stylerClass:.
To overcome this problem, I hold a reference to the code coverage report that has to be used to highlight covered code, and when someone sends the #new message to me (thinking I'm a text styler class), I create an instance of CodeCoverageTextStyler passing the code coverage report that should be used for code highlighting.
!
!CodeCoverageSourceCodeGenerator commentStamp: 'NPM 1/11/2021 21:33:07' prior: 0!
I take a compiled method and, based on its source code, generate a new source code by wrapping each AST node with a tracing message node I create.
When executed, those tracing message nodes will execute the parse node they wrap and notify the active compiled method's code coverage analyzer that the source range of the wrapped parse node that was covered.
See comments in my methods for more information about how I implement code coverage tracing and how I trace message nodes that the Parser optimizes (such as #to:do).!
!CodeCoverageAnalyzerBrowser commentStamp: 'NPM 1/18/2021 01:02:23' prior: 0!
I am a specialized browser that displays results from a code coverage report.
I customize the labels for system categories, classes, message categories and messages, adding their code coverage percentage.
I also highlight the parse nodes that have been covered in a compiled method's source code.
See my 'styling - code coverage results' protocol to see how I do the labels customization/source code highlighting.
!
!CodeCoverageTextStyler commentStamp: 'NPM 1/19/2021 19:56:05' prior: 0!
I am an specialized text styler that highlights covered code.
I use a translucent colors for highighting covered and uncoverd code to allow the selected text's background to be visible.
If the color was solid, the user would not have feedback about which par of the code is selected.!
!ProgressiveCodeCoverageTestRunner commentStamp: 'NPM 1/18/2021 01:56:29' prior: 0!
I am a specialized progressive test runner that runs a test suite collecting code coverage information.!
!CodeCoverageResultItem methodsFor: 'accessing' stamp: 'NPM 6/Nov/2022 03:27:10'!
item
^ item! !
!CodeCoverageResultItem methodsFor: 'accessing' stamp: 'NPM 6/Nov/2022 03:27:01'!
string
^ item string! !
!CodeCoverageResultItem methodsFor: 'initialization' stamp: 'NPM 2/Nov/2022 00:08:49'!
initializeFor: anItem with: aCodeCoverageReport skippingAllButFirst: numberOfCharacters
item := anItem.
report := aCodeCoverageReport.
numberOfCharactersToSkip := numberOfCharacters.! !
!CodeCoverageResultItem methodsFor: 'printing' stamp: 'NPM 18/Jan/2021 16:46:33'!
displayStringOrText
^ label ifNil: [ self initializeLabel ]! !
!CodeCoverageResultItem methodsFor: 'printing' stamp: 'NPM 18/Jan/2021 16:47:30'!
initializeLabel
^ label := ('{1} ({2}%)' format: { item. report percentCovered asFloat printStringFractionDigits: 2 })! !
!CodeCoverageResultItem methodsFor: 'system primitives' stamp: 'NPM 2/Nov/2022 00:11:22'!
allButFirst: numberOfCharacters
^ self class
for: item
report: report
skippingAllButFirst: numberOfCharacters ! !
!CodeCoverageResultItem methodsFor: 'system primitives' stamp: 'NPM 2/Nov/2022 00:08:49'!
asString
^ self displayStringOrText
allButFirst: numberOfCharactersToSkip! !
!CodeCoverageResultItem methodsFor: 'system primitives' stamp: 'NPM 2/Nov/2022 00:03:19'!
doesNotUnderstand: aMessage
^ aMessage sendTo: item! !
!CodeCoverageResultItem methodsFor: 'copying' stamp: 'NPM 2/Nov/2022 00:08:49'!
appendToString: aString
^ aString, (item allButFirst: numberOfCharactersToSkip)! !
!CodeCoverageResultItem methodsFor: 'as yet unclassified' stamp: 'NPM 2/Nov/2022 00:22:10'!
percentCovered
^ report percentCovered! !
!CodeCoverageResultItem class methodsFor: 'instance creation' stamp: 'NPM 2/Nov/2022 00:10:12'!
for: anItem report: aCodeCoverageReport
^ self
for: anItem
report: aCodeCoverageReport
skippingAllButFirst: 0 ! !
!CodeCoverageResultItem class methodsFor: 'instance creation' stamp: 'NPM 2/Nov/2022 00:09:47'!
for: anItem report: aCodeCoverageReport skippingAllButFirst: numberOfCharacters
^ self
new
initializeFor: anItem
with: aCodeCoverageReport
skippingAllButFirst: numberOfCharacters! !
!CodeCoverageAnalyzer methodsFor: 'analyzing compiled methods' stamp: 'NPM 11/Nov/2022 08:31:48'!
installCompiledMethodAnalizers
self triggerInstallStartedEvent.
installedCompiledMethodAnalyzers := compiledMethodsToAnalyze
select: [ :compiledMethodToAnalyze | compiledMethodToAnalyze isAbstract not ]
thenCollect: [ :compiledMethodToAnalyze | self installCompiledMethodAnalyzer: compiledMethodToAnalyze ].
coverageReportBuilders := installedCompiledMethodAnalyzers
collect: [ :compiledMethodAnalyzer | compiledMethodAnalyzer registerNewCoverageReportBuilderUsing: reportBuilderFactory ].
self triggerIntallFinishedEvent.
! !
!CodeCoverageAnalyzer methodsFor: 'analyzing compiled methods' stamp: 'NPM 10/Sep/2022 15:09:23'!
resetInstalledCompiledMethodAnalyzers
installedCompiledMethodAnalyzers := Set new.
coverageReportBuilders := Set new.! !
!CodeCoverageAnalyzer methodsFor: 'analyzing compiled methods' stamp: 'NPM 11/Nov/2022 07:54:47'!
triggerInstallStartedEvent
^ self triggerEvent: #startInstallingCompiledMethodAnalyzers with: compiledMethodsToAnalyze size! !
!CodeCoverageAnalyzer methodsFor: 'analyzing compiled methods' stamp: 'NPM 11/Nov/2022 08:29:52'!
triggerIntallFinishedEvent
^ self triggerEvent: #endInstallingCompiledMethodAnalyzers! !
!CodeCoverageAnalyzer methodsFor: 'analyzing compiled methods' stamp: 'NPM 11/Jan/2021 21:15:02'!
uninstallCompiledMethodAnalyzers
compiledMethodCoverageAnalyzer uninstallAll: installedCompiledMethodAnalyzers.
self resetInstalledCompiledMethodAnalyzers.! !
!CodeCoverageAnalyzer methodsFor: 'assertions' stamp: 'NPM 16/Jan/2021 17:44:47'!
assertReportsAreAvailable
self
assert: running not
description: self class reportsAreNotAvailableWhileRunningErrorMessage! !
!CodeCoverageAnalyzer methodsFor: 'code coverage report' stamp: 'NPM 10/Sep/2022 15:09:30'!
generateReport
| compiledMethodReports |
compiledMethodReports := coverageReportBuilders collect: [ :reportBuilder | reportBuilder value ].
report := CodeCoverageAnalyzerReport withAll: compiledMethodReports.
! !
!CodeCoverageAnalyzer methodsFor: 'code coverage report' stamp: 'NPM 20/Jan/2021 02:43:01'!
report
self assertReportsAreAvailable.
^ report! !
!CodeCoverageAnalyzer methodsFor: 'code coverage tracking' stamp: 'NPM 16/Jan/2021 20:28:26'!
startTrackingCodeCoverage
self ifRunning: [ ^ self ].
self installCompiledMethodAnalizers.
running := true.! !
!CodeCoverageAnalyzer methodsFor: 'code coverage tracking' stamp: 'NPM 12/Sep/2022 02:31:04'!
stopTrackingCodeCoverage
self ifRunning: [
running := false.
[ self generateReport ]
ensure: [
self uninstallCompiledMethodAnalyzers.
self triggerStopEvent ]
]
! !
!CodeCoverageAnalyzer methodsFor: 'evaluating' stamp: 'NPM 18/Jan/2021 20:00:08'!
value: aBlock
"Convenience method for collecting code coverage for compiledMethodsToAnalyze
and cleaning up after myself in one-shot."
[
self startTrackingCodeCoverage.
^ aBlock value
] ensure: [
self stopTrackingCodeCoverage
]
! !
!CodeCoverageAnalyzer methodsFor: 'initialization' stamp: 'NPM 7/Nov/2022 02:04:41'!
initializeToAnalyze: compiledMethods with: aCompiledMethodCoverageAnalyzer creatingReportBuildersWith: aReportBuilderFactory
compiledMethodsToAnalyze := compiledMethods.
compiledMethodCoverageAnalyzer := aCompiledMethodCoverageAnalyzer.
reportBuilderFactory := aReportBuilderFactory.
running := false.
report := IdentitySet new.
self resetInstalledCompiledMethodAnalyzers.! !
!CodeCoverageAnalyzer methodsFor: 'testing' stamp: 'NPM 10/Jan/2021 16:22:58'!
ifRunning: aBlock
running ifTrue: aBlock! !
!CodeCoverageAnalyzer methodsFor: 'events - triggering' stamp: 'NPM 12/Sep/2022 02:30:20'!
triggerStopEvent
self triggerEvent: #stop.! !
!CodeCoverageAnalyzer methodsFor: 'events - registering' stamp: 'NPM 12/Sep/2022 02:29:38'!
onStopSend: aSelector to: anObject
self when: #stop send: aSelector to: anObject.! !
!CodeCoverageAnalyzer methodsFor: 'as yet unclassified' stamp: 'NPM 21/Apr/2026 08:30:38'!
installCompiledMethodAnalyzer: compiledMethodToAnalyze
self triggerEvent: #installCompiledMethodAnalyzer with: compiledMethodToAnalyze.
^ compiledMethodCoverageAnalyzer installOn: compiledMethodToAnalyze ! !
!CodeCoverageAnalyzer class methodsFor: 'code coverage tracking' stamp: 'NPM 11/Jan/2021 22:08:50'!
stopTrackingCoverageInAllInstances
"Stops tracking coverage in all of my instances.
Useful during development or testing, where an exception can leave dangling instances around.
self stopTrackingCoverageInAllInstances.
"
self allInstancesDo: [ :codeCoverageAnalyzer | codeCoverageAnalyzer stopTrackingCodeCoverage ]! !
!CodeCoverageAnalyzer class methodsFor: 'error messages' stamp: 'NPM 16/Jan/2021 17:30:24'!
classWasNotAnalyzedErrorMessage
^ 'Class was not analyzed'! !
!CodeCoverageAnalyzer class methodsFor: 'error messages' stamp: 'NPM 9/Jan/2021 17:11:16'!
compiledMethodWasNotAnalyzedErrorMessage
^ 'The compiled method was not requested to be analyzed'! !
!CodeCoverageAnalyzer class methodsFor: 'error messages' stamp: 'NPM 16/Jan/2021 17:42:41'!
reportsAreNotAvailableWhileRunningErrorMessage
^ 'Code coverage reports are not available while code coverage analyzer is running'! !
!CodeCoverageAnalyzer class methodsFor: 'error messages' stamp: 'NPM 16/Jan/2021 17:36:10'!
systemCategoryWasNotAnalyzedErrorMessage
^ 'The requested system category was not analyzed'! !
!CodeCoverageAnalyzer class methodsFor: 'evaluating' stamp: 'NPM 20/Jan/2021 03:38:07'!
value: aBlock analyzingAll: compiledMethods
"Convenience method for analyzing code coverage of compiledMethods
during the evaluation of aBlock."
| analzer |
analzer := self toAnalyzeAll: compiledMethods.
analzer value: aBlock.
"Insted of returning aBlock result, I return the instance that its code coverage
to retrieve coverage reports from it."
^ analzer report! !
!CodeCoverageAnalyzer class methodsFor: 'instance creation' stamp: 'NPM 7/Nov/2022 03:44:16'!
toAnalyzeAll: compiledMethods
^ self
toAnalyzeAll: compiledMethods
creatingReportBuildersWith: DecisionConditionCoverageReportBuilder! !
!CodeCoverageAnalyzer class methodsFor: 'instance creation' stamp: 'NPM 7/Nov/2022 02:10:17'!
toAnalyzeAll: compiledMethods creatingReportBuildersWith: aReportBuilderFactory
^ self
toAnalyzeAll: compiledMethods
with: CompiledMethodCoverageAnalyzer
creatingReportBuildersWith: aReportBuilderFactory! !
!CodeCoverageAnalyzer class methodsFor: 'instance creation' stamp: 'NPM 7/Nov/2022 02:07:32'!
toAnalyzeAll: compiledMethods with: aCompiledMethodCoverageAnalyzer creatingReportBuildersWith: aReportBuilderFactory
(self anyBelongToMySystemCategory: compiledMethods)
ifTrue: [
^ self
toAnalyzeAllInMyPackage: compiledMethods
with: aCompiledMethodCoverageAnalyzer
creatingReportBuildersWith: aReportBuilderFactory ].
^ self
toAnalyzeAllOutsideMyPackage: compiledMethods
with: aCompiledMethodCoverageAnalyzer
creatingReportBuildersWith: aReportBuilderFactory! !
!CodeCoverageAnalyzer class methodsFor: 'instance creation' stamp: 'NPM 7/Nov/2022 02:08:10'!
toAnalyzeAllInMyPackage: compiledMethods with: aCompiledMethodCoverageAnalyzer creatingReportBuildersWith: aReportBuilderFactory
"To analyze methods in my own package (aka analyze instances of myself) I create a temporary copy of my whole package
and instantiate classes from it to avoid infinite recursions"
| snapshotOfCompiledMethodCoverageAnalyzer codeCoverageAnalyzer snapshotOfMyself myPackage snapshotOfMyPackage snapshotOfReportBuilderFactory |
"First I create a copy of my own package"
myPackage := CodePackage packageOfClass: self ifNone: [ self shouldNotHappen ].
snapshotOfMyPackage := PackageSnapshot takeOf: myPackage.
"Find a snapshot of myself and my collaborator in the package snapshot"
snapshotOfMyself := snapshotOfMyPackage snapshotOf: self.
snapshotOfCompiledMethodCoverageAnalyzer _ snapshotOfMyPackage snapshotOf: aCompiledMethodCoverageAnalyzer.
snapshotOfReportBuilderFactory _ snapshotOfMyPackage snapshotOf: aReportBuilderFactory.
"Create the code coverage analyzer instance. It will be an instance of my snapshot (not myself)"
codeCoverageAnalyzer := snapshotOfMyself
toAnalyzeAll: compiledMethods
with: snapshotOfCompiledMethodCoverageAnalyzer
creatingReportBuildersWith: snapshotOfReportBuilderFactory.
"Once codeCoverageAnalyzer is done running, it will need the package snapshot to discard it.
I need to pin it or else it will be garbage collected."
snapshotOfMyPackage pin.
"Migrate instances of classes in the snapshot package (e.g. coverage reports) to their original classes before discarding the package snapshot"
codeCoverageAnalyzer onStopSend: #migrateSnapshotInstancesToOriginalClasses to: snapshotOfMyPackage.
codeCoverageAnalyzer onStopSend: #discard to: snapshotOfMyPackage.
"Finally, I unpin the package snapshot so it can be garbage collected"
codeCoverageAnalyzer onStopSend: #unpin to: snapshotOfMyPackage.
^ codeCoverageAnalyzer
! !
!CodeCoverageAnalyzer class methodsFor: 'instance creation' stamp: 'NPM 7/Nov/2022 02:05:31'!
toAnalyzeAllOutsideMyPackage: compiledMethods with: aCompiledMethodCoverageAnalyzer creatingReportBuildersWith: aReportBuilderFactory
^ self
new
initializeToAnalyze: compiledMethods
with: aCompiledMethodCoverageAnalyzer
creatingReportBuildersWith: aReportBuilderFactory! !
!CodeCoverageAnalyzer class methodsFor: 'testing' stamp: 'NPM 26/Oct/2022 02:33:31'!
anyBelongToMySystemCategory: compiledMethods
^ compiledMethods
anySatisfy: [ :compiledMethod | self belongsToMySystemCategory: compiledMethod ]! !
!CodeCoverageAnalyzer class methodsFor: 'testing' stamp: 'NPM 12/Sep/2022 02:22:35'!
belongsToMySystemCategory: compiledMethod
^ compiledMethod methodClass category = self category! !
!CodeCoverageAnalyzerReport methodsFor: 'accesing' stamp: 'NPM 19/Jan/2021 21:16:45'!
mostCoveredCompiledMethodReport
^ summaryReport mostCoveredReport! !
!CodeCoverageAnalyzerReport methodsFor: 'accesing' stamp: 'NPM 18/Jan/2021 21:04:26'!
reportForClass: aClass
^ reportsByClass
at: aClass
ifAbsent: [ AssertionFailure signal: CodeCoverageAnalyzer classWasNotAnalyzedErrorMessage ]! !
!CodeCoverageAnalyzerReport methodsFor: 'accesing' stamp: 'NPM 18/Jan/2021 21:17:39'!
reportForCompiledMethod: aCompiledMethod
^ reportsByCompiledMethod
at: aCompiledMethod
ifAbsent: [ AssertionFailure signal: CodeCoverageAnalyzer compiledMethodWasNotAnalyzedErrorMessage ]! !
!CodeCoverageAnalyzerReport methodsFor: 'accesing' stamp: 'NPM 19/Jan/2021 21:17:40'!
reportForCompiledMethod: aCompiledMethod ifAnalyzed: foundBlock ifNotAnalyzed: noneBlock
^ reportsByCompiledMethod
at: aCompiledMethod
ifPresent: foundBlock
ifAbsent: noneBlock! !
!CodeCoverageAnalyzerReport methodsFor: 'accesing' stamp: 'NPM 19/Jan/2021 21:03:30'!
reportForMessageCategory: aMessageCategory inClass: aClass
^ (reportsByClassAndMessageCategory at: aClass)
at: aMessageCategory! !
!CodeCoverageAnalyzerReport methodsFor: 'accesing' stamp: 'NPM 18/Jan/2021 21:03:34'!
reportForSystemCategory: aSystemCategory
^ reportsBySystemCategory
at: aSystemCategory
ifAbsent: [ AssertionFailure signal: CodeCoverageAnalyzer systemCategoryWasNotAnalyzedErrorMessage ]! !
!CodeCoverageAnalyzerReport methodsFor: 'indexing' stamp: 'NPM 18/Jan/2021 21:21:28'!
indexReportsByClassAndMessageCategory: compiledMethodReports
reportsByClass := Dictionary new.
reportsByClassAndMessageCategory := Dictionary new.
(compiledMethodReports groupBy: [ :report | report methodClass ]) keysAndValuesDo: [ :class :compiledMethodReportss |
reportsByClass
at: class
put: (CodeCoverageReport toSummarize: compiledMethodReportss).
reportsByClassAndMessageCategory
at: class
put: (self indexReportsByMessageCategory: compiledMethodReportss) ]! !
!CodeCoverageAnalyzerReport methodsFor: 'indexing' stamp: 'NPM 18/Jan/2021 20:40:59'!
indexReportsByCompiledMethod: compiledMethodReports
reportsByCompiledMethod := compiledMethodReports
inject: IdentityDictionary new
into: [ :reportIndex :report | reportIndex at: report compiledMethod put: report; yourself ].! !
!CodeCoverageAnalyzerReport methodsFor: 'indexing' stamp: 'NPM 19/Jan/2021 21:21:43'!
indexReportsByMessageCategory: compiledMethodReports
^ (compiledMethodReports groupBy: [ :report | report messageCategory ])
collect: [ :reports | CodeCoverageReport toSummarize: reports ]
! !
!CodeCoverageAnalyzerReport methodsFor: 'indexing' stamp: 'NPM 18/Jan/2021 21:21:48'!
indexReportsBySystemCategory: compiledMethodReports
reportsBySystemCategory := (compiledMethodReports groupBy: [ :report | report systemCategory ])
collect: [ :reports | CodeCoverageReport toSummarize: reports ]! !
!CodeCoverageAnalyzerReport methodsFor: 'initialization' stamp: 'NPM 19/Jan/2021 21:16:16'!
initializeWithAll: compiledMethodReports
summaryReport := CodeCoverageReport toSummarize: compiledMethodReports.
self
indexReportsByCompiledMethod: compiledMethodReports;
indexReportsByClassAndMessageCategory: compiledMethodReports;
indexReportsBySystemCategory: compiledMethodReports! !
!CodeCoverageAnalyzerReport methodsFor: 'statistics' stamp: 'NPM 19/Jan/2021 21:16:15'!
percentCovered
^ summaryReport percentCovered ! !
!CodeCoverageAnalyzerReport methodsFor: 'testing' stamp: 'NPM 18/Jan/2021 20:46:52'!
wasClassAnalyzed: aClass
^ reportsByClass includesKey: aClass! !
!CodeCoverageAnalyzerReport methodsFor: 'testing' stamp: 'NPM 18/Jan/2021 20:50:47'!
wasCompiledMethodAnalyzed: aCompiledMethod
^ reportsByCompiledMethod includesKey: aCompiledMethod! !
!CodeCoverageAnalyzerReport methodsFor: 'testing' stamp: 'NPM 18/Jan/2021 20:49:48'!
wasMessageCategoryAnalyzed: aMessageCategory in: aClass
^ reportsByClassAndMessageCategory
at: aClass
ifPresent: [ :classReports | classReports includesKey: aMessageCategory ]
ifAbsent: [ false ]! !
!CodeCoverageAnalyzerReport methodsFor: 'testing' stamp: 'NPM 18/Jan/2021 20:44:59'!
wasSystemCategoryAnalyzed: aSystemCategory
^ reportsBySystemCategory includesKey: aSystemCategory! !
!CodeCoverageAnalyzerReport class methodsFor: 'instance creation' stamp: 'NPM 18/Jan/2021 20:31:24'!
withAll: compiledMethodReports
^ self
new
initializeWithAll: compiledMethodReports! !
!CodeCoverageReport methodsFor: 'statistics' stamp: 'NPM 11/Jan/2021 18:48:17'!
coverageRatio
self subclassResponsibility! !
!CodeCoverageReport methodsFor: 'statistics' stamp: 'NPM 14/Feb/2021 12:35:04'!
percentCovered
^ (self coverageRatio * 100)
roundTo: 0.01! !
!CodeCoverageReport class methodsFor: 'instance creation' stamp: 'NPM 21/Apr/2026 09:16:08'!
for: aCompiledMethod executed: aBoolean with: coverageResults
^ CompiledMethodCoverageReport
for: aCompiledMethod
executed: aBoolean
with: coverageResults
! !
!CodeCoverageReport class methodsFor: 'instance creation' stamp: 'NPM 11/Jan/2021 18:51:58'!
toSummarize: codeCoverageReports
^ CodeCoverageReportSummary withAll: codeCoverageReports! !
!CodeCoverageReportSummary methodsFor: 'initialization' stamp: 'NPM 11/Jan/2021 18:47:03'!
initializeWithAll: codeCoverageReports
childReports := codeCoverageReports.! !
!CodeCoverageReportSummary methodsFor: 'querying' stamp: 'NPM 19/Jan/2021 21:17:08'!
mostCoveredReport
^ childReports detectMax: [ :report | report percentCovered ]! !
!CodeCoverageReportSummary methodsFor: 'statistics' stamp: 'NPM 11/Jan/2021 18:47:03'!
coverageRatio
childReports ifEmpty: [ ^ 0 ].
^ (childReports sum: [ :coverageReport | coverageReport coverageRatio ]) / childReports size! !
!CodeCoverageReportSummary class methodsFor: 'instance creation' stamp: 'NPM 11/Jan/2021 18:12:26'!
withAll: anArray
^ self
new
initializeWithAll: anArray ! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 17/Jan/2021 20:52:31'!
compiledMethod
^ compiledMethod! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 14/Feb/2021 13:09:53'!
fullyCoveredSourceRanges
^ self selectSourceRangesByCoverageRatio: [ :coverageRatio | coverageRatio = 1 ]! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 19/Jan/2021 21:21:43'!
messageCategory
^ compiledMethod category! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 17/Jan/2021 18:10:36'!
methodClass
^ compiledMethod methodClass! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 14/Feb/2021 13:08:38'!
partiallyCoveredSourceRanges
^ self selectSourceRangesByCoverageRatio: [ :coverageRatio |
0 < coverageRatio and: [ coverageRatio < 1 ]]! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 14/Feb/2021 13:07:40'!
selectSourceRangesByCoverageRatio: aBlock
^ coverageRatioBySourceRange associations
select: [ :sourceRangeAndCoverageRatio | aBlock value: sourceRangeAndCoverageRatio value ]
thenCollect: [ :sourceRangeAndCoverageRatio | sourceRangeAndCoverageRatio key ]! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 17/Jan/2021 18:10:51'!
selector
^ compiledMethod selector! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 19/Jan/2021 21:31:23'!
systemCategory
^ compiledMethod
methodClass
category ! !
!CompiledMethodCoverageReport methodsFor: 'accessing' stamp: 'NPM 14/Feb/2021 13:09:46'!
uncoveredSourceRanges
^ self selectSourceRangesByCoverageRatio: [ :coverageRatio | coverageRatio isZero ]! !
!CompiledMethodCoverageReport methodsFor: 'initialization' stamp: 'NPM 21/Apr/2026 09:11:57'!
initializeFor: aCompiledMethod executed: aBoolean with: coverageResults
compiledMethod := aCompiledMethod.
compiledMethodWasExecuted := aBoolean.
coverageRatioBySourceRange := coverageResults.! !
!CompiledMethodCoverageReport methodsFor: 'statistics' stamp: 'NPM 14/Feb/2021 13:14:00'!
coverageRatio
compiledMethodWasExecuted ifFalse: [ ^ 0 ].
coverageRatioBySourceRange ifEmpty: [ ^ 1 ].
^ (coverageRatioBySourceRange values sum) / coverageRatioBySourceRange size! !
!CompiledMethodCoverageReport methodsFor: 'statistics' stamp: 'NPM 14/Feb/2021 13:13:23'!
coverageRatioOf: aSourceRange
^ coverageRatioBySourceRange at: aSourceRange! !
!CompiledMethodCoverageReport methodsFor: 'statistics' stamp: 'NPM 14/Feb/2021 13:10:50'!
numberOfSourceRanges
^ coverageRatioBySourceRange size! !
!CompiledMethodCoverageReport methodsFor: 'statistics' stamp: 'NPM 14/Feb/2021 13:05:11'!
totalCoveredSourceRanges
^ coverageRatioBySourceRange size - self uncoveredSourceRanges size! !
!CompiledMethodCoverageReport class methodsFor: 'instance creation' stamp: 'NPM 21/Apr/2026 09:16:08'!
for: aCompiledMethod executed: aBoolean with: coverageResults
^ self
new
initializeFor: aCompiledMethod
executed: aBoolean
with: coverageResults
! !
!CompiledMethodCoverageAnalyzer methodsFor: 'initialization' stamp: 'NPM 21/Apr/2026 08:28:44'!
initializeFor: aCompiledMethod generatingSourceCodeWith: aCodeCoverageSourceCodeGenerator
originalCompiledMethod := aCompiledMethod.
sourceCodeGenerator := aCodeCoverageSourceCodeGenerator.
codeCoverageNotifier := CompiledMethodCoverageTracker notifier.
installCount := 0.
methodClass := originalCompiledMethod methodClass.
! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:43:51'!
compileTracedMethod
"Compilation of the traced version of originalCompiledMethod can fail if the new source code
is too big to be compiled with optimizations.
At the time of writing this (2021-01-29) trying to analyze the code coverage of ArgentineLaw23555RuleTest>>#testCreation
(from the Chalten package (https://github.com/Cuis-Smalltalk/Calendars/commits/master/Chalten, at commit 63ac3888936b008e85679cdc474e4cc0685686bf)
fails with the following compiler error:
'genJumpLong: distance index -1042 is out of range -1024 to 1023'
To recover from this kind of errors, if compilation of tracedCompiledMethod fails, I give it a second chance and try to compile it wihout optimizations."
| tracedCompiledMethod reportBuilderLiteralIndex |
tracedCompiledMethod _ methodClass safelyBasicCompile: sourceCodeGenerator tracedSourceCode.
reportBuilderLiteralIndex _ tracedCompiledMethod indexOfLiteral: sourceCodeGenerator coverageTrackerLiteralName.
reportBuilderLiteralIndex > 0
ifTrue: [
tracedCompiledMethod
literalAt: reportBuilderLiteralIndex
put: codeCoverageNotifier ].
tracedCompiledMethod codeCoverageAnalyzer: self.
^ tracedCompiledMethod
! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:29:45'!
decrementInstallCount
self isInstalled
ifTrue: [ installCount := installCount - 1 ]! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:23:12'!
ifShouldBeUninstalled: aBlock
installCount = 0
ifTrue: aBlock ! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:30:03'!
incrementInstallCount
installCount _ installCount + 1! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:39:54'!
install
"Replace the original compiled method with myself to intercept its execution".
self isInstalled
ifFalse: [ self installTracedCompiledMethod ].
self incrementInstallCount.! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:44:37'!
installCompiledMethod: aCompiledMethod
methodClass
addSelectorSilently: aCompiledMethod selector
withMethod: aCompiledMethod! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:40:27'!
installOriginalMethod
self installCompiledMethod: originalCompiledMethod! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:41:33'!
installTracedCompiledMethod
self installCompiledMethod: self compileTracedMethod
! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:14:26'!
isInstalled
^ installCount > 0! !
!CompiledMethodCoverageAnalyzer methodsFor: 'installing & uninstalling' stamp: 'NPM 4/Nov/2022 02:39:29'!
uninstall
"Restore the original compiled method"
self isInstalled ifFalse: [ ^ self ].