Subject: Re: bug#67862: 30.0.50; Handler-bind and ert-test-error-debug

From: Stefan Monnier <[email-masked]>
Date: Tue, 26 Dec 2023 11:25:22 -0500

>>     (ert-deftest ert-test-error-debug ()
>>       (let ((test (make-ert-test :body (lambda () (error "Error message")))))
>>         (condition-case condition
>>             (progn
>>               (let ((ert-debug-on-error t))
>>                 (ert-run-test test))
>>               (cl-assert nil))
>>           ((error)
>>            (cl-assert (equal condition '(error "Error message")) t)))))
>>
>> Until now, this test passes just like that, i.e. without entering
>> the debugger.  With the new code, this test does enter the debugger.
>>
>> Can anyone give me a hand figuring out why/how the debugger is not entered
>> with the current code?
>
> Could that be from the condition-case that the test puts around the
> ert-run-test? Like in
>
>   (condition-case var
>       (let ((debug-on-error t))
>         (error "error"))
>     (error "no debugger"))
>     
OK, so now I understand how that test succeeds, but instead I don't
understand why it is expected to succeed or more specifically what it is
intended to test.

AFAICT

            (let ((ert-debug-on-error t))
              (ert-run-test test))

is supposed to say "run the test and please pop up a debugger if there's
an error".  The ERT code even goes to the trouble to store&use the value of
`ert-debug-on-error` upon entry to the tests rather the value that
happens to be current when the error is signaled.

So to me the code looks like it wants to test that `ert-debug-on-error`
indeed brings up a debugger, tho none of the surrounding code tries to
detect whether the debugger is/was entered, and instead that surrounding
code uses `condition-case` which prevents entering the debugger.

Is it really the purpose of this test to make sure that "even if we ask
for the debugger, `condition-case` prevents the use of a debugger"?

        Stefan