Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions source/FluxBase-Core-Tests/FBCancellationTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -983,3 +983,22 @@ FBCancellationTest >> testCancellingTheRemainingIterationsTakesAWaitingSubFlowWi
self assert: seen asArray equals: { #( nil nil ) }.
self assertConsistent: instance
]

{ #category : 'tests' }
FBCancellationTest >> testCancellingAFinishedInstanceIsNothing [
"a finished case is not cancelled after the fact: no trace, and it stays #done"
| flow instance before |
flow := self flowSplittingIntoTwoEnds.
instance := flow newInstance.
instance executeWith: 1.
self assert: instance state equals: #done.
self assert: instance hasEnded.
before := instance events size.

self assert: (instance cancel) isEmpty.

self assert: instance state equals: #done.
self deny: instance isCancelled.
self assert: instance events size equals: before.
self assertConsistent: instance
]
6 changes: 4 additions & 2 deletions source/FluxBase-Core/FBFlowInstance.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,11 @@ FBFlowInstance >> cancel [
waits in me, and end - regardless of steps that failed before, an abort is a
decision. I read #cancelled from then on; a late signal or a second cancel is
silent. An instance that has not run yet gets its root scope for this - it has
been cancelled before it started, and says so"
been cancelled before it started, and says so. An instance that is over already -
done, or cancelled before - is left as it is: cancelling a finished case is
nothing, and it must not turn a #done into a #cancelled after the fact"

self isCancelled ifTrue: [ ^ #() ].
self hasEnded ifTrue: [ ^ #() ].
self ensureScope.
^ [ self cancelScope: scope ] ensure: [
(executor isNil or: [ self atEnd ]) ifTrue: [ self ended ] ]
Expand Down
Loading