-
Notifications
You must be signed in to change notification settings - Fork 14
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
Composite test filter #106
Merged
guillep
merged 8 commits into
pharo-contributions:master
from
DurieuxPol:feat/compositeTestFilter
Apr 9, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bfd1a9d
added composite test filter
7fa9147
fix filtered tests appearing multiple times in general result
cb4d040
test for composite test filter
82cce46
rename auxiliar test class
70cc404
refactor tests
06697d0
removed unused method & fix class side method
656a29a
remove unused class
bec0672
added class comment
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
" | ||
This test filter is a composition of multiple test filters. | ||
It works as if the test collection passes through each test filter one by one. So a test is blocked by the composite test filter if any of its filters blocks the said test. In the same way, a test passes through the composite test filter if it passes through every of its filters. | ||
" | ||
Class { | ||
#name : 'MTCompositeTestFilter', | ||
#superclass : 'MTTestFilter', | ||
#instVars : [ | ||
'filters' | ||
], | ||
#category : 'MuTalk-Model-Test filters', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Test filters' | ||
} | ||
|
||
{ #category : 'instance creation' } | ||
MTCompositeTestFilter class >> for: aTestFilterCollection [ | ||
|
||
^ self new | ||
filters: aTestFilterCollection; | ||
yourself | ||
] | ||
|
||
{ #category : 'enumerating' } | ||
MTCompositeTestFilter >> excludedTestsFrom: aTestCaseCollection [ | ||
|
||
| excludedTestsCollection | | ||
excludedTestsCollection := Dictionary new. | ||
filters do: [ :filter | | ||
excludedTestsCollection addAll: | ||
((filter excludedTestsFrom: aTestCaseCollection) collect: [ :test | | ||
test -> filter filteredTestReason ]) ]. | ||
^ excludedTestsCollection asOrderedCollection | ||
] | ||
|
||
{ #category : 'enumerating' } | ||
MTCompositeTestFilter >> filterTests: aTestCaseCollection [ | ||
|
||
excludedTests := self excludedTestsFrom: aTestCaseCollection. | ||
^ filteredTests := self filteredTestsFrom: aTestCaseCollection | ||
] | ||
|
||
{ #category : 'enumerating' } | ||
MTCompositeTestFilter >> filteredTestsFrom: aTestCaseCollection [ | ||
|
||
| testCaseCollection | | ||
^ filters inject: aTestCaseCollection into: [ :accumulator :filter | | ||
testCaseCollection := filter filteredTestsFrom: accumulator ] | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTCompositeTestFilter >> filters [ | ||
|
||
^ filters | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTCompositeTestFilter >> filters: anObject [ | ||
|
||
filters := anObject | ||
] |
12 changes: 0 additions & 12 deletions
12
src/MuTalk-TestResources/MTAuxiliarClassForTestFilter.class.st
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/MuTalk-TestResources/MTAuxiliarTestClassForCompositeTestFilter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Class { | ||
#name : 'MTAuxiliarTestClassForCompositeTestFilter', | ||
#superclass : 'TestCase', | ||
#category : 'MuTalk-TestResources', | ||
#package : 'MuTalk-TestResources' | ||
} | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForCompositeTestFilter >> testX1 [ | ||
|
||
<pragma> | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForCompositeTestFilter >> testX2 [ | ||
|
||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForCompositeTestFilter >> testX3 [ | ||
|
||
<pragma> | ||
100 milliSeconds wait | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForCompositeTestFilter >> testY1 [ | ||
|
||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForCompositeTestFilter >> testY2 [ | ||
|
||
<pragma> | ||
|
||
] |
6 changes: 3 additions & 3 deletions
6
...xiliarClassForTimeTestFilterTest.class.st → ...xiliarTestClassForTimeTestFilter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
Class { | ||
#name : 'MTAuxiliarClassForTimeTestFilterTest', | ||
#name : 'MTAuxiliarTestClassForTimeTestFilter', | ||
#superclass : 'TestCase', | ||
#category : 'MuTalk-TestResources', | ||
#package : 'MuTalk-TestResources' | ||
} | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarClassForTimeTestFilterTest >> test10Milliseconds [ | ||
MTAuxiliarTestClassForTimeTestFilter >> test10Milliseconds [ | ||
|
||
10 milliSeconds wait | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarClassForTimeTestFilterTest >> test1Second [ | ||
MTAuxiliarTestClassForTimeTestFilter >> test1Second [ | ||
|
||
1 second wait | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Class { | ||
#name : 'MTCompositeTestFilterTest', | ||
#superclass : 'MTTestFilterTest', | ||
#category : 'MuTalk-Tests', | ||
#package : 'MuTalk-Tests' | ||
} | ||
|
||
{ #category : 'running' } | ||
MTCompositeTestFilterTest >> runAnalysisWithFilters: aTestFilterCollection [ | ||
|
||
self | ||
runAnalysisWithFilter: | ||
(MTCompositeTestFilter for: aTestFilterCollection) | ||
on: { } | ||
withTests: { MTAuxiliarTestClassForCompositeTestFilter } | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTCompositeTestFilterTest >> testWithCombinedTestFilters [ | ||
|
||
self runAnalysisWithFilters: { | ||
(MTBlockTestFilter for: [ :testCase | | ||
testCase selector beginsWith: 'testX' ]). | ||
(MTPragmaSelectionTestFilter for: #pragma). | ||
(MTTimeTestFilter for: 10 milliSeconds) }. | ||
|
||
self assert: analysis testCases size equals: 1. | ||
self assert: (analysis testCases at: 1) selector equals: #testX1 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a class comment? Does this filter filters if ALL filters say so, or if ANY filter does it? I assume it should be ANY (otherwise it will be unusable, right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It filters if any filter does. It's as if the tests collection passes through each filter one by one.
I'll add a class comment