Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented budgets #33

Merged
merged 15 commits into from
Dec 8, 2023
12 changes: 7 additions & 5 deletions src/MuTalk-Model/AllMutantSelectionStrategy.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Class {
#name : #AllMutantSelectionStrategy,
#superclass : #MutantSelectionStrategy,
#category : #'MuTalk-Model-Mutations generation strategies'
#name : 'AllMutantSelectionStrategy',
#superclass : 'MutantSelectionStrategy',
#category : 'MuTalk-Model-Mutations generation strategies',
#package : 'MuTalk-Model',
#tag : 'Mutations generation strategies'
}

{ #category : #generating }
{ #category : 'generating' }
AllMutantSelectionStrategy >> classesAndMetaclassesFrom: modelClasses [
^ modelClasses
inject: OrderedCollection new
Expand All @@ -14,7 +16,7 @@ AllMutantSelectionStrategy >> classesAndMetaclassesFrom: modelClasses [
classes]
]

{ #category : #generating }
{ #category : 'generating' }
AllMutantSelectionStrategy >> methodsToMutateFrom: aMutationTestingAnalysis [
^ (self classesAndMetaclassesFrom: aMutationTestingAnalysis modelClasses)
inject: OrderedCollection new
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Class {
#name : #AllTestsMethodsRunningTestSelectionStrategy,
#superclass : #TestSelectionStrategy,
#category : #'MuTalk-Model-Mutant evaluation strategies'
#name : 'AllTestsMethodsRunningTestSelectionStrategy',
#superclass : 'TestSelectionStrategy',
#category : 'MuTalk-Model-Mutant evaluation strategies',
#package : 'MuTalk-Model',
#tag : 'Mutant evaluation strategies'
}

{ #category : #private }
{ #category : 'private' }
AllTestsMethodsRunningTestSelectionStrategy >> testCasesToEvaluate: aMutation for: aMutantEvaluation [
^aMutantEvaluation testCases.

Expand Down
18 changes: 10 additions & 8 deletions src/MuTalk-Model/BlockBasedMutantOperator.class.st
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
Class {
#name : #BlockBasedMutantOperator,
#superclass : #MutantOperator,
#category : #'MuTalk-Model-Operators'
#name : 'BlockBasedMutantOperator',
#superclass : 'MutantOperator',
#category : 'MuTalk-Model-Operators',
#package : 'MuTalk-Model',
#tag : 'Operators'
}

{ #category : #testing }
{ #category : 'testing' }
BlockBasedMutantOperator class >> isOriginalOperator [
^ false
]

{ #category : #testing }
{ #category : 'testing' }
BlockBasedMutantOperator >> isAPosibleMutatedNode: aRBMethodNode [

| nodeThatMatches |
Expand All @@ -18,7 +20,7 @@ BlockBasedMutantOperator >> isAPosibleMutatedNode: aRBMethodNode [
self is: nodeThatMatches equalTo: aRBMethodNode ]
]

{ #category : #testing }
{ #category : 'testing' }
BlockBasedMutantOperator >> isAPosibleNodeToMutate: aRBMethodNode [

| nodeThatMatches |
Expand All @@ -30,7 +32,7 @@ BlockBasedMutantOperator >> isAPosibleNodeToMutate: aRBMethodNode [
self is: aRBMethodNode equalTo: nodeThatMatches ]
]

{ #category : #private }
{ #category : 'private' }
BlockBasedMutantOperator >> modifiedSourceFor: aCompiledMethod with: aParseTree number: aNumber [

| parser allNodes |
Expand All @@ -44,7 +46,7 @@ BlockBasedMutantOperator >> modifiedSourceFor: aCompiledMethod with: aParseTree
^ parser formattedCode
]

{ #category : #private }
{ #category : 'private' }
BlockBasedMutantOperator >> timesToApplyIn: aCompiledMethod with: aParseTree [

"Evaluates how many times can the operator be applyied"
Expand Down
8 changes: 4 additions & 4 deletions src/MuTalk-Model/Boolean.extension.st
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Extension { #name : #Boolean }
Extension { #name : 'Boolean' }

{ #category : #'*MuTalk-Model' }
{ #category : '*MuTalk-Model' }
Boolean >> bEqv: aBlock [

^self eqv: aBlock value
]

{ #category : #'*MuTalk-Model' }
{ #category : '*MuTalk-Model' }
Boolean >> bXor: aBlock [

^self xor: aBlock value
]

{ #category : #'*MuTalk-Model' }
{ #category : '*MuTalk-Model' }
Boolean >> nand: alternativeBlock [

^(self and: alternativeBlock) not
Expand Down
14 changes: 8 additions & 6 deletions src/MuTalk-Model/ClassTestCasesSelectionStrategy.class.st
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
Class {
#name : #ClassTestCasesSelectionStrategy,
#superclass : #TestCasesSelectionStrategy,
#category : 'MuTalk-Model-TestCases selection strategies'
#name : 'ClassTestCasesSelectionStrategy',
#superclass : 'TestCasesSelectionStrategy',
#category : 'MuTalk-Model-TestCases selection strategies',
#package : 'MuTalk-Model',
#tag : 'TestCases selection strategies'
}

{ #category : #printing }
{ #category : 'printing' }
ClassTestCasesSelectionStrategy >> description [
^'Tests in Same Clases'
]

{ #category : #selecting }
{ #category : 'selecting' }
ClassTestCasesSelectionStrategy >> testCasesFor: aTestCollection [
"Returns all tests in testClases from a collection of tests."

Expand All @@ -23,7 +25,7 @@ ClassTestCasesSelectionStrategy >> testCasesFor: aTestCollection [
resultTests ]
]

{ #category : #selecting }
{ #category : 'selecting' }
ClassTestCasesSelectionStrategy >> testClassesFrom: aTestCollection [
^ (aTestCollection collect: [ :testCase | testCase class ]) asSet
]
4 changes: 2 additions & 2 deletions src/MuTalk-Model/CompiledMethod.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #CompiledMethod }
Extension { #name : 'CompiledMethod' }

{ #category : #'*MuTalk-Model' }
{ #category : '*MuTalk-Model' }
CompiledMethod >> ignoredMutationOperators [

^ (self pragmaAt: #ignoreForMutations:)
Expand Down
39 changes: 20 additions & 19 deletions src/MuTalk-Model/CoverageAnalysis.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #CoverageAnalysis,
#superclass : #Object,
#name : 'CoverageAnalysis',
#superclass : 'Object',
#instVars : [
'classes',
'result',
Expand All @@ -9,15 +9,16 @@ Class {
'currentTest',
'testRunningElapsedTime'
],
#category : #'MuTalk-Model'
#category : 'MuTalk-Model',
#package : 'MuTalk-Model'
}

{ #category : #'instance creation' }
{ #category : 'instance creation' }
CoverageAnalysis class >> for: aCollectionOfClasses running: aCollectionOfTestCases [
^self new initializeFor: aCollectionOfClasses running: aCollectionOfTestCases
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> addTestsFrom: aWrapper to: methodToTestDictionary [
aWrapper tests notEmpty
ifTrue: [(methodToTestDictionary
Expand All @@ -26,7 +27,7 @@ CoverageAnalysis >> addTestsFrom: aWrapper to: methodToTestDictionary [
addAll: aWrapper tests]
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> classesAndMetaclasses [
classesAndMetaclasses isNil ifTrue:[
classesAndMetaclasses := (classes collect:[:aClass | aClass class]) asOrderedCollection.
Expand All @@ -35,34 +36,34 @@ CoverageAnalysis >> classesAndMetaclasses [

]

{ #category : #accessing }
{ #category : 'accessing' }
CoverageAnalysis >> currentTest [
^ currentTest
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> currentTest: aTestCase [
currentTest := aTestCase.
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> flushMethodLookupCaches [
Behavior flushCache.

]

{ #category : #'initialize-release' }
{ #category : 'initialize-release' }
CoverageAnalysis >> initializeFor: aCollectionOfClasses running: aCollectionOfTestCases [
classes := aCollectionOfClasses.
testCases := aCollectionOfTestCases
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> installAll: wrappers [
wrappers do: [ :each | each install ]
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> methodReferences [
^ self classesAndMetaclasses
inject: OrderedCollection new
Expand All @@ -73,7 +74,7 @@ CoverageAnalysis >> methodReferences [
methodReferences]
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> methodToTestDictionaryFrom: wrappers [
^ wrappers
inject: IdentityDictionary new
Expand All @@ -82,17 +83,17 @@ CoverageAnalysis >> methodToTestDictionaryFrom: wrappers [
methodToTestDictionary]
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> methodWrappersFor: methodReferences [
^ methodReferences collect: [ :each | MethodWrapperForCoverage on: each for: self ]
]

{ #category : #accessing }
{ #category : 'accessing' }
CoverageAnalysis >> result [
^result
]

{ #category : #evaluating }
{ #category : 'evaluating' }
CoverageAnalysis >> run [

| wrappers methodReferences |
Expand All @@ -105,7 +106,7 @@ CoverageAnalysis >> run [
result methodReferences: (self classesAndMetaclasses flatCollect: [:cls | cls methods])
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> runTests [
|suite|
testRunningElapsedTime := Time millisecondsToRun:
Expand All @@ -114,15 +115,15 @@ CoverageAnalysis >> runTests [
suite run ].
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> runTestsInstalling: wrappers [
[self installAll: wrappers.
self flushMethodLookupCaches.
self runTests]
ensure: [self uninstallAll: wrappers]
]

{ #category : #private }
{ #category : 'private' }
CoverageAnalysis >> uninstallAll: wrappers [
^ wrappers do: [ :each | each uninstall ]
]
29 changes: 15 additions & 14 deletions src/MuTalk-Model/CoverageAnalysisResult.class.st
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
Class {
#name : #CoverageAnalysisResult,
#superclass : #Object,
#name : 'CoverageAnalysisResult',
#superclass : 'Object',
#instVars : [
'methodToTestDictionary',
'timeToRunTests',
'methodReferences'
],
#category : #'MuTalk-Model'
#category : 'MuTalk-Model',
#package : 'MuTalk-Model'
}

{ #category : #'instance creation' }
{ #category : 'instance creation' }
CoverageAnalysisResult class >> from: aDictionaryOfMethodToTestCasesRelations [
^self new initializeFrom: aDictionaryOfMethodToTestCasesRelations.
]

{ #category : #'instance creation' }
{ #category : 'instance creation' }
CoverageAnalysisResult class >> from: aDictionaryOfMethodToTestCasesRelations elapsedTime: aTimeToRunTests [
^self new initializeFrom: aDictionaryOfMethodToTestCasesRelations elapsedTime: aTimeToRunTests.
]

{ #category : #api }
{ #category : 'api' }
CoverageAnalysisResult >> coveragePerTest: aMutationTestingAnalysis [

| coveragePerTest |
Expand All @@ -35,45 +36,45 @@ CoverageAnalysisResult >> coveragePerTest: aMutationTestingAnalysis [
^ coveragePerTest
]

{ #category : #accessing }
{ #category : 'accessing' }
CoverageAnalysisResult >> coveredMethods [
^methodToTestDictionary keys asIdentitySet. "select:[:each | (methodToTestDictionary at:each) notEmpty]."
]

{ #category : #'initialize-release' }
{ #category : 'initialize-release' }
CoverageAnalysisResult >> initializeFrom: aDictionaryOfMethodToTestCasesRelations [
methodToTestDictionary := aDictionaryOfMethodToTestCasesRelations
]

{ #category : #'initialize-release' }
{ #category : 'initialize-release' }
CoverageAnalysisResult >> initializeFrom: aDictionaryOfMethodToTestCasesRelations elapsedTime: aTimeToRunTests [
methodToTestDictionary := aDictionaryOfMethodToTestCasesRelations.
timeToRunTests := aTimeToRunTests.
]

{ #category : #accessing }
{ #category : 'accessing' }
CoverageAnalysisResult >> methodReferences [

^ methodReferences
]

{ #category : #accessing }
{ #category : 'accessing' }
CoverageAnalysisResult >> methodReferences: anObject [

methodReferences := anObject
]

{ #category : #accessing }
{ #category : 'accessing' }
CoverageAnalysisResult >> testCasesThatCovers: aCompiledMethod [
^methodToTestDictionary at:aCompiledMethod ifAbsent:[OrderedCollection new.].
]

{ #category : #accessing }
{ #category : 'accessing' }
CoverageAnalysisResult >> timeToRunTests [
^timeToRunTests
]

{ #category : #accessing }
{ #category : 'accessing' }
CoverageAnalysisResult >> uncoveredMethods [

^ (self methodReferences reject: #isSubclassResponsibility) asSet difference: self coveredMethods
Expand Down
9 changes: 5 additions & 4 deletions src/MuTalk-Model/CoverageTestSuiteSelector.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Class {
#name : #CoverageTestSuiteSelector,
#superclass : #Object,
#category : #'MuTalk-Model'
#name : 'CoverageTestSuiteSelector',
#superclass : 'Object',
#category : 'MuTalk-Model',
#package : 'MuTalk-Model'
}

{ #category : #selecting }
{ #category : 'selecting' }
CoverageTestSuiteSelector >> selectTestsFrom: aMutationTestingAnalysis [

| methodsToCover testCaseCandidates selectedTests |
Expand Down
Loading
Loading