A new version of ToolBuilder-Tests was added to project The Inbox:
http://source.squeak.org/inbox/ToolBuilder-Tests-jr.6.mcz ==================== Summary ==================== Name: ToolBuilder-Tests-jr.6 Author: jr Time: 25 April 2021, 9:32:10.341128 pm UUID: 3f989b9a-0bda-b446-9c00-1db787363c6c Ancestors: ToolBuilder-Tests-mt.5 Test that progress exceptions do not interfere with other exception handlers. At the time of this writing, this is broken in Squeak Trunk because too many handlers are reactivated. Related versions: - ToolBuilder-Kernel-nice.141 - ToolBuilder-Kernel-nice.142 Between the recent exception handler changes and the .141 version above, too few handlers were reactivated. =============== Diff against ToolBuilder-Tests-mt.5 =============== Item was added: + TestCase subclass: #ProgressInitiationExceptionTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'ToolBuilder-Tests'! Item was added: + ----- Method: ProgressInitiationExceptionTest>>testRearmedExceptionHandlers (in category 'test') ----- + testRearmedExceptionHandlers + "The work block should run with the same exception handlers active as the context that signalled the progress initiation. To verify that this test asserts the correct behavior, compare with the behavior if the ProgressInitiationException is not signalled, but just the work block executed." + | resultWithProgress resultWithoutProgress | + resultWithProgress := [ + [ + [ + [Warning signal: 'Pretend that a resource is missing'. + 'uncurtailed result' "Should not be reached"] + on: NotFound do: + [:e | e return: 'inner handler result' "Should not be reached"]] + on: Warning do: + [:e | "Pretend to download the missing resource. It takes long." + e return: + (ProgressInitiationException + display: 'some progress' from: 0 to: 1 + during: [:progress | + NotFound signal: 'should be handled by outer handler'])]] + on: NotFound do: + [:e | e return: 'outer handler result']] + on: ProgressInitiationException do: + [:e | e sendNotificationsTo: [:min :max :value | "silence"]]. + resultWithoutProgress := [ + [ + [ + [Warning signal: 'Pretend that a resource is missing'. + 'uncurtailed result' "Should not be reached"] + on: NotFound do: + [:e | e return: 'inner handler result' "Should not be reached"]] + on: Warning do: + [:e | "Pretend to download the missing resource. It takes long." + e return: + "Without ProgressInitiationException this time:" + (NotFound signal: 'should be handled by outer handler')]] + on: NotFound do: + [:e | e return: 'outer handler result']] + on: ProgressInitiationException do: + [:e | e sendNotificationsTo: [:min :max :value | "silence"]]. + self assert: resultWithoutProgress equals: resultWithProgress; + assert: 'outer handler result' equals: resultWithProgress. + "The stack should have looked like this with progress eventually: + - outer handler + - NotFound signal + - [sendNotificationsTo: silence] (reactivates outer handler) + - (found [sendNotificationsTo: silence], gets deactivated before being run) + - (outer handler gets deactivated) + - ProgressInitiationException signal + - warning handler + - (found warning handler, gets deactivated before being run) + - (inner handler gets deactivated) + - Warning signal + - on: NotFound do: inner handler + - on: Warning do: warning handler + - on: NotFound do: outer handler + - on: ProgressInitiationException do: [sendNotificationsTo: silence]"! |
Free forum by Nabble | Edit this page |