Skip to content

Commit

Permalink
Merge pull request #39 from jecisc/13-Add-a-way-to-select-cleaners-to…
Browse files Browse the repository at this point in the history
…-call

13-Add-a-way-to-select-cleaners-to-call
  • Loading branch information
jecisc committed Apr 15, 2020
2 parents 731a013 + 0def672 commit f2d3f67
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 27 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ packages := ((IceRepository registry select: [ :e | e name includesSubstring: 'M
Chanel perfume: packages
```

It is also possible to run only some cleaners selecting them manually.

```Smalltalk
Chanel perfume: packages using: { ChanelTestEqualityCleaner . ChanelProtocolsCleaner }.
```

You can find the full list of cleaners running `ChanelAbstractCleaner cleaners asArray`.
It is advised to keep the cleaner in the given order of this snippet since some of them needs to run before the others.

> **WARNING**: Some cleaning are making sense in most cases but might cause troubles in some edge cases. Please, read the documentation to see the list of possible problems it might introduce.
## Documentation
Expand Down
9 changes: 9 additions & 0 deletions resources/doc/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ packages := ((IceRepository registry select: [ :e | e name includesSubstring: 'M
Chanel perfume: packages
```

It is also possible to run only some cleaners selecting them manually.

```Smalltalk
Chanel perfume: packages using: { ChanelTestEqualityCleaner . ChanelProtocolsCleaner }.
```

You can find the full list of cleaners running `ChanelAbstractCleaner cleaners asArray`.
It is advised to keep the cleaner in the given order of this snippet since some of them needs to run before the others.

## Tests equality

Chanel iterates on all the tests of the packages and clean equality assertions.
Expand Down
26 changes: 13 additions & 13 deletions src/Chanel-Tests/ChanelProtocolsCleanerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ChanelProtocolsCleanerTest >> setUp [
class := self createClassNamed: #ChanelProtocolsFake
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testDoesNotUpdateCloseProtocolIfAlreadyRight [
class compile: 'method' classified: 'instance creation'.

Expand All @@ -22,7 +22,7 @@ ChanelProtocolsCleanerTest >> testDoesNotUpdateCloseProtocolIfAlreadyRight [
self assert: (class >> #method) protocol equals: 'instance creation'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testMethodInSpecificProtocol [
class compile: 'initialize' classified: 'random'.

Expand All @@ -31,7 +31,7 @@ ChanelProtocolsCleanerTest >> testMethodInSpecificProtocol [
self assert: (class >> #initialize) protocol equals: 'initialization'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testMethodInSpecificProtocolNotUpdateIfExtension [
class compile: 'initialize' classified: self extensionProtocol.

Expand All @@ -40,7 +40,7 @@ ChanelProtocolsCleanerTest >> testMethodInSpecificProtocolNotUpdateIfExtension [
self assert: (class >> #initialize) protocol equals: self extensionProtocol
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testMethodInSpecificProtocolNotUpdateIfNotInTheList [
class compile: 'initialize2' classified: 'random'.

Expand All @@ -49,7 +49,7 @@ ChanelProtocolsCleanerTest >> testMethodInSpecificProtocolNotUpdateIfNotInTheLis
self assert: (class >> #initialize2) protocol equals: 'random'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocol [
class := self createTestCaseNamed: #ChanelProtocolsFake.
class compile: 'setUp' classified: 'random'.
Expand All @@ -59,7 +59,7 @@ ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocol [
self assert: (class >> #setUp) protocol equals: 'running'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfExtension [
class := self createTestCaseNamed: #ChanelProtocolsFake.
class compile: 'setUp' classified: self extensionProtocol.
Expand All @@ -69,7 +69,7 @@ ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfExtens
self assert: (class >> #setUp) protocol equals: self extensionProtocol
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfNotInTestCase [
class compile: 'setUp' classified: 'random'.

Expand All @@ -78,7 +78,7 @@ ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfNotInT
self assert: (class >> #setUp) protocol equals: 'random'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfNotInTheList [
class := self createTestCaseNamed: #ChanelProtocolsFake.
class compile: 'toto' classified: 'random'.
Expand All @@ -88,7 +88,7 @@ ChanelProtocolsCleanerTest >> testTestMethodInSpecificProtocolNotUpdatedIfNotInT
self assert: (class >> #toto) protocol equals: 'random'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testTestMethodsAreInRightProtocol [
class := self createTestCaseNamed: #ChanelProtocolsFake.
class compile: 'testMethod' classified: 'not a test'.
Expand All @@ -98,7 +98,7 @@ ChanelProtocolsCleanerTest >> testTestMethodsAreInRightProtocol [
self assert: (class >> #testMethod) protocol equals: 'tests'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfExtension [
class := self createTestCaseNamed: #ChanelProtocolsFake.
class compile: 'testMethod' classified: self extensionProtocol.
Expand All @@ -108,7 +108,7 @@ ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfExtension [
self assert: (class >> #testMethod) protocol equals: self extensionProtocol
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfNotInTestCase [
class compile: 'testMethod' classified: 'not a test'.

Expand All @@ -117,7 +117,7 @@ ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfNotInTestCase
self assert: (class >> #testMethod) protocol equals: 'not a test'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfStartingByTest [
class := self createTestCaseNamed: #ChanelProtocolsFake.
class compile: 'testMethod' classified: 'test - protocols'.
Expand All @@ -127,7 +127,7 @@ ChanelProtocolsCleanerTest >> testTestMethodsProtocolAreNotUpdateIfStartingByTes
self assert: (class >> #testMethod) protocol equals: 'test - protocols'
]

{ #category : #running }
{ #category : #tests }
ChanelProtocolsCleanerTest >> testUpdateCloseProtocol [
class compile: 'method' classified: 'instance-creation'.

Expand Down
38 changes: 26 additions & 12 deletions src/Chanel/Chanel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ Examples
flatCollect: [ :e | e workingCopy packageNames collect: [:s | s asPackageIfAbsent: [ nil ] ]]) reject: #isNil.
Chanel perfume: packages
""You can also choose the list of cleaners to run:""
Chanel perfume: packages using: { ChanelTestEqualityCleaner . ChanelProtocolsCleaner }.
""You can find the full list of cleaners running:""
ChanelAbstractCleaner cleaners asArray
Internal Representation and Key Implementation Points.
--------------------
Expand All @@ -33,23 +41,29 @@ Class {

{ #category : #cleaning }
Chanel class >> perfume: aCollectionOfPackages [
^ self perfume: aCollectionOfPackages using: ChanelAbstractCleaner cleaners
]

{ #category : #cleaning }
Chanel class >> perfume: aCollectionOfPackages using: aCollectionOfCleaners [
^ self new
packages: aCollectionOfPackages;
clean
cleanUsing: aCollectionOfCleaners
]

{ #category : #cleaning }
Chanel >> clean [
| cleaners |
cleaners := ChanelAbstractCleaner cleanersFor: self.

UIManager default displayProgress: 'Running Chanel' from: 1 to: cleaners size during: [ :bar |
cleaners
doWithIndex: [ :cleaner :index |
bar
value: index;
title: '(' , index asString , '/' , cleaners size asString , ') Running ' , cleaner printString.
cleaner clean ] ]
Chanel >> cleanUsing: cleaners [
UIManager default
displayProgress: 'Running Chanel'
from: 1
to: cleaners size
during: [ :bar |
cleaners
doWithIndex: [ :cleaner :index |
bar
value: index;
title: '(' , index asString , '/' , cleaners size asString , ') Running ' , cleaner printString.
(cleaner configuration: self) clean ] ]
]

{ #category : #accessing }
Expand Down
6 changes: 4 additions & 2 deletions src/Chanel/ChanelAbstractCleaner.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Each of my subclasses represents a kind of cleaning to apply on the project to c
I am configured with an instance of Chanel to get the elements to clean.
You can find the full list of cleaners running `ChanelAbstractCleaner cleaners`.
Public API and Key Messages
--------------------
Expand All @@ -30,8 +32,8 @@ Class {
}

{ #category : #'instance creation' }
ChanelAbstractCleaner class >> cleanersFor: aConfiguration [
^ ((self allSubclasses reject: #isAbstract) sort: #priority ascending) collect: [ :class | class configuration: aConfiguration ]
ChanelAbstractCleaner class >> cleaners [
^ (self allSubclasses reject: #isAbstract) sort: #priority ascending
]

{ #category : #accessing }
Expand Down

0 comments on commit f2d3f67

Please sign in to comment.