diff options
author | Ulrich Müller <ulm@gentoo.org> | 2024-09-30 18:14:38 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2024-10-02 23:00:39 +0200 |
commit | 9f01191ebcb02ad2c46ff84a47dbd5c816971134 (patch) | |
tree | 31c5e8f9552ef56a10d51fd0455215052045698a | |
parent | Fix some byte-compiler warnings in tests (diff) | |
download | ebuild-mode-9f01191ebcb02ad2c46ff84a47dbd5c816971134.tar.gz ebuild-mode-9f01191ebcb02ad2c46ff84a47dbd5c816971134.tar.bz2 ebuild-mode-9f01191ebcb02ad2c46ff84a47dbd5c816971134.zip |
Fix a byte-compiler warning in tests
* test/ebuild-mode-tests.el (ebuild-mode-test-run-with-fixed-time):
* test/glep-mode-tests.el (glep-mode-test-run-with-fixed-time):
Use func-arity to detect the calling convention for encode-time.
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | test/ebuild-mode-tests.el | 13 | ||||
-rw-r--r-- | test/glep-mode-tests.el | 21 |
3 files changed, 20 insertions, 18 deletions
@@ -1,5 +1,9 @@ 2024-09-30 Ulrich Müller <ulm@gentoo.org> + * test/ebuild-mode-tests.el (ebuild-mode-test-run-with-fixed-time): + * test/glep-mode-tests.el (glep-mode-test-run-with-fixed-time): + Use func-arity to detect the calling convention for encode-time. + * test/ebuild-mode-tests.el (cl-letf, cl-letf*): Enclose their definition in eval-when-compile. (ebuild-mode-test-font-lock): Call font-lock-fontify-region diff --git a/test/ebuild-mode-tests.el b/test/ebuild-mode-tests.el index 6932bdd..ac5674d 100644 --- a/test/ebuild-mode-tests.el +++ b/test/ebuild-mode-tests.el @@ -29,15 +29,14 @@ (defalias 'cl-letf* #'letf*))) (defmacro ebuild-mode-test-run-with-fixed-time (&rest body) - (let ((zone (if (or (not (featurep 'xemacs)) + (let ((encode-time (if (and (fboundp 'func-arity) + (>= 1 (car (func-arity 'encode-time)))) + ;; new calling convention since Emacs 27 + '(encode-time) '(apply #'encode-time))) + (zone (if (or (not (featurep 'xemacs)) (function-allows-args #'format-time-string 3)) (list 'zone)))) - `(cl-letf* ((calendrical '(0 0 0 10 8 2024 nil nil 0)) - (fixed-time (condition-case nil - ;; new calling convention since Emacs 27 - (encode-time calendrical) - (wrong-number-of-arguments - (apply #'encode-time calendrical)))) + `(cl-letf* ((fixed-time (,@encode-time '(0 0 0 10 8 2024 nil nil 0))) (orig-fun (symbol-function 'format-time-string)) ((symbol-function 'format-time-string) (lambda (fmt-string &optional time ,@zone) diff --git a/test/glep-mode-tests.el b/test/glep-mode-tests.el index cc2e162..0706759 100644 --- a/test/glep-mode-tests.el +++ b/test/glep-mode-tests.el @@ -24,17 +24,16 @@ (require 'glep-mode) (defmacro glep-mode-test-run-with-fixed-time (&rest body) - `(cl-letf* ((calendrical '(0 0 0 10 8 2024 nil nil 0)) - (fixed-time (condition-case nil - ;; new calling convention since Emacs 27 - (encode-time calendrical) - (wrong-number-of-arguments - (apply #'encode-time calendrical)))) - (orig-fun (symbol-function 'format-time-string)) - ((symbol-function 'format-time-string) - (lambda (fmt-string &optional time zone) - (funcall orig-fun fmt-string (or time fixed-time) zone)))) - ,@body)) + (let ((encode-time (if (and (fboundp 'func-arity) + (>= 1 (car (func-arity 'encode-time)))) + ;; new calling convention since Emacs 27 + '(encode-time) '(apply #'encode-time)))) + `(cl-letf* ((fixed-time (,@encode-time '(0 0 0 10 8 2024 nil nil 0))) + (orig-fun (symbol-function 'format-time-string)) + ((symbol-function 'format-time-string) + (lambda (fmt-string &optional time zone) + (funcall orig-fun fmt-string (or time fixed-time) zone)))) + ,@body))) (defvar glep-mode-test-input nil) |