bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#74090: 31.0.50; Problems with dabbrev-expand


From: Stephen Berman
Subject: bug#74090: 31.0.50; Problems with dabbrev-expand
Date: Mon, 02 Dec 2024 13:15:23 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

On Mon, 02 Dec 2024 09:33:51 +0200 Juri Linkov <juri@linkov.net> wrote:

>> I've added a test but I'm somewhat dissatisfied with it.  I wanted to
>> essentially reproduce the behavior I see with the patch, described
>> above.  However, after killing buffer "foo", the message about no
>> further expansion is from a user-error in dabbrev-expand, and on hitting
>> this in the test run, the test immediately finishes.  So I used
>> should-error with :type 'user-error and the test succeeds, but I cannot
>> test for the final buffer content nor the message displayed by
>> user-error.  If anyone has an idea how to do that or otherwise improve
>> the test, please chime in.
>
> Probably 'condition-case' could help to catch a user-error.
> Or maybe better to set a buffer-local or let-bind 'command-error-function'
> like e.g. in 'minibuffer-error-initialize'.
>
> Then you can let-bind 'set-message-function' to catch a message
> to check it (but I don't remember if the error calls the message function).
>
> OTOH, I don't understand why the test immediately finishes after 
> 'should-error'?
> There are many tests that call 'should-error' sequentially like:
>
>   (ert-deftest abbrev-table-empty-p-test ()
>     (should-error (abbrev-table-empty-p 42))
>     (should-error (abbrev-table-empty-p "aoeu"))
>     (should-error (abbrev-table-empty-p '()))
>     (should-error (abbrev-table-empty-p []))
>
> And indeed implementation of 'should-error' already has 'condition-case'.

Thanks very much for the feedback.  I was wrong about the test
immediately finishing after `should-error'; I guess I misread or
misunderstood the output of the batch run.  Additionally, there was a
typo in the test of the final buffer content, which caused it to fail,
and that probably confused me further.  As for testing the error
message, I overlooked that `should-error' returns an error description
containing the message, so that seems the simplest way to do it.  With
these changes the test succeeds in batch runs and I think now better
reflects the user experience with manual input, so I went ahead and
pushed the fix (commit 6bca138d60e to emacs-30).  If you agree, feel
free to close the bug again (assuming it needs to be reclosed, since you
unarchived it); otherwise, if you see other problems with the test,
please let me know.

Steve Berman





reply via email to

[Prev in Thread] Current Thread [Next in Thread]