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

Fix unimplemented methods and small refactoring for test filters #101

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This project was originally developed at the University of Buenos Aires (Argenti
```smalltalk
Metacello new
baseline: 'MuTalk';
repository: 'github://pharo-contributions/mutalk:v2.1.0/src';
repository: 'github://pharo-contributions/mutalk:v2.2.1/src';
load.
```
* Full version:
Expand Down
30 changes: 26 additions & 4 deletions src/MuTalk-Model/MTBlockTestFilter.class.st
Original file line number Diff line number Diff line change
@@ -1,25 +1,47 @@
Class {
#name : 'MTBlockTestFilter',
#superclass : 'MTTestFilter',
#instVars : [
'conditionBlock'
],
#category : 'MuTalk-Model-Test filters',
#package : 'MuTalk-Model',
#tag : 'Test filters'
}

{ #category : 'accessing' }
MTBlockTestFilter >> condition: aConditionBlock [

self conditionBlock: aConditionBlock
]

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

^ conditionBlock
]

{ #category : 'accessing' }
MTBlockTestFilter >> conditionBlock: anObject [

conditionBlock := anObject
]

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

^ aTestCaseCollection reject: condition
^ aTestCaseCollection reject: conditionBlock
]

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

^ 'Took longer than ', condition printString, ' to run'
^ 'Did not respect the block condition: '
, conditionBlock printString
]

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

^ aTestCaseCollection select: condition
^ aTestCaseCollection select: conditionBlock
]
2 changes: 1 addition & 1 deletion src/MuTalk-Model/MTPragmaRejectionTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ MTPragmaRejectionTestFilter >> filteredTestsFrom: aTestCaseCollection [
{ #category : 'accessing' }
MTPragmaRejectionTestFilter >> reasonString [

^ 'Contains the pragma <' , condition
^ 'Contains the pragma'
]
2 changes: 1 addition & 1 deletion src/MuTalk-Model/MTPragmaSelectionTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ MTPragmaSelectionTestFilter >> filteredTestsFrom: aTestCaseCollection [
{ #category : 'accessing' }
MTPragmaSelectionTestFilter >> reasonString [

^ 'Does not contain the pragma <' , condition
^ 'Does not contain the pragma'
]
25 changes: 22 additions & 3 deletions src/MuTalk-Model/MTPragmaTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Class {
#name : 'MTPragmaTestFilter',
#superclass : 'MTTestFilter',
#instVars : [
'pragmaArguments'
'pragmaArguments',
'pragmaSelector'
],
#category : 'MuTalk-Model-Test filters',
#package : 'MuTalk-Model',
Expand Down Expand Up @@ -30,11 +31,17 @@ MTPragmaTestFilter class >> isAbstract [
^ self == MTPragmaTestFilter
]

{ #category : 'accessing' }
MTPragmaTestFilter >> condition: aPragmaSelector [

self pragmaSelector: aPragmaSelector
]

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

| reasonString |
reasonString := self reasonString.
reasonString := self reasonString , ' <' , pragmaSelector.

^ pragmaArguments isEmpty
ifTrue: [ reasonString , '>' ]
Expand All @@ -52,7 +59,7 @@ MTPragmaTestFilter >> isPragmaValidFrom: aTestCaseReference [
| pragmas |
pragmas := aTestCaseReference method pragmas.
^ pragmas anySatisfy: [ :pragma |
pragma selector = condition & (pragma arguments = pragmaArguments) ]
pragma selector = pragmaSelector & (pragma arguments = pragmaArguments) ]
]

{ #category : 'accessing' }
Expand All @@ -67,6 +74,18 @@ MTPragmaTestFilter >> pragmaArguments: anObject [
pragmaArguments := anObject
]

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

^ pragmaSelector
]

{ #category : 'accessing' }
MTPragmaTestFilter >> pragmaSelector: anObject [

pragmaSelector := anObject
]

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

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

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

^ aTestCaseCollection select: [ :testCase |
self failuresOrErrorsIn: testCase lastResult ]
]

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

^ 'Was initially failing, even without any mutant applied'
]

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

^ aTestCaseCollection reject: [ :testCase |
self failuresOrErrorsIn: testCase lastResult ]
Expand Down
13 changes: 0 additions & 13 deletions src/MuTalk-Model/MTTestFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Class {
#name : 'MTTestFilter',
#superclass : 'Object',
#instVars : [
'condition',
'excludedTests',
'filteredTests'
],
Expand All @@ -19,18 +18,6 @@ MTTestFilter class >> for: aCondition [
yourself
]

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

^ condition
]

{ #category : 'accessing' }
MTTestFilter >> condition: aCondition [

condition := aCondition
]

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

Expand Down
27 changes: 24 additions & 3 deletions src/MuTalk-Model/MTTimeTestFilter.class.st
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@
Class {
#name : 'MTTimeTestFilter',
#superclass : 'MTTestFilter',
#instVars : [
'maxDuration'
],
#category : 'MuTalk-Model-Test filters',
#package : 'MuTalk-Model',
#tag : 'Test filters'
}

{ #category : 'accessing' }
MTTimeTestFilter >> condition: aMaxDuration [

self maxDuration: aMaxDuration
]

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

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

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

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

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

^ aTestCaseCollection select: [ :testCaseReference |
testCaseReference lastTimeToRun <= condition ]
testCaseReference lastTimeToRun <= maxDuration ]
]

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

^ maxDuration
]

{ #category : 'accessing' }
MTTimeTestFilter >> maxDuration: anObject [

maxDuration := anObject
]
Loading