Skip to content

Commit

Permalink
Merge pull request #84 from DurieuxPol/enh/resultRapport
Browse files Browse the repository at this point in the history
General result shows filtered tests
  • Loading branch information
guillep authored Mar 14, 2024
2 parents 99c63f8 + 8e493f1 commit d742fbf
Show file tree
Hide file tree
Showing 12 changed files with 251 additions and 26 deletions.
11 changes: 7 additions & 4 deletions src/MuTalk-Model/MTAnalysis.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ MTAnalysis >> doNotStopOnErrorOrFail [
{ #category : 'results' }
MTAnalysis >> generalResult [

^ MTGeneralResult for: mutantResults timed: elapsedTime
^ MTGeneralResult
for: mutantResults
timed: elapsedTime
excludedTests: testFilter excludedTests
]

{ #category : 'running' }
Expand All @@ -121,17 +124,17 @@ MTAnalysis >> generateMutations [
{ #category : 'running' }
MTAnalysis >> generateResults [

| tests |
| filteredTests |
mutantResults := OrderedCollection new.
tests := testFilter filterTests: testCases.
filteredTests := testFilter filterTests: testCases.

mutations do: [ :aMutation |
(budget exceedsBudgetOn: mutantResults fromTotalMutations: mutations)
ifTrue: [ ^ mutantResults ].
logger logStartEvaluating: aMutation.
mutantResults add: ((MTMutantEvaluation
for: aMutation
using: tests
using: filteredTests
following: testSelectionStrategy
andConsidering: self coverageAnalysisResult)
valueStoppingOnError: stopOnErrorOrFail) ].
Expand Down
14 changes: 13 additions & 1 deletion src/MuTalk-Model/MTBlockTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ Class {
}

{ #category : 'enumerating' }
MTBlockTestFilter >> filterTests: aTestCaseCollection [
MTBlockTestFilter >> excludedTestsFrom: aTestCaseCollection [

^ aTestCaseCollection reject: condition
]

{ #category : 'accessing' }
MTBlockTestFilter >> filteredTestReason [

^ 'Took longer than ', condition printString, ' to run'
]

{ #category : 'enumerating' }
MTBlockTestFilter >> filteredTestsFrom: aTestCaseCollection [

^ aTestCaseCollection select: condition
]
14 changes: 13 additions & 1 deletion src/MuTalk-Model/MTFreeTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ Class {
}

{ #category : 'enumerating' }
MTFreeTestFilter >> filterTests: aTestCaseCollection [
MTFreeTestFilter >> excludedTestsFrom: aTestCaseCollection [

^ OrderedCollection empty
]

{ #category : 'accessing' }
MTFreeTestFilter >> filteredTestReason [

^ 'Not filtered'
]

{ #category : 'enumerating' }
MTFreeTestFilter >> filteredTestsFrom: aTestCaseCollection [

^ aTestCaseCollection
]
48 changes: 40 additions & 8 deletions src/MuTalk-Model/MTGeneralResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Class {
#superclass : 'Object',
#instVars : [
'particularResults',
'elapsedTime'
'elapsedTime',
'excludedTests'
],
#category : 'MuTalk-Model-Core',
#package : 'MuTalk-Model',
Expand All @@ -16,14 +17,31 @@ MTGeneralResult class >> empty [
]

{ #category : 'instance creation' }
MTGeneralResult class >> for: mutantsEvaluationsResults [
^self for: mutantsEvaluationsResults timed: Duration new
MTGeneralResult class >> for: mutantsEvaluationsResults [

^ self
for: mutantsEvaluationsResults
timed: Duration new
excludedTests: #( )
]

{ #category : 'instance creation' }
MTGeneralResult class >> for: mutantsEvaluationsResults timed: anElapsedTime [

^ self
for: mutantsEvaluationsResults
timed: anElapsedTime
excludedTests: #( )
]

{ #category : 'instance creation' }
MTGeneralResult class >> for: mutantsEvaluationsResults timed: anElapsedTime [
^ self new initializeFor: mutantsEvaluationsResults timed: anElapsedTime;
yourself
MTGeneralResult class >> for: mutantsEvaluationsResults timed: anElapsedTime excludedTests: someTests [

^ self new
initializeFor: mutantsEvaluationsResults
timed: anElapsedTime
excludedTests: someTests;
yourself
]

{ #category : 'accessing' }
Expand All @@ -36,10 +54,24 @@ MTGeneralResult >> elapsedTime [
^ elapsedTime
]

{ #category : 'accessing' }
MTGeneralResult >> excludedTests [

^ excludedTests
]

{ #category : 'accessing' }
MTGeneralResult >> excludedTests: anObject [

excludedTests := anObject
]

{ #category : 'initialize' }
MTGeneralResult >> initializeFor: mutantsEvaluationsResults timed: anElapsedTime [
MTGeneralResult >> initializeFor: mutantsEvaluationsResults timed: anElapsedTime excludedTests: someTests [

particularResults := mutantsEvaluationsResults.
elapsedTime := anElapsedTime
elapsedTime := anElapsedTime.
excludedTests := someTests
]

{ #category : 'testing' }
Expand Down
17 changes: 14 additions & 3 deletions src/MuTalk-Model/MTPragmaRejectionTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ Class {
}

{ #category : 'enumerating' }
MTPragmaRejectionTestFilter >> filterTests: aTestCaseCollection [
MTPragmaRejectionTestFilter >> excludedTestsFrom: aTestCaseCollection [

^ aTestCaseCollection reject: [ :testCaseReference |
self isPragmaValidFrom: testCaseReference ]
^ self selectPragmaInTestCollection: aTestCaseCollection
]

{ #category : 'enumerating' }
MTPragmaRejectionTestFilter >> filteredTestsFrom: aTestCaseCollection [

^ self rejectPragmaInTestCollection: aTestCaseCollection
]

{ #category : 'accessing' }
MTPragmaRejectionTestFilter >> reasonString [

^ 'Contains the pragma <' , condition
]
17 changes: 14 additions & 3 deletions src/MuTalk-Model/MTPragmaSelectionTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ Class {
}

{ #category : 'enumerating' }
MTPragmaSelectionTestFilter >> filterTests: aTestCaseCollection [
MTPragmaSelectionTestFilter >> excludedTestsFrom: aTestCaseCollection [

^ aTestCaseCollection select: [ :testCaseReference |
self isPragmaValidFrom: testCaseReference ]
^ self rejectPragmaInTestCollection: aTestCaseCollection
]

{ #category : 'enumerating' }
MTPragmaSelectionTestFilter >> filteredTestsFrom: aTestCaseCollection [

^ self selectPragmaInTestCollection: aTestCaseCollection
]

{ #category : 'accessing' }
MTPragmaSelectionTestFilter >> reasonString [

^ 'Does not contain the pragma <' , condition
]
36 changes: 33 additions & 3 deletions src/MuTalk-Model/MTPragmaTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,20 @@ MTPragmaTestFilter class >> isAbstract [
^ self == MTPragmaTestFilter
]

{ #category : 'enumerating' }
MTPragmaTestFilter >> filterTests: aTestCaseCollection [
{ #category : 'accessing' }
MTPragmaTestFilter >> filteredTestReason [

| reasonString |
reasonString := self reasonString.

^ pragmaArguments isEmpty
ifTrue: [ reasonString , '>' ]
ifFalse: [
| pragmaString |
pragmaString := pragmaArguments reduce: [ :arg1 :arg2 |
arg1 , ' ' , arg2 ].

^ self subclassResponsibility
reasonString , pragmaString , '>' ]
]

{ #category : 'testing' }
Expand All @@ -56,3 +66,23 @@ MTPragmaTestFilter >> pragmaArguments: anObject [

pragmaArguments := anObject
]

{ #category : 'accessing' }
MTPragmaTestFilter >> reasonString [

self subclassResponsibility
]

{ #category : 'enumerating' }
MTPragmaTestFilter >> rejectPragmaInTestCollection: aTestCaseCollection [

^ aTestCaseCollection reject: [ :testCaseReference |
self isPragmaValidFrom: testCaseReference ]
]

{ #category : 'enumerating' }
MTPragmaTestFilter >> selectPragmaInTestCollection: aTestCaseCollection [

^ aTestCaseCollection select: [ :testCaseReference |
self isPragmaValidFrom: testCaseReference ]
]
48 changes: 47 additions & 1 deletion src/MuTalk-Model/MTTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Class {
#name : 'MTTestFilter',
#superclass : 'Object',
#instVars : [
'condition'
'condition',
'excludedTests',
'filteredTests'
],
#category : 'MuTalk-Model-Test filters',
#package : 'MuTalk-Model',
Expand All @@ -29,8 +31,52 @@ MTTestFilter >> condition: aCondition [
condition := aCondition
]

{ #category : 'accessing' }
MTTestFilter >> excludedTests [

^ excludedTests
]

{ #category : 'accessing' }
MTTestFilter >> excludedTests: anObject [

excludedTests := anObject
]

{ #category : 'enumerating' }
MTTestFilter >> excludedTestsFrom: aTestCaseCollection [

^ self subclassResponsibility
]

{ #category : 'enumerating' }
MTTestFilter >> filterTests: aTestCaseCollection [

excludedTests := (self excludedTestsFrom: aTestCaseCollection)
collect: [ :test | test -> self filteredTestReason ].
^ filteredTests := self filteredTestsFrom: aTestCaseCollection
]

{ #category : 'accessing' }
MTTestFilter >> filteredTestReason [

self subclassResponsibility
]

{ #category : 'accessing' }
MTTestFilter >> filteredTests [

^ filteredTests
]

{ #category : 'accessing' }
MTTestFilter >> filteredTests: anObject [

filteredTests := anObject
]

{ #category : 'enumerating' }
MTTestFilter >> filteredTestsFrom: aTestCaseCollection [

^ self subclassResponsibility
]
15 changes: 14 additions & 1 deletion src/MuTalk-Model/MTTimeTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ Class {
}

{ #category : 'enumerating' }
MTTimeTestFilter >> filterTests: aTestCaseCollection [
MTTimeTestFilter >> excludedTestsFrom: aTestCaseCollection [

^ aTestCaseCollection reject: [ :testCaseReference |
testCaseReference lastTimeToRun <= condition ]
]

{ #category : 'accessing' }
MTTimeTestFilter >> filteredTestReason [

^ 'Took longer than ', condition printString, ' to run'
]

{ #category : 'enumerating' }
MTTimeTestFilter >> filteredTestsFrom: aTestCaseCollection [

^ aTestCaseCollection select: [ :testCaseReference |
testCaseReference lastTimeToRun <= condition ]
Expand Down
48 changes: 48 additions & 0 deletions src/MuTalk-SpecUI/MTExcludedTestsPresenter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Class {
#name : 'MTExcludedTestsPresenter',
#superclass : 'MTMutationResultsPresenter',
#instVars : [
'testCodePresenter'
],
#category : 'MuTalk-SpecUI',
#package : 'MuTalk-SpecUI'
}

{ #category : 'initialization' }
MTExcludedTestsPresenter >> connectPresenters [

tablePresenter whenSelectionChangedDo: [ :selection |
| selectedItem |
selectedItem := selection selectedItem.
testCodePresenter
beForMethod: selectedItem key method;
text: selectedItem key method sourceCode;
beNotEditable ]
]

{ #category : 'layout' }
MTExcludedTestsPresenter >> defaultLayout [

^ SpPanedLayout newTopToBottom
add: tablePresenter;
add: testCodePresenter;
yourself
]

{ #category : 'initialization' }
MTExcludedTestsPresenter >> initializePresenters [

tablePresenter := self newTable.
tablePresenter
items: model;
activateOnSingleClick;
addColumn: (SpStringTableColumn
title: 'ExcludedTests'
evaluated: [ :each | each key ]);
addColumn:
(SpStringTableColumn
title: 'Reason'
evaluated: [ :each | each value ]).

testCodePresenter := self newCode.
]
7 changes: 7 additions & 0 deletions src/MuTalk-SpecUI/MTGeneralResult.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Extension { #name : 'MTGeneralResult' }

{ #category : '*MuTalk-SpecUI' }
MTGeneralResult >> excludedTestsExtension [

<inspectorPresentationOrder: 3 title: 'Excluded Tests'>
^ MTExcludedTestsPresenter on: excludedTests
]

{ #category : '*MuTalk-SpecUI' }
MTGeneralResult >> killedMutantsExtension [

Expand Down
2 changes: 1 addition & 1 deletion src/MuTalk-Tests/MTPragmaSelectionTestFilterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ MTPragmaSelectionTestFilterTest >> testAllTestsAreExcluded [
{ #category : 'tests' }
MTPragmaSelectionTestFilterTest >> testAllTestsAreExcluded2 [

self runAnalysisForPragmaCondition: #aPragma: andArguments: 'arg'.
self runAnalysisForPragmaCondition: #aPragma: andArguments: { 'arg' }.

self
assert: (analysis generalResult particularResults at: 1) runCount
Expand Down

0 comments on commit d742fbf

Please sign in to comment.