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

General result shows filtered tests #84

Merged
merged 11 commits into from
Mar 14, 2024
11 changes: 7 additions & 4 deletions src/MuTalk-Model/MTAnalysis.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,10 @@ MTAnalysis >> doNotStopOnErrorOrFail [
{ #category : 'results' }
MTAnalysis >> generalResult [

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

{ #category : 'running' }
Expand All @@ -533,17 +536,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 , '>' ]
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is weird... why is it attaching > at the end of the string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because reasonString is the start of the string, and it contains <.
It's because I wanted the pragma to be between <>, like this <pragma>


{ #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
Loading