diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-04-07 16:29:32 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-04-07 19:08:33 +0200 |
commit | 7c0c2b1bb539424af1bb72bd9caefedd66cfd3da (patch) | |
tree | d17e18d4bf8407c818985e29f22c5bb8b3d1717a /test | |
parent | 211618293d9fd620f9f8971090e049d98c05f546 (diff) | |
download | emacs-7c0c2b1bb539424af1bb72bd9caefedd66cfd3da.tar.gz |
Remove useless unwind-protect forms, or make them useful as intended
* lisp/imenu.el (imenu--generic-function):
* lisp/mail/yenc.el (yenc-decode-region):
* lisp/textmodes/table.el (table-recognize-region):
* test/lisp/dired-tests.el (dired-test-directory-files):
* test/lisp/hl-line-tests.el (hl-line-tests-sticky):
Fix unwind-protect bracketing mistakes that caused the unwind code to
be misplaced.
* lisp/strokes.el (strokes-read-stroke): Fix a bracketing mistake that
misplaced the unwind code, and another one that misplaced the
else-clause of an `if` form.
* test/lisp/gnus/mml-sec-tests.el (mml-secure-test-fixture): Fix a
bracketing mistake that misplaced the unwind code, and remove
superfluous condition-case.
* lisp/mwheel.el (mouse-wheel-global-text-scale):
* lisp/speedbar.el (speedbar-stealthy-updates)
(speedbar-fetch-dynamic-etags):
* lisp/emacs-lisp/edebug.el (edebug--recursive-edit):
* lisp/emacs-lisp/package.el (package--read-pkg-desc):
* lisp/cedet/semantic.el (semantic-refresh-tags-safe):
* lisp/emulation/viper-cmd.el (viper-escape-to-state):
* lisp/emulation/viper-cmd.el (viper-file-add-suffix):
* lisp/gnus/mail-source.el (mail-source-movemail):
* lisp/mail/feedmail.el (feedmail-send-it-immediately)
(feedmail-deduce-address-list):
* lisp/mail/mailclient.el (mailclient-send-it):
* lisp/mail/smtpmail.el (smtpmail-deduce-address-list):
* lisp/mh-e/mh-print.el (mh-ps-print-range):
* lisp/textmodes/reftex-index.el (reftex-index-this-phrase):
* test/lisp/emacs-lisp/ert-tests.el (ert-test-run-tests-batch):
(ert-test-run-tests-batch-expensive):
Remove unwind-protect forms that are apparently useless, some since a
prior edit that removed their purpose, some since their first
appearance.
* test/lisp/subr-tests.el (subr-test--frames-2):
Insert dummy unwind form in backtrace test code.
Diffstat (limited to 'test')
-rw-r--r-- | test/lisp/dired-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/ert-tests.el | 28 | ||||
-rw-r--r-- | test/lisp/gnus/mml-sec-tests.el | 51 | ||||
-rw-r--r-- | test/lisp/hl-line-tests.el | 8 | ||||
-rw-r--r-- | test/lisp/subr-tests.el | 3 |
5 files changed, 44 insertions, 50 deletions
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el index 347bdfc0d7b..0701b229edd 100644 --- a/test/lisp/dired-tests.el +++ b/test/lisp/dired-tests.el @@ -477,9 +477,9 @@ ;;(should (= 0 (length (directory-files testdir nil "[0-9]" t -1)))) (should (= 5 (length (directory-files testdir nil "[0-9]" t)))) (should (= 5 (length (directory-files testdir nil "[0-9]" t 50)))) - (should-not (directory-empty-p testdir))) + (should-not (directory-empty-p testdir)))) - (delete-directory testdir t))))) + (delete-directory testdir t)))) (ert-deftest dired-test-directory-files-and-attributes () "Test for `directory-files-and-attributes'." diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el index 3e499fc6f59..7713a0f6e38 100644 --- a/test/lisp/emacs-lisp/ert-tests.el +++ b/test/lisp/emacs-lisp/ert-tests.el @@ -577,13 +577,12 @@ This macro is used to test if macroexpansion in `should' works." (lambda (format-string &rest args) (push (apply #'format format-string args) messages)))) (save-window-excursion - (unwind-protect - (let ((case-fold-search nil) - (ert-batch-backtrace-right-margin nil) - (ert-batch-print-level 10) - (ert-batch-print-length 11)) - (ert-run-tests-batch - `(member ,failing-test-1 ,failing-test-2)))))) + (let ((case-fold-search nil) + (ert-batch-backtrace-right-margin nil) + (ert-batch-print-level 10) + (ert-batch-print-length 11)) + (ert-run-tests-batch + `(member ,failing-test-1 ,failing-test-2))))) (let ((long-text "(different-types[ \t\n]+(1 1 1 1 1 1 1 1 1 1 1)[ \t\n]+1)))[ \t\n]*$") (complex-text "(different-types[ \t\n]+((:1[ \t\n]+(:2[ \t\n]+(:3[ \t\n]+(:4[ \t\n]+(:5[ \t\n]+(:6[ \t\n]+\"abc\")))))))[ \t\n]+1)))[ \t\n]*$") found-long @@ -609,14 +608,13 @@ This macro is used to test if macroexpansion in `should' works." (lambda (format-string &rest args) (push (apply #'format format-string args) messages)))) (save-window-excursion - (unwind-protect - (let ((case-fold-search nil) - (ert-batch-backtrace-right-margin nil) - (ert-batch-backtrace-line-length nil) - (ert-batch-print-level 6) - (ert-batch-print-length 11)) - (ert-run-tests-batch - `(member ,failing-test-1)))))) + (let ((case-fold-search nil) + (ert-batch-backtrace-right-margin nil) + (ert-batch-backtrace-line-length nil) + (ert-batch-print-level 6) + (ert-batch-print-length 11)) + (ert-run-tests-batch + `(member ,failing-test-1))))) (let ((frame "ert-fail(((should (equal complex-list 1)) :form (equal ((:1 (:2 (:3 (:4 (:5 (:6 \"abc\"))))))) 1) :value nil :explanation (different-types ((:1 (:2 (:3 (:4 (:5 (:6 \"abc\"))))))) 1)))") found-frame) (cl-loop for msg in (reverse messages) diff --git a/test/lisp/gnus/mml-sec-tests.el b/test/lisp/gnus/mml-sec-tests.el index 37e84c148af..a5dadf21c8c 100644 --- a/test/lisp/gnus/mml-sec-tests.el +++ b/test/lisp/gnus/mml-sec-tests.el @@ -66,34 +66,29 @@ This fixture temporarily unsets GPG_AGENT_INFO to enable passphrase tests, which will neither work with gpgsm nor GnuPG 2.1 any longer, I guess. Actually, I'm not sure why people would want to cache passwords in Emacs instead of gpg-agent." - (unwind-protect - (let ((agent-info (getenv "GPG_AGENT_INFO")) - (gpghome (getenv "GNUPGHOME"))) - (condition-case error - (let ((epg-gpg-home-directory (ert-resource-directory)) - (mml-smime-use 'epg) - ;; Create debug output in empty epg-debug-buffer. - (epg-debug t) - (epg-debug-buffer (get-buffer-create " *epg-test*")) - (mml-secure-fail-when-key-problem (not interactive))) - (with-current-buffer epg-debug-buffer - (erase-buffer)) - ;; Unset GPG_AGENT_INFO to enable passphrase caching inside Emacs. - ;; Just for testing. Jens does not recommend this for daily use. - (setenv "GPG_AGENT_INFO") - ;; Set GNUPGHOME as gpg-agent started by gpgsm does - ;; not look in the proper places otherwise, see: - ;; https://bugs.gnupg.org/gnupg/issue2126 - (setenv "GNUPGHOME" epg-gpg-home-directory) - (unwind-protect - (funcall body) - (mml-sec-test--kill-gpg-agent))) - (error - (setenv "GPG_AGENT_INFO" agent-info) - (setenv "GNUPGHOME" gpghome) - (signal (car error) (cdr error)))) - (setenv "GPG_AGENT_INFO" agent-info) - (setenv "GNUPGHOME" gpghome)))) + (let ((agent-info (getenv "GPG_AGENT_INFO")) + (gpghome (getenv "GNUPGHOME"))) + (unwind-protect + (let ((epg-gpg-home-directory (ert-resource-directory)) + (mml-smime-use 'epg) + ;; Create debug output in empty epg-debug-buffer. + (epg-debug t) + (epg-debug-buffer (get-buffer-create " *epg-test*")) + (mml-secure-fail-when-key-problem (not interactive))) + (with-current-buffer epg-debug-buffer + (erase-buffer)) + ;; Unset GPG_AGENT_INFO to enable passphrase caching inside Emacs. + ;; Just for testing. Jens does not recommend this for daily use. + (setenv "GPG_AGENT_INFO") + ;; Set GNUPGHOME as gpg-agent started by gpgsm does + ;; not look in the proper places otherwise, see: + ;; https://bugs.gnupg.org/gnupg/issue2126 + (setenv "GNUPGHOME" epg-gpg-home-directory) + (unwind-protect + (funcall body) + (mml-sec-test--kill-gpg-agent))) + (setenv "GPG_AGENT_INFO" agent-info) + (setenv "GNUPGHOME" gpghome)))) (defun mml-secure-test-message-setup (method to from &optional text bcc) "Setup a buffer with MML METHOD, TO, and FROM headers. diff --git a/test/lisp/hl-line-tests.el b/test/lisp/hl-line-tests.el index 56924ff8e3e..9c120e0d7ff 100644 --- a/test/lisp/hl-line-tests.el +++ b/test/lisp/hl-line-tests.el @@ -104,10 +104,10 @@ (run-hooks 'post-command-hook) (should (hl-line-tests-verify 257 t)) (with-current-buffer second-buffer - (should (hl-line-tests-verify 999 nil))))) - (let (kill-buffer-query-functions) - (ignore-errors (kill-buffer first-buffer)) - (ignore-errors (kill-buffer second-buffer))))) + (should (hl-line-tests-verify 999 nil)))) + (let (kill-buffer-query-functions) + (ignore-errors (kill-buffer first-buffer)) + (ignore-errors (kill-buffer second-buffer)))))) (provide 'hl-line-tests) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 050ee22ac18..8f46c2af136 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -579,7 +579,8 @@ (cons (mapcar (pcase-lambda (`(,evald ,func ,args ,_)) `(,evald ,func ,@args)) (backtrace-frames base)) - (subr-test--backtrace-frames-with-backtrace-frame base)))))) + (subr-test--backtrace-frames-with-backtrace-frame base)) + (sit-for 0))))) ; dummy unwind form (defun subr-test--frames-1 (base) (subr-test--frames-2 base)) |