From fbcf1c1631384581c8873851ed1270bae0701a20 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 17 Apr 2024 14:34:48 +0200 Subject: [PATCH 01/10] start refactoring analysis to use methods insead of classes --- src/MuTalk-Model/MTAnalysis.class.st | 24 ++++++++++++++++---- src/MuTalk-Model/MTCoverageAnalysis.class.st | 16 ++++++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/MuTalk-Model/MTAnalysis.class.st b/src/MuTalk-Model/MTAnalysis.class.st index 0378680..ea8eb89 100644 --- a/src/MuTalk-Model/MTAnalysis.class.st +++ b/src/MuTalk-Model/MTAnalysis.class.st @@ -3,6 +3,7 @@ Class { #superclass : 'Object', #instVars : [ 'modelClasses', + 'methodsToMutate', 'operators', 'elapsedTime', 'mutations', @@ -34,9 +35,10 @@ MTAnalysis >> budget: anObject [ ] { #category : 'accessing' } -MTAnalysis >> classesToMutate: anObject [ +MTAnalysis >> classesToMutate: aClassCollection [ - modelClasses := anObject + methodsToMutate := aClassCollection flatCollect: [ :class | + class package methodsForClass: class ] ] { #category : 'accessing' } @@ -115,7 +117,7 @@ MTAnalysis >> generateCoverageAnalysis [ logger logStartCoverageAnalysis. coverageAnalysisResult := (MTCoverageAnalysis - for: self modelClasses + for: methodsToMutate running: testCases) run; result @@ -192,6 +194,18 @@ MTAnalysis >> logger: anObject [ logger := anObject ] +{ #category : 'accessing' } +MTAnalysis >> methodsToMutate [ + + ^ methodsToMutate +] + +{ #category : 'accessing' } +MTAnalysis >> methodsToMutate: anObject [ + + methodsToMutate := anObject +] + { #category : 'accessing' } MTAnalysis >> modelClasses [ "Filter tests and testsResources" @@ -253,8 +267,8 @@ MTAnalysis >> operators: anObject [ { #category : 'accessing' } MTAnalysis >> packagesToMutate: aCollectionOfPackages [ - modelClasses := aCollectionOfPackages flatCollect: [ :packageName | - packageName asPackage definedClasses ] + methodsToMutate := aCollectionOfPackages flatCollect: [ :packageName | + packageName asPackage methods ] ] { #category : 'computing' } diff --git a/src/MuTalk-Model/MTCoverageAnalysis.class.st b/src/MuTalk-Model/MTCoverageAnalysis.class.st index 22ca777..4b4996a 100644 --- a/src/MuTalk-Model/MTCoverageAnalysis.class.st +++ b/src/MuTalk-Model/MTCoverageAnalysis.class.st @@ -2,12 +2,12 @@ Class { #name : 'MTCoverageAnalysis', #superclass : 'Object', #instVars : [ - 'classes', 'result', 'classesAndMetaclasses', 'testCases', 'currentTest', - 'testRunningElapsedTime' + 'testRunningElapsedTime', + 'methods' ], #category : 'MuTalk-Model-Coverage', #package : 'MuTalk-Model', @@ -15,8 +15,11 @@ Class { } { #category : 'instance creation' } -MTCoverageAnalysis class >> for: aCollectionOfClasses running: aCollectionOfTestCases [ - ^self new initializeFor: aCollectionOfClasses running: aCollectionOfTestCases +MTCoverageAnalysis class >> for: aCollectionOfMethods running: aCollectionOfTestCases [ + + ^ self new + initializeFor: aCollectionOfMethods + running: aCollectionOfTestCases ] { #category : 'private' } @@ -54,8 +57,9 @@ MTCoverageAnalysis >> flushMethodLookupCaches [ ] { #category : 'initialize-release' } -MTCoverageAnalysis >> initializeFor: aCollectionOfClasses running: aCollectionOfTestCases [ - classes := aCollectionOfClasses. +MTCoverageAnalysis >> initializeFor: aCollectionOfMethods running: aCollectionOfTestCases [ + + methods := aCollectionOfMethods. testCases := aCollectionOfTestCases ] From 40d22e6f0d527a6a4806b7772e0bc8d23979aa85 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 17 Apr 2024 15:45:15 +0200 Subject: [PATCH 02/10] refactor mutation testing analysis and coverage analysis to use methods directly --- .../MTAllMutantGenerationStrategy.class.st | 17 ++----------- src/MuTalk-Model/MTAnalysis.class.st | 6 ++++- src/MuTalk-Model/MTCoverageAnalysis.class.st | 24 +++++-------------- 3 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/MuTalk-Model/MTAllMutantGenerationStrategy.class.st b/src/MuTalk-Model/MTAllMutantGenerationStrategy.class.st index 7bf75cd..e045ec6 100644 --- a/src/MuTalk-Model/MTAllMutantGenerationStrategy.class.st +++ b/src/MuTalk-Model/MTAllMutantGenerationStrategy.class.st @@ -7,20 +7,7 @@ Class { } { #category : 'generating' } -MTAllMutantGenerationStrategy >> classesAndMetaclassesFrom: modelClasses [ - ^ modelClasses - inject: OrderedCollection new - into: [:classes :aClass | - classes add: aClass; - add: aClass class. - classes] -] +MTAllMutantGenerationStrategy >> methodsToMutateFrom: aMutationTestingAnalysis [ -{ #category : 'generating' } -MTAllMutantGenerationStrategy >> methodsToMutateFrom: aMutationTestingAnalysis [ - ^ (self classesAndMetaclassesFrom: aMutationTestingAnalysis modelClasses) - inject: OrderedCollection new - into: [:methods :aClass | - methods addAll: aClass methods. - methods] + ^ aMutationTestingAnalysis methodsToMutate ] diff --git a/src/MuTalk-Model/MTAnalysis.class.st b/src/MuTalk-Model/MTAnalysis.class.st index ea8eb89..08b6089 100644 --- a/src/MuTalk-Model/MTAnalysis.class.st +++ b/src/MuTalk-Model/MTAnalysis.class.st @@ -38,7 +38,11 @@ MTAnalysis >> budget: anObject [ MTAnalysis >> classesToMutate: aClassCollection [ methodsToMutate := aClassCollection flatCollect: [ :class | - class package methodsForClass: class ] + | methods | + methods := class package methodsForClass: class. + methods addAll: + (class package methodsForClass: class class). + methods ] ] { #category : 'accessing' } diff --git a/src/MuTalk-Model/MTCoverageAnalysis.class.st b/src/MuTalk-Model/MTCoverageAnalysis.class.st index 4b4996a..f8af46f 100644 --- a/src/MuTalk-Model/MTCoverageAnalysis.class.st +++ b/src/MuTalk-Model/MTCoverageAnalysis.class.st @@ -3,7 +3,6 @@ Class { #superclass : 'Object', #instVars : [ 'result', - 'classesAndMetaclasses', 'testCases', 'currentTest', 'testRunningElapsedTime', @@ -31,15 +30,6 @@ MTCoverageAnalysis >> addTestsFrom: aWrapper to: methodToTestDictionary [ addAll: aWrapper tests] ] -{ #category : 'private' } -MTCoverageAnalysis >> classesAndMetaclasses [ - classesAndMetaclasses isNil ifTrue:[ - classesAndMetaclasses := (classes collect:[:aClass | aClass class]) asOrderedCollection. - classesAndMetaclasses addAll: classes.]. - ^classesAndMetaclasses. - -] - { #category : 'accessing' } MTCoverageAnalysis >> currentTest [ ^ currentTest @@ -70,13 +60,11 @@ MTCoverageAnalysis >> installAll: wrappers [ { #category : 'private' } MTCoverageAnalysis >> methodReferences [ - ^ self classesAndMetaclasses - inject: OrderedCollection new - into: [:methodReferences :aClass | - methodReferences - addAll: (aClass selectors - collect: [:aSelector | RGMethodDefinition class: aClass selector: aSelector]). - methodReferences] + + ^ methods collect: [ :aMethod | + RGMethodDefinition + class: aMethod methodClass + selector: aMethod selector ] ] { #category : 'private' } @@ -108,7 +96,7 @@ MTCoverageAnalysis >> run [ result := MTCoverageAnalysisResult from: (self methodToTestDictionaryFrom: wrappers) elapsedTime: testRunningElapsedTime. - result methodReferences: (self classesAndMetaclasses flatCollect: [:cls | cls methods]) + result methodReferences: methods ] { #category : 'private' } From cfe63562cf0ab3992104a39c942725ac0687120e Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 17 Apr 2024 15:46:41 +0200 Subject: [PATCH 03/10] start fixing tests --- .../MTTestCoverageAnalysis.class.st | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/MuTalk-Tests/MTTestCoverageAnalysis.class.st b/src/MuTalk-Tests/MTTestCoverageAnalysis.class.st index babb588..99c11d4 100644 --- a/src/MuTalk-Tests/MTTestCoverageAnalysis.class.st +++ b/src/MuTalk-Tests/MTTestCoverageAnalysis.class.st @@ -8,16 +8,20 @@ Class { { #category : 'testing' } MTTestCoverageAnalysis >> testBugWhenHavingATestResourceSendingToOther [ "the problem was when sending from a resource a message to another object wich class is going to be considered for coverage" - | analysis testCases| + + | analysis testCases methods | + methods := MTClassForTestingCoverage methods asOrderedCollection. + methods addAll: MTTestResourceClassForTestingCoverage methods. analysis := MTCoverageAnalysis - for: (Array with: MTClassForTestingCoverage with:MTTestResourceClassForTestingCoverage) - running: MTTestClassForTestingCoverage suite tests. + for: methods + running: MTTestClassForTestingCoverage suite tests. analysis run. - testCases := analysis result testCasesThatCovers: MTClassForTestingCoverage class >> #aClassCoveredMethod. - - self assert: ((testCases collect: [:each | each selector]) includes:#testCaseThatCoversAClassMethod). - + testCases := analysis result testCasesThatCovers: + MTClassForTestingCoverage class >> #aClassCoveredMethod. + self assert: + ((testCases collect: [ :each | each selector ]) includes: + #testCaseThatCoversAClassMethod) ] { #category : 'testing' } @@ -25,7 +29,7 @@ MTTestCoverageAnalysis >> testCoveredMethods [ | analysis | analysis := MTCoverageAnalysis - for: (Array with: MTClassForTestingCoverage) + for: MTClassForTestingCoverage methods running: MTTestClassForTestingCoverage suite tests. analysis run. @@ -38,7 +42,8 @@ MTTestCoverageAnalysis >> testCoveredMethods [ self deny: (analysis result uncoveredMethods includes: MTClassForTestingCoverage >> #aCoveredMethod). self deny: (analysis result uncoveredMethods includes: - MTClassForTestingCoverage >> #anUncoveredMethodSubClassResponsibility) + MTClassForTestingCoverage + >> #anUncoveredMethodSubClassResponsibility) ] { #category : 'testing' } From 2ae351f1e58d2855415d39a058117c39032681fa Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 17 Apr 2024 16:09:09 +0200 Subject: [PATCH 04/10] fix tests --- src/MuTalk-Model/MTCoverageAnalysis.class.st | 15 ++++++ src/MuTalk-Model/MTMutantEvaluation.class.st | 15 ++++-- .../MTTestCoverageAnalysis.class.st | 46 ++++++++++--------- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/MuTalk-Model/MTCoverageAnalysis.class.st b/src/MuTalk-Model/MTCoverageAnalysis.class.st index f8af46f..7d89192 100644 --- a/src/MuTalk-Model/MTCoverageAnalysis.class.st +++ b/src/MuTalk-Model/MTCoverageAnalysis.class.st @@ -21,6 +21,21 @@ MTCoverageAnalysis class >> for: aCollectionOfMethods running: aCollectionOfTest running: aCollectionOfTestCases ] +{ #category : 'instance creation' } +MTCoverageAnalysis class >> forClasses: aCollectionOfClasses running: aCollectionOfTestCases [ + + | methodCollection | + methodCollection := aCollectionOfClasses flatCollect: [ :class | + | methods | + methods := class package methodsForClass: class. + methods addAll: + (class package methodsForClass: class class). + methods ]. + ^ self new + initializeFor: methodCollection + running: aCollectionOfTestCases +] + { #category : 'private' } MTCoverageAnalysis >> addTestsFrom: aWrapper to: methodToTestDictionary [ aWrapper tests notEmpty diff --git a/src/MuTalk-Model/MTMutantEvaluation.class.st b/src/MuTalk-Model/MTMutantEvaluation.class.st index e38535f..83a90a6 100644 --- a/src/MuTalk-Model/MTMutantEvaluation.class.st +++ b/src/MuTalk-Model/MTMutantEvaluation.class.st @@ -37,11 +37,16 @@ MTMutantEvaluation >> coverageAnalysisResult [ { #category : 'initialize-release' } MTMutantEvaluation >> initializeCoverageResultIfNil [ - coverageAnalysisResult - ifNil:[ |coverageAnalysis| - coverageAnalysis := MTCoverageAnalysis for: (OrderedCollection with: mutation originalClass) - running: testCases. - coverageAnalysisResult := coverageAnalysis run;result]. + + coverageAnalysisResult ifNil: [ + | coverageAnalysis | + coverageAnalysis := MTCoverageAnalysis + forClasses: + (OrderedCollection with: mutation originalClass) + running: testCases. + coverageAnalysisResult := coverageAnalysis + run; + result ] ] { #category : 'initialize-release' } diff --git a/src/MuTalk-Tests/MTTestCoverageAnalysis.class.st b/src/MuTalk-Tests/MTTestCoverageAnalysis.class.st index 99c11d4..0a9e0cd 100644 --- a/src/MuTalk-Tests/MTTestCoverageAnalysis.class.st +++ b/src/MuTalk-Tests/MTTestCoverageAnalysis.class.st @@ -9,11 +9,11 @@ Class { MTTestCoverageAnalysis >> testBugWhenHavingATestResourceSendingToOther [ "the problem was when sending from a resource a message to another object wich class is going to be considered for coverage" - | analysis testCases methods | - methods := MTClassForTestingCoverage methods asOrderedCollection. - methods addAll: MTTestResourceClassForTestingCoverage methods. + | analysis testCases | analysis := MTCoverageAnalysis - for: methods + forClasses: (Array + with: MTClassForTestingCoverage + with: MTTestResourceClassForTestingCoverage) running: MTTestClassForTestingCoverage suite tests. analysis run. testCases := analysis result testCasesThatCovers: @@ -29,7 +29,7 @@ MTTestCoverageAnalysis >> testCoveredMethods [ | analysis | analysis := MTCoverageAnalysis - for: MTClassForTestingCoverage methods + forClasses: (Array with: MTClassForTestingCoverage) running: MTTestClassForTestingCoverage suite tests. analysis run. @@ -42,33 +42,37 @@ MTTestCoverageAnalysis >> testCoveredMethods [ self deny: (analysis result uncoveredMethods includes: MTClassForTestingCoverage >> #aCoveredMethod). self deny: (analysis result uncoveredMethods includes: - MTClassForTestingCoverage - >> #anUncoveredMethodSubClassResponsibility) + MTClassForTestingCoverage >> #anUncoveredMethodSubClassResponsibility) ] { #category : 'testing' } MTTestCoverageAnalysis >> testGettingTheTestCasesThatCoverAClassMethod [ - | analysis testCases| + + | analysis testCases | analysis := MTCoverageAnalysis - for: (Array with: MTClassForTestingCoverage) - running: MTTestClassForTestingCoverage suite tests. + forClasses: (Array with: MTClassForTestingCoverage) + running: MTTestClassForTestingCoverage suite tests. analysis run. - testCases := analysis result testCasesThatCovers: MTClassForTestingCoverage class >> #aClassCoveredMethod. - - self assert: ((testCases collect: [:each | each selector]) includes:#testCaseThatCoversAClassMethod). - + testCases := analysis result testCasesThatCovers: + MTClassForTestingCoverage class >> #aClassCoveredMethod. + self assert: + ((testCases collect: [ :each | each selector ]) includes: + #testCaseThatCoversAClassMethod) ] { #category : 'testing' } MTTestCoverageAnalysis >> testGettingTheTestCasesThatCoverAMethod [ - | analysis testCases| - analysis := MTCoverageAnalysis - for: (Array with: MTClassForTestingCoverage) - running: MTTestClassForTestingCoverage suite tests. + | analysis testCases | + analysis := MTCoverageAnalysis + forClasses: (Array with: MTClassForTestingCoverage) + running: MTTestClassForTestingCoverage suite tests. analysis run. - testCases := analysis result testCasesThatCovers: MTClassForTestingCoverage >> #aCoveredMethod. - self assert: ((testCases collect: [:each | each selector]) includes:#testCase1). - self deny: ((testCases collect: [:each | each selector]) includes:#testCase3). + testCases := analysis result testCasesThatCovers: + MTClassForTestingCoverage >> #aCoveredMethod. + self assert: + ((testCases collect: [ :each | each selector ]) includes: #testCase1). + self deny: + ((testCases collect: [ :each | each selector ]) includes: #testCase3) ] From e36cf6e8d3dbe23802b93ed3d43c8564a68080c7 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 17 Apr 2024 16:47:00 +0200 Subject: [PATCH 05/10] add tests for extension methods --- ...ssForAnalysisWithExtensionMethods.class.st | 6 +++++ ...rAnalysisWithExtensionMethods.extension.st | 5 ++++ .../package.st | 1 + src/MuTalk-Tests/MTAnalysisTest.class.st | 26 +++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 src/MuTalk-TestResources/MTAuxiliarClassForAnalysisWithExtensionMethods.class.st create mode 100644 src/MuTalk-TestResourcesForExtensionMethods/MTAuxiliarClassForAnalysisWithExtensionMethods.extension.st create mode 100644 src/MuTalk-TestResourcesForExtensionMethods/package.st diff --git a/src/MuTalk-TestResources/MTAuxiliarClassForAnalysisWithExtensionMethods.class.st b/src/MuTalk-TestResources/MTAuxiliarClassForAnalysisWithExtensionMethods.class.st new file mode 100644 index 0000000..dd0d882 --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarClassForAnalysisWithExtensionMethods.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarClassForAnalysisWithExtensionMethods', + #superclass : 'Object', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-TestResourcesForExtensionMethods/MTAuxiliarClassForAnalysisWithExtensionMethods.extension.st b/src/MuTalk-TestResourcesForExtensionMethods/MTAuxiliarClassForAnalysisWithExtensionMethods.extension.st new file mode 100644 index 0000000..b29917c --- /dev/null +++ b/src/MuTalk-TestResourcesForExtensionMethods/MTAuxiliarClassForAnalysisWithExtensionMethods.extension.st @@ -0,0 +1,5 @@ +Extension { #name : 'MTAuxiliarClassForAnalysisWithExtensionMethods' } + +{ #category : '*MuTalk-TestResourcesForExtensionMethods' } +MTAuxiliarClassForAnalysisWithExtensionMethods >> extensionMethod [ +] diff --git a/src/MuTalk-TestResourcesForExtensionMethods/package.st b/src/MuTalk-TestResourcesForExtensionMethods/package.st new file mode 100644 index 0000000..6ee4c69 --- /dev/null +++ b/src/MuTalk-TestResourcesForExtensionMethods/package.st @@ -0,0 +1 @@ +Package { #name : 'MuTalk-TestResourcesForExtensionMethods' } diff --git a/src/MuTalk-Tests/MTAnalysisTest.class.st b/src/MuTalk-Tests/MTAnalysisTest.class.st index 486a923..9ad7429 100644 --- a/src/MuTalk-Tests/MTAnalysisTest.class.st +++ b/src/MuTalk-Tests/MTAnalysisTest.class.st @@ -288,6 +288,32 @@ MTAnalysisTest >> testExecutingTwoMutations [ self assert: generalResult numberOfKilledMutants equals: 2 ] +{ #category : 'tests' } +MTAnalysisTest >> testExtensionMethodsMutatedWhenUsingPackages [ + + | analysis mutations selectors | + analysis := MTAnalysis new packagesToMutate: + { 'MuTalk-TestResourcesForExtensionMethods' }. + mutations := analysis generateMutations. + selectors := mutations collect: [ :mutant | + mutant originalMethod selector ]. + + self assert: (selectors includes: #extensionMethod) +] + +{ #category : 'tests' } +MTAnalysisTest >> testExtensionMethodsNotMutatedWhenUsingClasses [ + + | analysis mutations selectors | + analysis := MTAnalysis new classesToMutate: + { MTAuxiliarClassForAnalysisWithExtensionMethods }. + mutations := analysis generateMutations. + selectors := mutations collect: [ :mutant | + mutant originalMethod selector ]. + + self deny: (selectors includes: #extensionMethod) +] + { #category : 'tests' } MTAnalysisTest >> testRunningAllTests [ "This test verify that the test evaluation keeps running even after the first error, if specified" From bf86c303a6daffd0814bea57510244003eddb39b Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 17 Apr 2024 16:50:39 +0200 Subject: [PATCH 06/10] update baseline --- src/BaselineOfMuTalk/BaselineOfMuTalk.class.st | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BaselineOfMuTalk/BaselineOfMuTalk.class.st b/src/BaselineOfMuTalk/BaselineOfMuTalk.class.st index 676357b..32c1ebe 100644 --- a/src/BaselineOfMuTalk/BaselineOfMuTalk.class.st +++ b/src/BaselineOfMuTalk/BaselineOfMuTalk.class.st @@ -14,9 +14,10 @@ BaselineOfMuTalk >> baseline: spec [ package: 'TestCoverage'; package: 'MuTalk-Model' with: [ spec requires: #( 'TestCoverage' ) ]; package: 'MuTalk-TestResources' with: [ spec requires: #( 'MuTalk-Model' ) ]; + package: 'MuTalk-TestResourcesForExtensionMethods' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-TestResources' ) ]; package: 'MuTalk-CI' with: [ spec requires: #( 'MuTalk-Model' ) ]; package: 'MuTalk-CI-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-CI' ) ]; - package: 'MuTalk-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-TestResources' ) ]; + package: 'MuTalk-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-TestResources' 'MuTalk-TestResourcesForExtensionMethods ') ]; package: 'MuTalk-SpecUI' with: [ spec requires: #('MuTalk-Model') ]; package: 'MuTalk-Utilities' with: [ spec requires: #( 'MuTalk-Model' ) ]; package: 'MuTalk-Utilities-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-Utilities' ) ]. @@ -24,6 +25,6 @@ BaselineOfMuTalk >> baseline: spec [ spec group: 'default' with: - #( 'TestCoverage' 'MuTalk-Model' 'MuTalk-TestResources' 'MuTalk-Tests' + #( 'TestCoverage' 'MuTalk-Model' 'MuTalk-TestResources' 'MuTalk-TestResourcesForExtensionMethods' 'MuTalk-Tests' 'MuTalk-CI' 'MuTalk-CI-Tests' 'MuTalk-SpecUI' 'MuTalk-Utilities' 'MuTalk-Utilities-Tests' ) ] ] From 675c05bc64491a87f45baeb907e03d9cb30ed4bf Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 17 Apr 2024 16:55:51 +0200 Subject: [PATCH 07/10] remove modelClasses variable & refactor modelClasses method for mutalk-ci --- src/MuTalk-Model/MTAnalysis.class.st | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/MuTalk-Model/MTAnalysis.class.st b/src/MuTalk-Model/MTAnalysis.class.st index 08b6089..d1e1837 100644 --- a/src/MuTalk-Model/MTAnalysis.class.st +++ b/src/MuTalk-Model/MTAnalysis.class.st @@ -2,7 +2,6 @@ Class { #name : 'MTAnalysis', #superclass : 'Object', #instVars : [ - 'modelClasses', 'methodsToMutate', 'operators', 'elapsedTime', @@ -212,11 +211,10 @@ MTAnalysis >> methodsToMutate: anObject [ { #category : 'accessing' } MTAnalysis >> modelClasses [ - "Filter tests and testsResources" - ^ modelClasses reject: [ :class | - self testBaseClasses anySatisfy: [ :classToFilter | - class includesBehavior: classToFilter ] ] + | classes | + classes := methodsToMutate collect: #methodClass. + ^ classes copyWithoutDuplicates ] { #category : 'accessing' } From ed2cbf2de2b73a216b858344ce00029fcece8d2c Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 17 Apr 2024 17:06:09 +0200 Subject: [PATCH 08/10] fix typo --- src/BaselineOfMuTalk/BaselineOfMuTalk.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaselineOfMuTalk/BaselineOfMuTalk.class.st b/src/BaselineOfMuTalk/BaselineOfMuTalk.class.st index 32c1ebe..e3954f4 100644 --- a/src/BaselineOfMuTalk/BaselineOfMuTalk.class.st +++ b/src/BaselineOfMuTalk/BaselineOfMuTalk.class.st @@ -17,7 +17,7 @@ BaselineOfMuTalk >> baseline: spec [ package: 'MuTalk-TestResourcesForExtensionMethods' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-TestResources' ) ]; package: 'MuTalk-CI' with: [ spec requires: #( 'MuTalk-Model' ) ]; package: 'MuTalk-CI-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-CI' ) ]; - package: 'MuTalk-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-TestResources' 'MuTalk-TestResourcesForExtensionMethods ') ]; + package: 'MuTalk-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-TestResources' 'MuTalk-TestResourcesForExtensionMethods') ]; package: 'MuTalk-SpecUI' with: [ spec requires: #('MuTalk-Model') ]; package: 'MuTalk-Utilities' with: [ spec requires: #( 'MuTalk-Model' ) ]; package: 'MuTalk-Utilities-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-Utilities' ) ]. From 85fe6137f0d25b0316dfeee445c579dcc46ebf87 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 18 Apr 2024 10:49:45 +0200 Subject: [PATCH 09/10] add accessor to mt analysis in analysis utilities & refactor test --- .../MTNonMutatedMethodsAnalysisTest.class.st | 18 ++++++++++-------- .../MTMutantOperatorAnalysis.class.st | 10 ++++------ .../MTNonMutatedMethodsAnalysis.class.st | 8 +++----- .../MTUtilityAnalysis.class.st | 18 +++++++++++++++++- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/MuTalk-Utilities-Tests/MTNonMutatedMethodsAnalysisTest.class.st b/src/MuTalk-Utilities-Tests/MTNonMutatedMethodsAnalysisTest.class.st index e12af65..d61c486 100644 --- a/src/MuTalk-Utilities-Tests/MTNonMutatedMethodsAnalysisTest.class.st +++ b/src/MuTalk-Utilities-Tests/MTNonMutatedMethodsAnalysisTest.class.st @@ -8,13 +8,15 @@ Class { { #category : 'tests' } MTNonMutatedMethodsAnalysisTest >> testNonMutatedMethods [ - | results | - results := (MTNonMutatedMethodsAnalysis forClasses: { - MTAuxiliarClassForMatrix. - MTAuxiliarClassForMatrixTest }) - methodsWithoutMutation asSet. + | analysis results | + analysis := (MTNonMutatedMethodsAnalysis forClasses: + { MTAuxiliarClassForMatrix }) initializeMtAnalysis. + analysis mtAnalysis operators: { + MTReplacePlusWithMinusMutantOperator new. + MTReplaceMinusWithPlusMutantOperator new }. + results := analysis methodsWithoutMutation. - self - assert: results - equals: MTAuxiliarClassForMatrixTest methods asSet + self assert: results equals: { + (MTAuxiliarClassForMatrix >> #initialize). + (MTAuxiliarClassForMatrix >> #reset) } asOrderedCollection ] diff --git a/src/MuTalk-Utilities/MTMutantOperatorAnalysis.class.st b/src/MuTalk-Utilities/MTMutantOperatorAnalysis.class.st index 9876023..4112d00 100644 --- a/src/MuTalk-Utilities/MTMutantOperatorAnalysis.class.st +++ b/src/MuTalk-Utilities/MTMutantOperatorAnalysis.class.st @@ -41,14 +41,12 @@ MTMutantOperatorAnalysis >> operatorDictionary [ { #category : 'computing' } MTMutantOperatorAnalysis >> operatorDictionaryFromAnalysis [ - | analysis dic | - analysis := MTAnalysis new - classesToMutate: classes; - testClasses: { }. + | dic | + self initializeMtAnalysis. - analysis generateMutations. + mtAnalysis generateMutations. - ^ dic := (analysis mutations groupedBy: [ :e | e operator species ]) + ^ dic := (mtAnalysis mutations groupedBy: [ :e | e operator species ]) collect: [ :coll | coll size ] ] diff --git a/src/MuTalk-Utilities/MTNonMutatedMethodsAnalysis.class.st b/src/MuTalk-Utilities/MTNonMutatedMethodsAnalysis.class.st index 886ac4b..c4d4852 100644 --- a/src/MuTalk-Utilities/MTNonMutatedMethodsAnalysis.class.st +++ b/src/MuTalk-Utilities/MTNonMutatedMethodsAnalysis.class.st @@ -26,13 +26,11 @@ MTNonMutatedMethodsAnalysis >> methodsWithoutMutation [ { #category : 'computing' } MTNonMutatedMethodsAnalysis >> mutatedMethods [ - | analysis mutatedMethods | - analysis := MTAnalysis new - classesToMutate: classes; - testClasses: { }. + | mutatedMethods | + self initializeMtAnalysis. mutatedMethods := Set withAll: - (analysis generateMutations collect: + (mtAnalysis generateMutations collect: #originalMethod). ^ mutatedMethods ] diff --git a/src/MuTalk-Utilities/MTUtilityAnalysis.class.st b/src/MuTalk-Utilities/MTUtilityAnalysis.class.st index 949fa3a..6b50d1a 100644 --- a/src/MuTalk-Utilities/MTUtilityAnalysis.class.st +++ b/src/MuTalk-Utilities/MTUtilityAnalysis.class.st @@ -2,7 +2,8 @@ Class { #name : 'MTUtilityAnalysis', #superclass : 'Object', #instVars : [ - 'classes' + 'classes', + 'mtAnalysis' ], #category : 'MuTalk-Utilities', #package : 'MuTalk-Utilities' @@ -38,3 +39,18 @@ MTUtilityAnalysis >> classes: anObject [ classes := anObject ] + +{ #category : 'initialization' } +MTUtilityAnalysis >> initializeMtAnalysis [ + + mtAnalysis ifNil: [ + mtAnalysis := MTAnalysis new + classesToMutate: classes; + testClasses: { } ] +] + +{ #category : 'accessing' } +MTUtilityAnalysis >> mtAnalysis [ + + ^ mtAnalysis +] From 96bf8dbbe0ee04e49428c668af1f90d2074f91b9 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 18 Apr 2024 10:53:46 +0200 Subject: [PATCH 10/10] change ordered collections to sets --- .../MTNonMutatedMethodsAnalysisTest.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MuTalk-Utilities-Tests/MTNonMutatedMethodsAnalysisTest.class.st b/src/MuTalk-Utilities-Tests/MTNonMutatedMethodsAnalysisTest.class.st index d61c486..d172e0a 100644 --- a/src/MuTalk-Utilities-Tests/MTNonMutatedMethodsAnalysisTest.class.st +++ b/src/MuTalk-Utilities-Tests/MTNonMutatedMethodsAnalysisTest.class.st @@ -14,9 +14,9 @@ MTNonMutatedMethodsAnalysisTest >> testNonMutatedMethods [ analysis mtAnalysis operators: { MTReplacePlusWithMinusMutantOperator new. MTReplaceMinusWithPlusMutantOperator new }. - results := analysis methodsWithoutMutation. + results := analysis methodsWithoutMutation asSet. self assert: results equals: { (MTAuxiliarClassForMatrix >> #initialize). - (MTAuxiliarClassForMatrix >> #reset) } asOrderedCollection + (MTAuxiliarClassForMatrix >> #reset) } asSet ]