Skip to content

Commit

Permalink
Remove old tests, better error management when cleanup with a popup :…
Browse files Browse the repository at this point in the history
… choice to debug, continue and cancel the cleanup. Menu element refactoring.
  • Loading branch information
labordep committed Jun 29, 2023
1 parent 6e7b4dd commit 5702ea7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 77 deletions.
21 changes: 0 additions & 21 deletions Molecule-IDE-Tests/MolWorldTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@ Class {
#category : #'Molecule-IDE-Tests-Cases'
}

{ #category : #'tests - actions' }
MolWorldTest >> testDoComponentManagerCleanUp [

self assert: MolWorld doComponentManagerCleanUpCatchingErrors isNil
]

{ #category : #'tests - actions' }
MolWorldTest >> testDoComponentManagerCleanUpWithError [

| result comp |
comp := MolSignalErrorComponentWhenPassivate start: #comp1.

result := MolWorld doComponentManagerCleanUpCatchingErrors.
self assert: (result isKindOf: Error).
self assert: MolComponentManager isRunningComponents.

"Simulate an error fix by the developper"
comp isRaisedErrorOnPassivate: false.
self assert: (MolWorld doComponentManagerCleanUpCatchingErrors isNil).
]

{ #category : #tests }
MolWorldTest >> testWorldMenu [
| menuElements moleculeMenuEntry libraryMenu |
Expand Down
45 changes: 19 additions & 26 deletions Molecule-IDE/MolWorld.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ MolWorld class >> doComponentManagerCleanUpCatchingErrors [
"Clean the current ComponentManager, ignore errors when appears and show a report if necessary"
| error |

[ MolComponentManager cleanUp ] on: Error do:[ :e | error := e ].
[ MolComponentManager cleanUp ] on: Error do:[ :e | | result |
error := e.
result := UIManager default
confirm: 'Continue or debug error ?'
label: 'Molecule - Cleanup freezed by an error'
trueChoice: 'Continue' falseChoice: 'Debug' cancelChoice: 'Cancel' default: false.

result = true ifTrue:[ error resume ].
result = false ifTrue:[ error debug ].
].

error ifNil: [
MolUtils showInformation: 'Cleanup done'.
] ifNotNil: [
MolUtils showInformation: 'Errors during cleanup : Try to do an "Image Molecule cleanup".'.
MolUtils showInformation: 'Error during cleanup, try to re-clean to be safe.'.
].

^ error
]

{ #category : #menu }
Expand Down Expand Up @@ -105,21 +112,20 @@ MolWorld class >> menu30ComponentManagerCleanUpOn: aBuilder [
order: 2.0;
help: 'Clean the current ComponentManager and current running Components';
icon: (self iconNamed: #stop);
action: [ | result error |
action: [ | result |
MolComponentManager isRunningComponents ifTrue: [
"Confirmation window to execute the clean when system is running components"
result := UIManager default confirm: 'Some Components are running, clean anyway ?' label: 'Molecule - Cleanup confirmation'.
].

((result notNil and: [ result ]) or: [ result isNil ]) ifFalse: [ ^ self ].
((result notNil and: [ result ]) or: [ result isNil ]) ifTrue:[

error := self doComponentManagerCleanUpCatchingErrors.
error ifNotNil: [
UIManager default abort: 'Errors during cleanup : Try to do an "Image Molecule cleanup" to debug' title: 'Molecule - Cleanup error'
]
self doComponentManagerCleanUpCatchingErrors.

].

];
label: 'Do cleanup'
label: 'Cleanup'
]

{ #category : #menu }
Expand Down Expand Up @@ -182,7 +188,6 @@ MolWorld class >> toolsMenu100DefineAllComponentsOn: aBuilder [
<worldMenu>
(aBuilder item: #MoleculeDefineAllComponents)
parent: #MoleculeDebug;
target: World;
order: 1.9;
action: [ | result |
"Confirmation window"
Expand All @@ -200,7 +205,6 @@ MolWorld class >> toolsMenu10DefineComponentOn: aBuilder [
<worldMenu>
(aBuilder item: #MoleculeDefineComponent)
parent: #MoleculeDebug;
target: World;
order: 1.0;
action: [ self defineAComponent ];
icon: (self iconNamed: #smallUpdate);
Expand All @@ -212,17 +216,16 @@ MolWorld class >> toolsMenu110DeepCleanUp: aBuilder [
<worldMenu>
(aBuilder item: #MoleculeClearComponent)
parent: #MoleculeDebug;
target: World;
order: 11.0;
icon: (self iconNamed: #remove);
icon: (self iconNamed: #stop);
action: [| result |
"Confirmation window"
result := UIManager default confirm: 'Do you want to scan and clean all the Molecule Components of your Pharo image ?
This action may be necessary if your system is broken.'
label: 'Molecule - Confirmation'.
result ifTrue:[ MolComponentManager deepCleanUp].
];
label: 'Do Image Molecule Cleanup';
label: 'Garbage, cleanup and release all components';
help: 'Cleanup all Molecule system instances and components of the image'
]

Expand All @@ -233,7 +236,6 @@ MolWorld class >> toolsMenu20ToggleLogsOn: aBuilder [
ifFalse: [
(aBuilder item: #TurnOffMolLogs)
parent: #MoleculeDebug;
target: World;
icon: (self iconNamed: #smallDebug);
order: 2.0;
action: [ MolUtils toggleLog. MenubarMorph reset. ];
Expand All @@ -242,7 +244,6 @@ MolWorld class >> toolsMenu20ToggleLogsOn: aBuilder [
ifTrue: [
(aBuilder item: #TurnOnMolLogs)
parent: #MoleculeDebug;
target: World;
icon: (self iconNamed: #smallDebug);
order: 2.0;
action: [ MolUtils toggleLog. MenubarMorph reset. ];
Expand All @@ -257,7 +258,6 @@ MolWorld class >> toolsMenu30ToggleDynamicContractUpdate: aBuilder [
ifFalse: [
(aBuilder item: #TurnOffMolLogs)
parent: #MoleculeDebug;
target: World;
icon: (self iconNamed: #smallAuthoringTools);
order: 3.0;
action: [ MolComponentFactory default activateDynamicContractUpdate. MenubarMorph reset. ];
Expand All @@ -266,7 +266,6 @@ MolWorld class >> toolsMenu30ToggleDynamicContractUpdate: aBuilder [
ifTrue: [
(aBuilder item: #TurnOnMolLogs)
parent: #MoleculeDebug;
target: World;
icon: (self iconNamed: #smallAuthoringTools);
order: 3.0;
action: [ MolComponentFactory default deactivateDynamicContractUpdate. MenubarMorph reset. ];
Expand All @@ -281,7 +280,6 @@ MolWorld class >> toolsMenu40InspectAllComponentInstances: aBuilder [
<worldMenu>
(aBuilder item: #InspectAllComponentInstances)
parent: #MoleculeDebug;
target: World;
order: 4.0;
action: [
| components |
Expand All @@ -303,7 +301,6 @@ MolWorld class >> toolsMenu50InspectComponentManager: aBuilder [
<worldMenu>
(aBuilder item: #InspectComponentManager)
parent: #MoleculeDebug;
target: World;
order: 5.0;
action: [ MolComponentManager default inspect ];
icon: (self iconNamed: #glamorousInspect);
Expand All @@ -315,7 +312,6 @@ MolWorld class >> toolsMenu60InspectComponentFactory: aBuilder [
<worldMenu>
(aBuilder item: #InspectComponentFactory)
parent: #MoleculeDebug;
target: World;
order: 6.0;
action: [ MolComponentFactory default inspect ];
icon: (self iconNamed: #glamorousInspect);
Expand All @@ -327,7 +323,6 @@ MolWorld class >> toolsMenu70InspectDirtyComponents: aBuilder [
<worldMenu>
(aBuilder item: #InspectDirtyComponents)
parent: #MoleculeDebug;
target: World;
order: 7.0;
action: [ MolComponentFactory default dirtyComponents inspect ];
icon: (self iconNamed: #glamorousInspect);
Expand All @@ -339,7 +334,6 @@ MolWorld class >> toolsMenu80InspectDirtyComponentTypes: aBuilder [
<worldMenu>
(aBuilder item: #InspectDirtyComponentTypes)
parent: #MoleculeDebug;
target: World;
order: 8.0;
action: [ MolComponentFactory default dirtyComponentTypes inspect ];
icon: (self iconNamed: #glamorousInspect);
Expand All @@ -352,7 +346,6 @@ MolWorld class >> toolsMenu90DefineDirtyComponentsOn: aBuilder [
<worldMenu>
(aBuilder item: #MoleculeDefineDirtyComponents)
parent: #MoleculeDebug;
target: World;
order: 10.0;
action: [ MolComponentFactory defineDirtyComponents ];
icon: (self iconNamed: #smallUpdate);
Expand Down
30 changes: 0 additions & 30 deletions Molecule-Tests/MolSignalErrorComponentWhenPassivate.class.st

This file was deleted.

0 comments on commit 5702ea7

Please sign in to comment.