Skip to content

Commit

Permalink
sync trivial changes (mostly formatting) with Pharo 13
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-krivanek committed May 1, 2024
1 parent a2c5207 commit 44b7849
Show file tree
Hide file tree
Showing 73 changed files with 1,124 additions and 1,017 deletions.
26 changes: 13 additions & 13 deletions TaskIt-Tests/TKTBasicTaskTest.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Class {
#name : #TKTBasicTaskTest,
#superclass : #TKTTestCase,
#category : #'TaskIt-Tests-Kernel'
#name : 'TKTBasicTaskTest',
#superclass : 'TKTTestCase',
#category : 'TaskIt-Tests-Kernel',
#package : 'TaskIt-Tests',
#tag : 'Kernel'
}

{ #category : #tests }
{ #category : 'tests' }
TKTBasicTaskTest >> testFutureExecutes [

| done sema |
Expand All @@ -13,20 +15,18 @@ TKTBasicTaskTest >> testFutureExecutes [
[ done := true.
sema signal ] future.
sema wait.

self assert: done


]

{ #category : #tests }
{ #category : 'tests' }
TKTBasicTaskTest >> testFutureExecutesByDefaultInGlobalWorkerPool [
| future |
future := [ TKTConfiguration runner ] future.
self assert: (future synchronizeTimeout: 1 second) equals: TKTConfiguration runner
]

{ #category : #tests }
{ #category : 'tests' }
TKTBasicTaskTest >> testFutureExecutesConcurrently [
| results future1 future2 |
results := OrderedCollection new.
Expand All @@ -41,7 +41,7 @@ TKTBasicTaskTest >> testFutureExecutesConcurrently [
self assert: results asArray equals: #(2 1)
]

{ #category : #tests }
{ #category : 'tests' }
TKTBasicTaskTest >> testFutureReturnsAssociatedFutureObject [
| done sema |
done := false.
Expand All @@ -52,17 +52,17 @@ TKTBasicTaskTest >> testFutureReturnsAssociatedFutureObject [
self assert: done
]

{ #category : #tests }
{ #category : 'tests' }
TKTBasicTaskTest >> testFutureWithFutureInsideSchedulesOk [

| future |

future := [ [TKTConfiguration runner] schedule ] future.

self shouldnt: (future synchronizeTimeout: 1 second) raise: UnhandledError.
self shouldnt: (future synchronizeTimeout: 1 second) raise: UnhandledError
]

{ #category : #tests }
{ #category : 'tests' }
TKTBasicTaskTest >> testScheduleExecutes [
| done sema |
done := false.
Expand Down
46 changes: 23 additions & 23 deletions TaskIt-Tests/TKTCommonQueueWorkerPoolTest.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Class {
#name : #TKTCommonQueueWorkerPoolTest,
#superclass : #TKTTestCase,
#category : #'TaskIt-Tests-Worker'
#name : 'TKTCommonQueueWorkerPoolTest',
#superclass : 'TKTTestCase',
#category : 'TaskIt-Tests-Worker',
#package : 'TaskIt-Tests',
#tag : 'Worker'
}

{ #category : #tests }
{ #category : 'tests' }
TKTCommonQueueWorkerPoolTest >> testWorkerPoolCretesWorkersWhenExecutingATask [
| pool |
pool := TKTCommonQueueWorkerPool new.
Expand All @@ -15,7 +17,7 @@ TKTCommonQueueWorkerPoolTest >> testWorkerPoolCretesWorkersWhenExecutingATask [
self assert: pool workers notEmpty
]

{ #category : #tests }
{ #category : 'tests' }
TKTCommonQueueWorkerPoolTest >> testWorkerPoolDoesNotExceedPoolSize [
| pool |
pool := TKTCommonQueueWorkerPool new.
Expand All @@ -26,7 +28,7 @@ TKTCommonQueueWorkerPoolTest >> testWorkerPoolDoesNotExceedPoolSize [
self assert: pool size <= 4
]

{ #category : #tests }
{ #category : 'tests' }
TKTCommonQueueWorkerPoolTest >> testWorkerPoolDoesNotExceedPoolSizeWhenSchedulingTasksInParallel [
| pool totalTasks futures |
pool := TKTCommonQueueWorkerPool new.
Expand All @@ -40,64 +42,62 @@ TKTCommonQueueWorkerPoolTest >> testWorkerPoolDoesNotExceedPoolSizeWhenSchedulin
self assert: pool size <= 10
]

{ #category : #tests }
{ #category : 'tests' }
TKTCommonQueueWorkerPoolTest >> testWorkerPoolStopStopsWorkers [

| pool |
pool := TKTCommonQueueWorkerPool new.
pool poolMaxSize: 4.
pool start.

((1 to: 10) collect: [:i | pool future: [ 1 + 1 ] ])
do: [ :future | future waitForCompletion: 500 milliSeconds. ].

pool stop.
pool workers do: [ :worker | self deny: worker isRunning ].

pool workers do: [ :worker | self deny: worker isRunning ]
]

{ #category : #tests }
{ #category : 'tests' }
TKTCommonQueueWorkerPoolTest >> testWorkerPoolWorkersAreStoppedAfterPoolsCollection [

| pool workerProcess |
pool := TKTCommonQueueWorkerPool new.
pool name: 'test pool' , UUID new asString.
pool poolMaxSize: 4.
pool start.
(pool future: (MessageSend receiver: self selector: #yourself))
(pool future: (MessageSend receiver: self selector: #yourself))
waitForCompletion: 1 second.
self assert: pool workers notEmpty.
workerProcess := WeakArray with: pool workers anyOne process.
pool := nil.
self assertWithGarbageCollect: [ workerProcess first isNil ].

self assertWithGarbageCollect: [ workerProcess first isNil ]
]

{ #category : #tests }
{ #category : 'tests' }
TKTCommonQueueWorkerPoolTest >> testWorkerPoolWorkersProcessesAreStoppedAfterPoolsCollection [

| pool workerProcess |
pool := TKTCommonQueueWorkerPool new.
pool name: 'Test pool' , UUID new asString.
pool poolMaxSize: 4.
pool start.
(pool future: (MessageSend receiver: self selector: #yourself))
(pool future: (MessageSend receiver: self selector: #yourself))
waitForCompletion: 1 second.
workerProcess := WeakArray with: pool workers anyOne process process.
pool := nil.
self assertWithGarbageCollect: [ workerProcess first isNil ].

self assertWithGarbageCollect: [ workerProcess first isNil ]
]

{ #category : #tests }
{ #category : 'tests' }
TKTCommonQueueWorkerPoolTest >> testWorkerPoolWorkersProcessesAreTerminatedAfterPoolsCollection [

| pool workerProcess |
pool := TKTCommonQueueWorkerPool createDefault.
(pool future: (MessageSend receiver: self selector: #yourself))
(pool future: (MessageSend receiver: self selector: #yourself))
waitForCompletion: 1 second.
workerProcess := pool workers anyOne process process.
pool := nil.
self assertWithGarbageCollect: [ workerProcess isTerminated ].

self assertWithGarbageCollect: [ workerProcess isTerminated ]
]
12 changes: 7 additions & 5 deletions TaskIt-Tests/TKTConfigurationTest.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Class {
#name : #TKTConfigurationTest,
#superclass : #TKTTestCase,
#category : #'TaskIt-Tests-Kernel'
#name : 'TKTConfigurationTest',
#superclass : 'TKTTestCase',
#category : 'TaskIt-Tests-Kernel',
#package : 'TaskIt-Tests',
#tag : 'Kernel'
}

{ #category : #tests }
{ #category : 'tests' }
TKTConfigurationTest >> testAllProfilesCanBeSet [
TKTProfile profiles do: [ :each |
| aProfile |
Expand All @@ -16,7 +18,7 @@ TKTConfigurationTest >> testAllProfilesCanBeSet [

]

{ #category : #tests }
{ #category : 'tests' }
TKTConfigurationTest >> testDefaultValueIsAProfile [
TKTConfiguration resetSoleInstance.
self assert: (TKTConfiguration profile isKindOf: TKTProfile).
Expand Down
Loading

0 comments on commit 44b7849

Please sign in to comment.