[squeak-dev] The Trunk: ToolBuilder-Tests-jr.6.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon Apr 26 00:14:48 UTC 2021


Very good example, but this one, i don't know how to solve yet.

I thought that I could use resumeEvaluating: introduced in the inbox
Kernel-nice.1394 in order to evaluate the block in the context that
did send the signal.
But this is dangerous if the block tries to manipulate the stack (like
doing a resume: or return: or...).


Le lun. 26 avr. 2021 à 02:09, <commits at source.squeak.org> a écrit :
>
> Nicolas Cellier uploaded a new version of ToolBuilder-Tests to project The Trunk:
> http://source.squeak.org/trunk/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]"!
>
>


More information about the Squeak-dev mailing list