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

Log refactoring and improvement #97

Merged
merged 14 commits into from
Mar 14, 2024
14 changes: 11 additions & 3 deletions src/MuTalk-Model/MTAnalysis.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ MTAnalysis >> defaultBudget [
{ #category : 'accessing - defaults' }
MTAnalysis >> defaultLogger [

^ MTNullAnalysisLogger new
^ MTNullLogger new
]

{ #category : 'accessing - defaults' }
Expand Down Expand Up @@ -105,6 +105,7 @@ MTAnalysis >> generalResult [
{ #category : 'running' }
MTAnalysis >> generateCoverageAnalysis [

logger logStartCoverageAnalysis.
coverageAnalysisResult := (MTCoverageAnalysis
for: self modelClasses
running: testCases)
Expand All @@ -115,16 +116,20 @@ MTAnalysis >> generateCoverageAnalysis [
{ #category : 'running' }
MTAnalysis >> generateMutations [

logger logStartMutationGeneration.
^ mutations ifNil: [
mutations := mutantSelectionStrategy
mutationsFor: self
loggingIn: logger ]
loggingIn: logger.
logger logTotalNumberOfMutations: mutations.
mutations ]
]

{ #category : 'running' }
MTAnalysis >> generateResults [

mutantResults := OrderedCollection new.
logger logStartMutationEvaluation.

mutations do: [ :aMutation |
(budget exceedsBudgetOn: mutantResults fromTotalMutations: mutations)
Expand All @@ -136,6 +141,7 @@ MTAnalysis >> generateResults [
following: testSelectionStrategy
andConsidering: self coverageAnalysisResult)
valueStoppingOnError: stopOnErrorOrFail) ].
logger logEnd.
^ mutantResults
]

Expand Down Expand Up @@ -173,6 +179,8 @@ MTAnalysis >> logger [
{ #category : 'accessing' }
MTAnalysis >> logger: anObject [

testCases do: [ :testCaseReference |
testCaseReference logger: anObject ].
logger := anObject
]

Expand Down Expand Up @@ -296,7 +304,7 @@ MTAnalysis >> testCasesFrom: aClassCollection [
MTAnalysis >> testCasesReferencesFrom: testClass [

^ testClass buildSuite tests collect: [ :each |
MTTestCaseReference for: each ]
MTTestCaseReference for: each logger: logger ]
]

{ #category : 'accessing' }
Expand Down
66 changes: 0 additions & 66 deletions src/MuTalk-Model/MTAnalysisFileLogger.class.st

This file was deleted.

42 changes: 42 additions & 0 deletions src/MuTalk-Model/MTAnalysisLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,54 @@ MTAnalysisLogger >> logAnalysisStartFor: aMutationTestingAnalysis [
self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logEnd [

^ self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logNumberOfGeneratedMutations: aNumber [

^ self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logRunningTest: aTestCaseReference [

self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logStartBuildingMutantionsFor: aCompiledMethod using: aMutantOperator [
self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logStartCoverageAnalysis [

^ self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logStartEvaluating: aMethodMutation [
self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logStartMutationEvaluation [

^ self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logStartMutationGeneration [

^ self subclassResponsibility
]

{ #category : 'logging' }
MTAnalysisLogger >> logTotalNumberOfMutations: mutations [

^ self subclassResponsibility
]
41 changes: 41 additions & 0 deletions src/MuTalk-Model/MTFileLogger.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Class {
#name : 'MTFileLogger',
#superclass : 'MTStreamLogger',
#instVars : [
'fileReference'
],
#category : 'MuTalk-Model-Logging',
#package : 'MuTalk-Model',
#tag : 'Logging'
}

{ #category : 'instance creation' }
MTFileLogger class >> toFileNamed: aString [

^ self basicNew initializeToFileNamed: aString
]

{ #category : 'accessing' }
MTFileLogger >> fileReference [

^ fileReference
]

{ #category : 'accessing' }
MTFileLogger >> fileReference: anObject [

fileReference := anObject
]

{ #category : 'initialization' }
MTFileLogger >> initializeStream [

stream := fileReference writeStream
]

{ #category : 'initialize-release' }
MTFileLogger >> initializeToFileNamed: aString [

fileReference := aString asFileReference.
self initialize
]
23 changes: 15 additions & 8 deletions src/MuTalk-Model/MTMutantSelectionStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,27 @@ MTMutantSelectionStrategy >> mutationsFor: aMutationTestingAnalysis loggingIn: a
]

{ #category : 'generating' }
MTMutantSelectionStrategy >> mutationsFor: aMethod usingAll: aCollectionOfMutantOperators logginIn: aLogger [
MTMutantSelectionStrategy >> mutationsFor: aMethod usingAll: aCollectionOfMutantOperators logginIn: aLogger [

| parseTree |
parseTree := aMethod parseTree.
^ aCollectionOfMutantOperators
inject: OrderedCollection new
into: [:mutations :anOperator |
aLogger logStartBuildingMutantionsFor: aMethod using: anOperator.
(aMethod ignoredMutationOperators includes: anOperator class)
ifFalse: [ mutations addAll: (anOperator mutationsFor: aMethod with: parseTree) ].
mutations ]
inject: OrderedCollection new
into: [ :mutations :anOperator |
aLogger logStartBuildingMutantionsFor: aMethod using: anOperator.
(aMethod ignoredMutationOperators includes: anOperator class)
ifFalse: [
| newMutations |
newMutations := anOperator
mutationsFor: aMethod
with: parseTree.
aLogger logNumberOfGeneratedMutations: newMutations size.
mutations addAll: newMutations ].
mutations ]
]

{ #category : 'logging' }
MTMutantSelectionStrategy >> nullLogger [

^ MTNullAnalysisLogger new.
^ MTNullLogger new.
]
28 changes: 0 additions & 28 deletions src/MuTalk-Model/MTNullAnalysisLogger.class.st

This file was deleted.

70 changes: 70 additions & 0 deletions src/MuTalk-Model/MTNullLogger.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Class {
#name : 'MTNullLogger',
#superclass : 'MTAnalysisLogger',
#classInstVars : [
'instance'
],
#category : 'MuTalk-Model-Logging',
#package : 'MuTalk-Model',
#tag : 'Logging'
}

{ #category : 'instance creation' }
MTNullLogger class >> new [
instance ifNil:[instance := super new.].
^instance.
]

{ #category : 'logging' }
MTNullLogger >> logAnalysisStartFor: aMutationTestingAnalysis [
]

{ #category : 'logging' }
MTNullLogger >> logEnd [


]

{ #category : 'logging' }
MTNullLogger >> logNumberOfGeneratedMutations: aNumber [


]

{ #category : 'logging' }
MTNullLogger >> logRunningTest: aTestCaseReference [


]

{ #category : 'logging' }
MTNullLogger >> logStartBuildingMutantionsFor: aCompiledMethod using: aMutantOperator [
]

{ #category : 'logging' }
MTNullLogger >> logStartCoverageAnalysis [


]

{ #category : 'logging' }
MTNullLogger >> logStartEvaluating: aMethodMutation [
]

{ #category : 'logging' }
MTNullLogger >> logStartMutationEvaluation [


]

{ #category : 'logging' }
MTNullLogger >> logStartMutationGeneration [


]

{ #category : 'logging' }
MTNullLogger >> logTotalNumberOfMutations: mutations [


]
Loading
Loading