aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias EngdegÄrd2023-04-07 16:29:32 +0200
committerMattias EngdegÄrd2023-04-07 19:08:33 +0200
commit7c0c2b1bb539424af1bb72bd9caefedd66cfd3da (patch)
treed17e18d4bf8407c818985e29f22c5bb8b3d1717a /test
parent211618293d9fd620f9f8971090e049d98c05f546 (diff)
downloademacs-7c0c2b1bb539424af1bb72bd9caefedd66cfd3da.tar.gz
emacs-7c0c2b1bb539424af1bb72bd9caefedd66cfd3da.zip
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.el4
-rw-r--r--test/lisp/emacs-lisp/ert-tests.el28
-rw-r--r--test/lisp/gnus/mml-sec-tests.el51
-rw-r--r--test/lisp/hl-line-tests.el8
-rw-r--r--test/lisp/subr-tests.el3
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 @@
477 ;;(should (= 0 (length (directory-files testdir nil "[0-9]" t -1)))) 477 ;;(should (= 0 (length (directory-files testdir nil "[0-9]" t -1))))
478 (should (= 5 (length (directory-files testdir nil "[0-9]" t)))) 478 (should (= 5 (length (directory-files testdir nil "[0-9]" t))))
479 (should (= 5 (length (directory-files testdir nil "[0-9]" t 50)))) 479 (should (= 5 (length (directory-files testdir nil "[0-9]" t 50))))
480 (should-not (directory-empty-p testdir))) 480 (should-not (directory-empty-p testdir))))
481 481
482 (delete-directory testdir t))))) 482 (delete-directory testdir t))))
483 483
484(ert-deftest dired-test-directory-files-and-attributes () 484(ert-deftest dired-test-directory-files-and-attributes ()
485 "Test for `directory-files-and-attributes'." 485 "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."
577 (lambda (format-string &rest args) 577 (lambda (format-string &rest args)
578 (push (apply #'format format-string args) messages)))) 578 (push (apply #'format format-string args) messages))))
579 (save-window-excursion 579 (save-window-excursion
580 (unwind-protect 580 (let ((case-fold-search nil)
581 (let ((case-fold-search nil) 581 (ert-batch-backtrace-right-margin nil)
582 (ert-batch-backtrace-right-margin nil) 582 (ert-batch-print-level 10)
583 (ert-batch-print-level 10) 583 (ert-batch-print-length 11))
584 (ert-batch-print-length 11)) 584 (ert-run-tests-batch
585 (ert-run-tests-batch 585 `(member ,failing-test-1 ,failing-test-2)))))
586 `(member ,failing-test-1 ,failing-test-2))))))
587 (let ((long-text "(different-types[ \t\n]+(1 1 1 1 1 1 1 1 1 1 1)[ \t\n]+1)))[ \t\n]*$") 586 (let ((long-text "(different-types[ \t\n]+(1 1 1 1 1 1 1 1 1 1 1)[ \t\n]+1)))[ \t\n]*$")
588 (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]*$") 587 (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]*$")
589 found-long 588 found-long
@@ -609,14 +608,13 @@ This macro is used to test if macroexpansion in `should' works."
609 (lambda (format-string &rest args) 608 (lambda (format-string &rest args)
610 (push (apply #'format format-string args) messages)))) 609 (push (apply #'format format-string args) messages))))
611 (save-window-excursion 610 (save-window-excursion
612 (unwind-protect 611 (let ((case-fold-search nil)
613 (let ((case-fold-search nil) 612 (ert-batch-backtrace-right-margin nil)
614 (ert-batch-backtrace-right-margin nil) 613 (ert-batch-backtrace-line-length nil)
615 (ert-batch-backtrace-line-length nil) 614 (ert-batch-print-level 6)
616 (ert-batch-print-level 6) 615 (ert-batch-print-length 11))
617 (ert-batch-print-length 11)) 616 (ert-run-tests-batch
618 (ert-run-tests-batch 617 `(member ,failing-test-1)))))
619 `(member ,failing-test-1))))))
620 (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)))") 618 (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)))")
621 found-frame) 619 found-frame)
622 (cl-loop for msg in (reverse messages) 620 (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,
66which will neither work with gpgsm nor GnuPG 2.1 any longer, I guess. 66which will neither work with gpgsm nor GnuPG 2.1 any longer, I guess.
67Actually, I'm not sure why people would want to cache passwords in Emacs 67Actually, I'm not sure why people would want to cache passwords in Emacs
68instead of gpg-agent." 68instead of gpg-agent."
69 (unwind-protect 69 (let ((agent-info (getenv "GPG_AGENT_INFO"))
70 (let ((agent-info (getenv "GPG_AGENT_INFO")) 70 (gpghome (getenv "GNUPGHOME")))
71 (gpghome (getenv "GNUPGHOME"))) 71 (unwind-protect
72 (condition-case error 72 (let ((epg-gpg-home-directory (ert-resource-directory))
73 (let ((epg-gpg-home-directory (ert-resource-directory)) 73 (mml-smime-use 'epg)
74 (mml-smime-use 'epg) 74 ;; Create debug output in empty epg-debug-buffer.
75 ;; Create debug output in empty epg-debug-buffer. 75 (epg-debug t)
76 (epg-debug t) 76 (epg-debug-buffer (get-buffer-create " *epg-test*"))
77 (epg-debug-buffer (get-buffer-create " *epg-test*")) 77 (mml-secure-fail-when-key-problem (not interactive)))
78 (mml-secure-fail-when-key-problem (not interactive))) 78 (with-current-buffer epg-debug-buffer
79 (with-current-buffer epg-debug-buffer 79 (erase-buffer))
80 (erase-buffer)) 80 ;; Unset GPG_AGENT_INFO to enable passphrase caching inside Emacs.
81 ;; Unset GPG_AGENT_INFO to enable passphrase caching inside Emacs. 81 ;; Just for testing. Jens does not recommend this for daily use.
82 ;; Just for testing. Jens does not recommend this for daily use. 82 (setenv "GPG_AGENT_INFO")
83 (setenv "GPG_AGENT_INFO") 83 ;; Set GNUPGHOME as gpg-agent started by gpgsm does
84 ;; Set GNUPGHOME as gpg-agent started by gpgsm does 84 ;; not look in the proper places otherwise, see:
85 ;; not look in the proper places otherwise, see: 85 ;; https://bugs.gnupg.org/gnupg/issue2126
86 ;; https://bugs.gnupg.org/gnupg/issue2126 86 (setenv "GNUPGHOME" epg-gpg-home-directory)
87 (setenv "GNUPGHOME" epg-gpg-home-directory) 87 (unwind-protect
88 (unwind-protect 88 (funcall body)
89 (funcall body) 89 (mml-sec-test--kill-gpg-agent)))
90 (mml-sec-test--kill-gpg-agent))) 90 (setenv "GPG_AGENT_INFO" agent-info)
91 (error 91 (setenv "GNUPGHOME" gpghome))))
92 (setenv "GPG_AGENT_INFO" agent-info)
93 (setenv "GNUPGHOME" gpghome)
94 (signal (car error) (cdr error))))
95 (setenv "GPG_AGENT_INFO" agent-info)
96 (setenv "GNUPGHOME" gpghome))))
97 92
98(defun mml-secure-test-message-setup (method to from &optional text bcc) 93(defun mml-secure-test-message-setup (method to from &optional text bcc)
99 "Setup a buffer with MML METHOD, TO, and FROM headers. 94 "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 @@
104 (run-hooks 'post-command-hook) 104 (run-hooks 'post-command-hook)
105 (should (hl-line-tests-verify 257 t)) 105 (should (hl-line-tests-verify 257 t))
106 (with-current-buffer second-buffer 106 (with-current-buffer second-buffer
107 (should (hl-line-tests-verify 999 nil))))) 107 (should (hl-line-tests-verify 999 nil))))
108 (let (kill-buffer-query-functions) 108 (let (kill-buffer-query-functions)
109 (ignore-errors (kill-buffer first-buffer)) 109 (ignore-errors (kill-buffer first-buffer))
110 (ignore-errors (kill-buffer second-buffer))))) 110 (ignore-errors (kill-buffer second-buffer))))))
111 111
112(provide 'hl-line-tests) 112(provide 'hl-line-tests)
113 113
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 @@
579 (cons (mapcar (pcase-lambda (`(,evald ,func ,args ,_)) 579 (cons (mapcar (pcase-lambda (`(,evald ,func ,args ,_))
580 `(,evald ,func ,@args)) 580 `(,evald ,func ,@args))
581 (backtrace-frames base)) 581 (backtrace-frames base))
582 (subr-test--backtrace-frames-with-backtrace-frame base)))))) 582 (subr-test--backtrace-frames-with-backtrace-frame base))
583 (sit-for 0))))) ; dummy unwind form
583 584
584(defun subr-test--frames-1 (base) 585(defun subr-test--frames-1 (base)
585 (subr-test--frames-2 base)) 586 (subr-test--frames-2 base))