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

Applications are now DB transient objects on GS64 #57

Merged
merged 14 commits into from
Mar 21, 2024
1 change: 1 addition & 0 deletions rowan/components/Deployment.ston
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
RwSimpleProjectLoadComponentV2 {
#name : 'Deployment',
#postloadDoitName: 'scripts/deploymentPostload',
#projectNames : [
'Bell',
'Buoy',
Expand Down
38 changes: 38 additions & 0 deletions rowan/components/scripts/deploymentPostload.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"Recompile LaunchpadApplication and CurrentlyRunningLaunchpadApplication with dbTransient option
so that instances are not persistent because they store session-dependent information only"

| removeNonTransientVersionsOf |
removeNonTransientVersionsOf := [:class |
| nonTransientVersions |
nonTransientVersions := class classHistory reject: [:classVersion | classVersion instancesDbTransient].
nonTransientVersions do: [:classVersion | class classHistory removeVersion: classVersion]].

LaunchpadApplication instancesDbTransient
ifFalse: [
Object subclass: 'LaunchpadApplication'
instVarNames: LaunchpadApplication instVarNames
classVars: LaunchpadApplication classVarNames
classInstVars: LaunchpadApplication class instVarNames
poolDictionaries: LaunchpadApplication _poolDictionaries
inDictionary: Launchpad
options: #( dbTransient ).
(OrderedCollection new
add: LaunchpadApplication;
addAll: LaunchpadApplication allSubclasses;
yourself)
do: [:applicationClass | removeNonTransientVersionsOf value: applicationClass].
].
ytsejam78 marked this conversation as resolved.
Show resolved Hide resolved

CurrentlyRunningLaunchpadApplication instancesDbTransient
ifFalse: [
Object subclass: 'CurrentlyRunningLaunchpadApplication'
instVarNames: CurrentlyRunningLaunchpadApplication instVarNames
classVars: CurrentlyRunningLaunchpadApplication classVarNames
classInstVars: CurrentlyRunningLaunchpadApplication class instVarNames
poolDictionaries: CurrentlyRunningLaunchpadApplication _poolDictionaries
inDictionary: Launchpad
options: #( dbTransient ).
removeNonTransientVersionsOf value: CurrentlyRunningLaunchpadApplication.
].

CurrentlyRunningLaunchpadApplication initializeUniqueInstance.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
A CurrentApplicationConfigurationTest is a test class for testing the behavior of CurrentApplicationConfiguration
"
Class {
#name : #CurrentApplicationConfigurationTest,
#superclass : #TestCase,
#category : #'Launchpad-Applications-Tests'
#name : 'CurrentApplicationConfigurationTest',
#superclass : 'TestCase',
#category : 'Launchpad-Applications-Tests',
#package : 'Launchpad-Applications-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
CurrentApplicationConfigurationTest >> testAccessingConfigurationOfRunningApplication [

| application |
Expand All @@ -22,7 +23,7 @@ CurrentApplicationConfigurationTest >> testAccessingConfigurationOfRunningApplic
during: [ self assert: CurrentApplicationConfiguration value equals: application configuration ]
]

{ #category : #tests }
{ #category : 'tests' }
CurrentApplicationConfigurationTest >> testNoApplicationRunning [

self should: [ CurrentApplicationConfiguration value ]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Class {
#name : 'CurrentlyRunningLaunchpadApplicationTest',
#superclass : 'TestCase',
#instVars : [
'currentlyRunningLaunchpadApp'
],
#category : 'Launchpad-Applications-Tests',
#package : 'Launchpad-Applications-Tests'
}

{ #category : 'running' }
CurrentlyRunningLaunchpadApplicationTest >> setUp [

super setUp.
CurrentlyRunningLaunchpadApplication initialize.
ytsejam78 marked this conversation as resolved.
Show resolved Hide resolved
currentlyRunningLaunchpadApp := CurrentlyRunningLaunchpadApplication new.
currentlyRunningLaunchpadApp resetCurrentlyRunning
]

{ #category : 'tests' }
CurrentlyRunningLaunchpadApplicationTest >> testCurrentlyRunning [

self
should: [ currentlyRunningLaunchpadApp currentlyRunning ]
raise: AssertionFailed
withMessageText: 'There''s no current application running.'
]

{ #category : 'tests' }
CurrentlyRunningLaunchpadApplicationTest >> testResetCurrentlyRunning [

currentlyRunningLaunchpadApp setAsCurrentlyRunning: #MockApp.
currentlyRunningLaunchpadApp resetCurrentlyRunning.
self
should: [ currentlyRunningLaunchpadApp currentlyRunning ]
raise: AssertionFailed
withMessageText: 'There''s no current application running.'
]

{ #category : 'tests' }
CurrentlyRunningLaunchpadApplicationTest >> testSetAsCurrentlyRunning [

currentlyRunningLaunchpadApp setAsCurrentlyRunning: #MockApp.
self assert: currentlyRunningLaunchpadApp currentlyRunning equals: #MockApp
]

{ #category : 'tests' }
CurrentlyRunningLaunchpadApplicationTest >> testSetAsCurrentlyRunningDuring [

currentlyRunningLaunchpadApp setAsCurrentlyRunning: #MockApp.
currentlyRunningLaunchpadApp
setAsCurrentlyRunning: #MockAppOther
during: [
self
assert: currentlyRunningLaunchpadApp currentlyRunning
equals: #MockAppOther ].
self
assert: currentlyRunningLaunchpadApp currentlyRunning
equals: #MockApp
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@
A DebuggingApplicationModeTest is a test class for testing the behavior of DebuggingApplicationMode
"
Class {
#name : #DebuggingApplicationModeTest,
#superclass : #LaunchpadTest,
#category : #'Launchpad-Applications-Tests'
#name : 'DebuggingApplicationModeTest',
#superclass : 'LaunchpadTest',
#category : 'Launchpad-Applications-Tests',
#package : 'Launchpad-Applications-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
DebuggingApplicationModeTest >> testExitFailure [

self
runMemoryLoggerDuring: [ DebuggingApplicationMode new exitFailure ]
assertingLogRecordsMatch: #( '[ERROR] Exit application' )
]

{ #category : #tests }
{ #category : 'tests' }
DebuggingApplicationModeTest >> testExitSuccess [

self
runMemoryLoggerDuring: [ DebuggingApplicationMode new exitSuccess ]
assertingLogRecordsMatch: #( '[INFO] Exit application' )
]

{ #category : #test }
{ #category : 'test' }
DebuggingApplicationModeTest >> testIsDebugMode [

self assert: DebuggingApplicationMode new isDebugMode
]

{ #category : #tests }
{ #category : 'tests' }
DebuggingApplicationModeTest >> testValueOnErrorDo [

DebuggingApplicationMode new value: [ ] onErrorDo: [ self fail ].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
A LaunchpadApplicationTest is a test class for testing the behavior of LaunchpadApplication
"
Class {
#name : #LaunchpadApplicationTest,
#superclass : #TestCase,
#category : #'Launchpad-Applications-Tests'
#name : 'LaunchpadApplicationTest',
#superclass : 'TestCase',
#category : 'Launchpad-Applications-Tests',
#package : 'Launchpad-Applications-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
LaunchpadApplicationTest >> testIsDebugModeEnabled [

| application |
Expand All @@ -19,7 +20,7 @@ LaunchpadApplicationTest >> testIsDebugModeEnabled [
self assert: application isDebugModeEnabled
]

{ #category : #tests }
{ #category : 'tests' }
LaunchpadApplicationTest >> testIsDebugModeNotEnabled [

| application |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
A NullStackTraceDumperTest is a test class for testing the behavior of NullStackTraceDumper
"
Class {
#name : #NullStackTraceDumperTest,
#superclass : #LaunchpadTest,
#category : #'Launchpad-Applications-Tests'
#name : 'NullStackTraceDumperTest',
#superclass : 'LaunchpadTest',
#category : 'Launchpad-Applications-Tests',
#package : 'Launchpad-Applications-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
NullStackTraceDumperTest >> testDumpStackTraceFor [

self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@
A ReleasedApplicationModeTest is a test class for testing the behavior of ReleasedApplicationMode
"
Class {
#name : #ReleasedApplicationModeTest,
#superclass : #TestCase,
#category : #'Launchpad-Applications-Tests'
#name : 'ReleasedApplicationModeTest',
#superclass : 'TestCase',
#category : 'Launchpad-Applications-Tests',
#package : 'Launchpad-Applications-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
ReleasedApplicationModeTest >> testExitFailure [

self should: [ ReleasedApplicationMode new exitFailure ]
raise: Exit
withExceptionDo: [ :exit | self deny: exit isSuccess ]
]

{ #category : #tests }
{ #category : 'tests' }
ReleasedApplicationModeTest >> testExitSuccess [

self should: [ ReleasedApplicationMode new exitSuccess ]
raise: Exit
withExceptionDo: [ :exit | self assert: exit isSuccess ]
]

{ #category : #tests }
{ #category : 'tests' }
ReleasedApplicationModeTest >> testIsDebugMode [

self deny: ReleasedApplicationMode new isDebugMode
]

{ #category : #tests }
{ #category : 'tests' }
ReleasedApplicationModeTest >> testValueOnErrorDo [

| errorWasHandled |
Expand Down
2 changes: 1 addition & 1 deletion source/Launchpad-Applications-Tests/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Launchpad-Applications-Tests' }
Package { #name : 'Launchpad-Applications-Tests' }
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
Class {
#name : #CurrentApplicationConfiguration,
#superclass : #DynamicVariable,
#category : #'Launchpad-Applications'
#name : 'CurrentApplicationConfiguration',
#superclass : 'DynamicVariable',
#category : 'Launchpad-Applications',
#package : 'Launchpad-Applications'
}

{ #category : #accessing }
{ #category : 'accessing' }
CurrentApplicationConfiguration class >> default [

^ LaunchpadApplication currentlyRunning configuration
]

{ #category : #accessing }
{ #category : 'accessing' }
CurrentApplicationConfiguration >> default [

^ self class default
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Class {
#name : 'CurrentlyRunningLaunchpadApplication',
#superclass : 'Object',
#instVars : [
'binding'
],
#classVars : [
'uniqueInstance'
],
#category : 'Launchpad-Applications',
#package : 'Launchpad-Applications'
}

{ #category : 'initialization' }
CurrentlyRunningLaunchpadApplication class >> initialize [

<ignoreForCoverage>
self initializeUniqueInstance
]

{ #category : 'initialization' }
CurrentlyRunningLaunchpadApplication class >> initializeUniqueInstance [

uniqueInstance := super new
]

{ #category : 'instance creation' }
CurrentlyRunningLaunchpadApplication class >> new [

^uniqueInstance
]

{ #category : 'accessing' }
CurrentlyRunningLaunchpadApplication >> currentlyRunning [

binding ifNil: [ self resetCurrentlyRunning ].
^ binding content
]

{ #category : 'accessing' }
CurrentlyRunningLaunchpadApplication >> resetCurrentlyRunning [

binding := Binding undefinedExplainedBy:
'There''s no current application running.'
]

{ #category : 'accessing' }
CurrentlyRunningLaunchpadApplication >> setAsCurrentlyRunning: anApplication [

binding := Binding to: anApplication
]

{ #category : 'accessing' }
CurrentlyRunningLaunchpadApplication >> setAsCurrentlyRunning: anApplication during: aBlock [
ytsejam78 marked this conversation as resolved.
Show resolved Hide resolved

| previousBinding |
previousBinding := binding.
binding := Binding to: anApplication.
aBlock ensure: [ binding := previousBinding ]
]
15 changes: 8 additions & 7 deletions source/Launchpad-Applications/DebuggingApplicationMode.class.st
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
Class {
#name : #DebuggingApplicationMode,
#superclass : #LaunchpadApplicationRunningMode,
#category : #'Launchpad-Applications'
#name : 'DebuggingApplicationMode',
#superclass : 'LaunchpadApplicationRunningMode',
#category : 'Launchpad-Applications',
#package : 'Launchpad-Applications'
}

{ #category : #utilities }
{ #category : 'utilities' }
DebuggingApplicationMode >> exitFailure [

LogRecord emitError: 'Exit application'
]

{ #category : #utilities }
{ #category : 'utilities' }
DebuggingApplicationMode >> exitSuccess [

LogRecord emitInfo: 'Exit application'
]

{ #category : #testing }
{ #category : 'testing' }
DebuggingApplicationMode >> isDebugMode [

^ true
]

{ #category : #utilities }
{ #category : 'utilities' }
DebuggingApplicationMode >> value: aBlock onErrorDo: errorHandler [

^ aBlock value
Expand Down
Loading
Loading