emacs-diffs
[Top][All Lists]
Advanced

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

master 7c68c84: Silence byte-compiler in some tests


From: Stefan Kangas
Subject: master 7c68c84: Silence byte-compiler in some tests
Date: Sat, 4 Dec 2021 09:50:08 -0500 (EST)

branch: master
commit 7c68c84674d67d7bee9d78b99ce01ad789a77961
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Silence byte-compiler in some tests
    
    * test/lisp/dired-tests.el:
    * test/lisp/emacs-lisp/cl-macs-tests.el:
    * test/lisp/emacs-lisp/derived-tests.el:
    * test/lisp/emacs-lisp/eieio-tests/eieio-tests.el:
    * test/lisp/emacs-lisp/generator-tests.el:
    * test/lisp/emacs-lisp/lisp-tests.el:
    * test/lisp/emacs-lisp/seq-tests.el (test-seq-let)
    (test-seq-setq):
    * test/lisp/emacs-lisp/subr-x-tests.el (subr-x-test-if-let*-false)
    (subr-x-test-if-let*-and-laziness-is-preserved)
    (subr-x-test-when-let*-false)
    (subr-x-test-when-let*-and-laziness-is-preserved):
    * test/lisp/emacs-lisp/timer-tests.el
    (timer-tests-debug-timer-check):
    * test/lisp/format-spec-tests.el (format-spec-do-flags-truncate)
    (format-spec-do-flags-pad):
    * test/lisp/ls-lisp-tests.el (ls-lisp-test-bug27762):
    * test/lisp/obsolete/cl-tests.el (labels-function-quoting):
    * test/lisp/progmodes/elisp-mode-tests.el:
    * test/lisp/replace-tests.el (replace-regexp-bug45973):
    * test/lisp/ses-tests.el:
    * test/lisp/subr-tests.el:
    * test/lisp/tar-mode-tests.el (tar-mode-test-tar-grind-file-mode):
    * test/src/data-tests.el (data-tests--set-default-per-buffer):
    * test/src/search-tests.el
    (test-replace-match-modification-hooks): Silence byte-compiler.
---
 test/lisp/dired-tests.el                        | 49 ++++++++++++++++---------
 test/lisp/emacs-lisp/cl-macs-tests.el           |  4 ++
 test/lisp/emacs-lisp/derived-tests.el           |  4 +-
 test/lisp/emacs-lisp/eieio-tests/eieio-tests.el | 40 ++++++++++----------
 test/lisp/emacs-lisp/generator-tests.el         |  3 +-
 test/lisp/emacs-lisp/lisp-tests.el              |  1 +
 test/lisp/emacs-lisp/seq-tests.el               | 20 ++++++----
 test/lisp/emacs-lisp/subr-x-tests.el            | 26 ++++++-------
 test/lisp/emacs-lisp/timer-tests.el             |  3 +-
 test/lisp/format-spec-tests.el                  |  4 +-
 test/lisp/ls-lisp-tests.el                      |  3 +-
 test/lisp/obsolete/cl-tests.el                  | 11 ++++--
 test/lisp/progmodes/elisp-mode-tests.el         | 18 ++++++---
 test/lisp/replace-tests.el                      | 11 +++---
 test/lisp/ses-tests.el                          |  4 ++
 test/lisp/subr-tests.el                         |  1 +
 test/lisp/tar-mode-tests.el                     |  8 +++-
 test/src/data-tests.el                          | 41 +++++++++++----------
 test/src/search-tests.el                        |  2 +-
 19 files changed, 152 insertions(+), 101 deletions(-)

diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 4379111..1c4f37b 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -543,10 +543,12 @@ path's data to use."
                          ((equal "." path) default-directory)
                          (path)))
              (return-size
-              (car (files-tests--look-up-free-data path))))
+              ;; It is always defined but this silences the byte-compiler:
+              (when (fboundp 'files-tests--look-up-free-data)
+                (car (files-tests--look-up-free-data path)))))
         (list return-size return-size return-size))))
 
-  (defun files-tests--insert-directory-output (dir &optional verbose)
+  (defun files-tests--insert-directory-output (dir &optional _verbose)
     "Run `insert-directory' and return its output."
     (with-current-buffer-window "files-tests--insert-directory" nil nil
       (let ((dired-free-space 'separate))
@@ -555,35 +557,46 @@ path's data to use."
 
   (ert-deftest files-tests-insert-directory-shows-files ()
     "Verify `insert-directory' reports the files in the directory."
-    (let* ((test-dir (car test-files))
-           (files (cdr test-files))
-           (output (files-tests--insert-directory-output test-dir)))
-      (dolist (file files)
-        (should (string-match-p file output)))))
+    ;; It is always defined but this silences the byte-compiler:
+    (when (fboundp 'files-tests--insert-directory-output)
+      (let* ((test-dir (car test-files))
+             (files (cdr test-files))
+             (output (files-tests--insert-directory-output test-dir)))
+        (dolist (file files)
+          (should (string-match-p file output))))))
 
   (defun files-tests--insert-directory-shows-given-free (dir &optional
                                                              info-func)
     "Run `insert-directory' and verify it reports the correct available space.
 Stub `file-system-info' to ensure the available space is consistent,
 either with the given stub function or a default one using test data."
-    (cl-letf (((symbol-function 'file-system-info)
-               (or info-func
-                   (files-tests--make-file-system-info-stub))))
-      (should (string-match-p (cadr
-                               (files-tests--look-up-free-data dir))
-                              (files-tests--insert-directory-output dir t)))))
+    ;; It is always defined but this silences the byte-compiler:
+    (when (and (fboundp 'files-tests--make-file-system-info-stub)
+               (fboundp 'files-tests--look-up-free-data)
+               (fboundp 'files-tests--insert-directory-output))
+      (cl-letf (((symbol-function 'file-system-info)
+                 (or info-func
+                     (files-tests--make-file-system-info-stub))))
+        (should (string-match-p (cadr
+                                 (files-tests--look-up-free-data dir))
+                                (files-tests--insert-directory-output dir 
t))))))
 
   (ert-deftest files-tests-insert-directory-shows-free ()
     "Test that verbose `insert-directory' shows the correct available space."
-    (files-tests--insert-directory-shows-given-free
-     test-dir
-     (files-tests--make-file-system-info-stub test-dir)))
+    ;; It is always defined but this silences the byte-compiler:
+    (when (and (fboundp 'files-tests--insert-directory-shows-given-free)
+               (fboundp 'files-tests--make-file-system-info-stub))
+      (files-tests--insert-directory-shows-given-free
+       test-dir
+       (files-tests--make-file-system-info-stub test-dir))))
 
   (ert-deftest files-tests-bug-50630 ()
     "Verify verbose `insert-directory' shows free space of the target 
directory.
 The current directory at call time should not affect the result (Bug#50630)."
-    (let ((default-directory test-dir-other))
-      (files-tests--insert-directory-shows-given-free test-dir))))
+    ;; It is always defined but this silences the byte-compiler:
+    (when (fboundp 'files-tests--insert-directory-shows-given-free)
+      (let ((default-directory test-dir-other))
+        (files-tests--insert-directory-shows-given-free test-dir)))))
 
 (provide 'dired-tests)
 ;;; dired-tests.el ends here
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el 
b/test/lisp/emacs-lisp/cl-macs-tests.el
index be2c0fa..7c3afef 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -668,6 +668,10 @@ collection clause."
                      #'len))
             (`(function (lambda (,_ ,_) . ,_)) t))))
 
+(with-suppressed-warnings ((lexical test) (lexical test1) (lexical test2))
+  (defvar test)
+  (defvar test1)
+  (defvar test2))
 (ert-deftest cl-macs--progv ()
   (should (= (cl-progv '(test test) '(1 2) test) 2))
   (should (equal (cl-progv '(test1 test2) '(1 2) (list test1 test2))
diff --git a/test/lisp/emacs-lisp/derived-tests.el 
b/test/lisp/emacs-lisp/derived-tests.el
index 9c8e6c3..2647b86 100644
--- a/test/lisp/emacs-lisp/derived-tests.el
+++ b/test/lisp/emacs-lisp/derived-tests.el
@@ -24,13 +24,13 @@
 (define-derived-mode derived-tests--parent-mode prog-mode "P"
   :after-hook
   (let ((f (let ((x "S")) (lambda () x))))
-    (insert (format "AFP=%s " (let ((x "D")) (funcall f)))))
+    (insert (format "AFP=%s " (let ((x "D")) x (funcall f)))))
   (insert "PB "))
 
 (define-derived-mode derived-tests--child-mode derived-tests--parent-mode "C"
   :after-hook
   (let ((f (let ((x "S")) (lambda () x))))
-    (insert (format "AFC=%s " (let ((x "D")) (funcall f)))))
+    (insert (format "AFC=%s " (let ((x "D")) x (funcall f)))))
   (insert "CB "))
 
 (ert-deftest derived-tests-after-hook-lexical ()
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el 
b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
index ba2e5f7..dfdfb63 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
@@ -172,7 +172,7 @@
   ;; Check that generic-p works
   (should (generic-p 'generic1))
 
-  (defmethod generic1 ((c class-a))
+  (defmethod generic1 ((_c class-a))
     "Method on generic1."
     'monkey)
 
@@ -240,12 +240,12 @@ Argument C is the class bound to this static method."
   (should (make-instance 'class-a :water 'cho))
   (should (make-instance 'class-b)))
 
-(defmethod class-cn ((a class-a))
+(defmethod class-cn ((_a class-a))
   "Try calling `call-next-method' when there isn't one.
 Argument A is object of type symbol `class-a'."
   (call-next-method))
 
-(defmethod no-next-method ((a class-a) &rest args)
+(defmethod no-next-method ((_a class-a) &rest _args)
   "Override signal throwing for variable `class-a'.
 Argument A is the object of class variable `class-a'."
   'moose)
@@ -254,7 +254,7 @@ Argument A is the object of class variable `class-a'."
   ;; Play with call-next-method
   (should (eq (class-cn eitest-ab) 'moose)))
 
-(defmethod no-applicable-method ((b class-b) method &rest args)
+(defmethod no-applicable-method ((_b class-b) _method &rest _args)
   "No need.
 Argument B is for booger.
 METHOD is the method that was attempting to be called."
@@ -264,38 +264,38 @@ METHOD is the method that was attempting to be called."
   ;; Non-existing methods.
   (should (eq (class-cn eitest-b) 'moose)))
 
-(defmethod class-fun ((a class-a))
+(defmethod class-fun ((_a class-a))
   "Fun with class A."
   'moose)
 
-(defmethod class-fun ((b class-b))
+(defmethod class-fun ((_b class-b))
   "Fun with class B."
   (error "Class B fun should not be called")
   )
 
-(defmethod class-fun-foo ((b class-b))
+(defmethod class-fun-foo ((_b class-b))
   "Foo Fun with class B."
   'moose)
 
-(defmethod class-fun2 ((a class-a))
+(defmethod class-fun2 ((_a class-a))
   "More fun with class A."
   'moose)
 
-(defmethod class-fun2 ((b class-b))
+(defmethod class-fun2 ((_b class-b))
   "More fun with class B."
   (error "Class B fun2 should not be called")
   )
 
-(defmethod class-fun2 ((ab class-ab))
+(defmethod class-fun2 ((_ab class-ab))
   "More fun with class AB."
   (call-next-method))
 
 ;; How about if B is the only slot?
-(defmethod class-fun3 ((b class-b))
+(defmethod class-fun3 ((_b class-b))
   "Even More fun with class B."
   'moose)
 
-(defmethod class-fun3 ((ab class-ab))
+(defmethod class-fun3 ((_ab class-ab))
   "Even More fun with class AB."
   (call-next-method))
 
@@ -314,17 +314,17 @@ METHOD is the method that was attempting to be called."
 
 
 (defvar class-fun-value-seq '())
-(defmethod class-fun-value :BEFORE ((a class-a))
+(defmethod class-fun-value :BEFORE ((_a class-a))
   "Return `before', and push `before' in `class-fun-value-seq'."
   (push 'before class-fun-value-seq)
   'before)
 
-(defmethod class-fun-value :PRIMARY ((a class-a))
+(defmethod class-fun-value :PRIMARY ((_a class-a))
   "Return `primary', and push `primary' in `class-fun-value-seq'."
   (push 'primary class-fun-value-seq)
   'primary)
 
-(defmethod class-fun-value :AFTER ((a class-a))
+(defmethod class-fun-value :AFTER ((_a class-a))
   "Return `after', and push `after' in `class-fun-value-seq'."
   (push 'after class-fun-value-seq)
   'after)
@@ -343,14 +343,14 @@ METHOD is the method that was attempting to be called."
 ;;
 
 (ert-deftest eieio-test-13-init-methods ()
-  (defmethod initialize-instance ((a class-a) &rest slots)
+  (defmethod initialize-instance ((a class-a) &rest _slots)
     "Initialize the slots of class-a."
     (call-next-method)
     (if (/= (oref a test-tag) 1)
        (error "shared-initialize test failed."))
     (oset a test-tag 2))
 
-  (defmethod shared-initialize ((a class-a) &rest slots)
+  (defmethod shared-initialize ((a class-a) &rest _slots)
     "Shared initialize method for class-a."
     (call-next-method)
     (oset a test-tag 1))
@@ -369,7 +369,7 @@ METHOD is the method that was attempting to be called."
 
 (ert-deftest eieio-test-15-slot-missing ()
 
-  (defmethod slot-missing ((ab class-ab) &rest foo)
+  (defmethod slot-missing ((_ab class-ab) &rest _foo)
     "If a slot in AB is unbound, return something cool.  FOO."
     'moose)
 
@@ -425,7 +425,7 @@ METHOD is the method that was attempting to be called."
 
 (ert-deftest eieio-test-18-slot-unbound ()
 
-  (defmethod slot-unbound ((a class-a) &rest foo)
+  (defmethod slot-unbound ((_a class-a) &rest _foo)
     "If a slot in A is unbound, ignore FOO."
     'moose)
 
@@ -448,7 +448,7 @@ METHOD is the method that was attempting to be called."
   (should (eq (oref (class-a) water) 'penguin))
 
   ;; Revert the above
-  (defmethod slot-unbound ((a class-a) &rest foo)
+  (defmethod slot-unbound ((_a class-a) &rest _foo)
     "If a slot in A is unbound, ignore FOO."
     ;; Disable the old slot-unbound so we can run this test
     ;; more than once
diff --git a/test/lisp/emacs-lisp/generator-tests.el 
b/test/lisp/emacs-lisp/generator-tests.el
index 50b8cc5..492c4e4 100644
--- a/test/lisp/emacs-lisp/generator-tests.el
+++ b/test/lisp/emacs-lisp/generator-tests.el
@@ -74,7 +74,7 @@ identical output."
 (cps-testcase cps-prog1-b (prog1 1))
 (cps-testcase cps-prog1-c (prog2 1 2 3))
 (cps-testcase cps-quote (progn 'hello))
-(cps-testcase cps-function (progn #'hello))
+(cps-testcase cps-function (progn #'message))
 
 (cps-testcase cps-and-fail (and 1 nil 2))
 (cps-testcase cps-and-succeed (and 1 2 3))
@@ -307,6 +307,7 @@ identical output."
                                             (1+ it)))))))
                  -2)))
 
+(defun generator-tests-edebug ()) ; silence byte-compiler
 (ert-deftest generator-tests-edebug ()
   "Check that Bug#40434 is fixed."
   (with-temp-buffer
diff --git a/test/lisp/emacs-lisp/lisp-tests.el 
b/test/lisp/emacs-lisp/lisp-tests.el
index 8301d99..7f4d50c 100644
--- a/test/lisp/emacs-lisp/lisp-tests.el
+++ b/test/lisp/emacs-lisp/lisp-tests.el
@@ -213,6 +213,7 @@
     (should-error (forward-sexp)))) ;; FIXME: Shouldn't be an error.
 
 ;; Test some core Elisp rules.
+(defvar c-e-x)
 (ert-deftest core-elisp-tests-1-defvar-in-let ()
   "Test some core Elisp rules."
   (with-temp-buffer
diff --git a/test/lisp/emacs-lisp/seq-tests.el 
b/test/lisp/emacs-lisp/seq-tests.el
index 8dc0b93..8cfa3bd 100644
--- a/test/lisp/emacs-lisp/seq-tests.el
+++ b/test/lisp/emacs-lisp/seq-tests.el
@@ -172,17 +172,23 @@ Evaluate BODY for each created sequence.
   (should-not (seq-find #'null '(1 2 3)))
   (should (seq-find #'null '(1 2 3) 'sentinel)))
 
+;; Hack to work around the ERT limitation that we can't reliably use
+;; `with-suppressed-warnings' inside an `ert-deftest'.  (Bug#36568)
+(defun seq--contains (&rest args)
+  (with-suppressed-warnings ((obsolete seq-contains))
+    (apply #'seq-contains args)))
+
 (ert-deftest test-seq-contains ()
   (with-test-sequences (seq '(3 4 5 6))
-    (should (seq-contains seq 3))
-    (should-not (seq-contains seq 7)))
+    (should (seq--contains seq 3))
+    (should-not (seq--contains seq 7)))
   (with-test-sequences (seq '())
-    (should-not (seq-contains seq 3))
-    (should-not (seq-contains seq nil))))
+    (should-not (seq--contains seq 3))
+    (should-not (seq--contains seq nil))))
 
 (ert-deftest test-seq-contains-should-return-the-elt ()
   (with-test-sequences (seq '(3 4 5 6))
-    (should (= 5 (seq-contains seq 5)))))
+    (should (= 5 (seq--contains seq 5)))))
 
 (ert-deftest test-seq-contains-p ()
   (with-test-sequences (seq '(3 4 5 6))
@@ -404,7 +410,7 @@ Evaluate BODY for each created sequence.
   (let ((seq '(1 (2 (3 (4))))))
     (seq-let (_ (_ (_ (a)))) seq
       (should (= a 4))))
-  (let (seq)
+  (let ((seq nil))
     (seq-let (a b c) seq
       (should (null a))
       (should (null b))
@@ -428,7 +434,7 @@ Evaluate BODY for each created sequence.
         (seq '(1 (2 (3 (4))))))
     (seq-setq (_ (_ (_ (a)))) seq)
     (should (= a 4)))
-  (let (seq a b c)
+  (let ((seq nil) a b c)
     (seq-setq (a b c) seq)
     (should (null a))
     (should (null b))
diff --git a/test/lisp/emacs-lisp/subr-x-tests.el 
b/test/lisp/emacs-lisp/subr-x-tests.el
index 69d59e8..d836950 100644
--- a/test/lisp/emacs-lisp/subr-x-tests.el
+++ b/test/lisp/emacs-lisp/subr-x-tests.el
@@ -169,13 +169,13 @@
              "no")
            "no"))
   (should (equal
-           (let (z)
+           (let ((z nil))
              (if-let* (z (a 1) (b 2) (c 3))
                  "yes"
                "no"))
            "no"))
   (should (equal
-           (let (d)
+           (let ((d nil))
              (if-let* ((a 1) (b 2) (c 3) d)
                  "yes"
                "no"))
@@ -191,7 +191,7 @@
 
 (ert-deftest subr-x-test-if-let*-and-laziness-is-preserved ()
   "Test `if-let' respects `and' laziness."
-  (let (a-called b-called c-called)
+  (let ((a-called nil) (b-called nil) c-called)
     (should (equal
              (if-let* ((a nil)
                        (b (setq b-called t))
@@ -199,7 +199,7 @@
                  "yes"
                (list a-called b-called c-called))
              (list nil nil nil))))
-  (let (a-called b-called c-called)
+  (let ((a-called nil) (b-called nil) c-called)
     (should (equal
              (if-let* ((a (setq a-called t))
                        (b nil)
@@ -207,12 +207,12 @@
                  "yes"
                (list a-called b-called c-called))
              (list t nil nil))))
-  (let (a-called b-called c-called)
+  (let ((a-called nil) (b-called nil) c-called)
     (should (equal
              (if-let* ((a (setq a-called t))
-                      (b (setq b-called t))
-                      (c nil)
-                      (d (setq c-called t)))
+                       (b (setq b-called t))
+                       (c nil)
+                       (d (setq c-called t)))
                  "yes"
                (list a-called b-called c-called))
              (list t t nil)))))
@@ -329,12 +329,12 @@
              "no")
            nil))
   (should (equal
-           (let (z)
+           (let ((z nil))
              (when-let* (z (a 1) (b 2) (c 3))
                "no"))
            nil))
   (should (equal
-           (let (d)
+           (let ((d nil))
              (when-let* ((a 1) (b 2) (c 3) d)
                "no"))
            nil)))
@@ -348,7 +348,7 @@
 
 (ert-deftest subr-x-test-when-let*-and-laziness-is-preserved ()
   "Test `when-let' respects `and' laziness."
-  (let (a-called b-called c-called)
+  (let ((a-called nil) (b-called nil) (c-called nil))
     (should (equal
              (progn
                (when-let* ((a nil)
@@ -357,7 +357,7 @@
                  "yes")
                (list a-called b-called c-called))
              (list nil nil nil))))
-  (let (a-called b-called c-called)
+  (let ((a-called nil) (b-called nil) (c-called nil))
     (should (equal
              (progn
                (when-let* ((a (setq a-called t))
@@ -366,7 +366,7 @@
                  "yes")
                (list a-called b-called c-called))
              (list t nil nil))))
-  (let (a-called b-called c-called)
+  (let ((a-called nil) (b-called nil) (c-called nil))
     (should (equal
              (progn
                (when-let* ((a (setq a-called t))
diff --git a/test/lisp/emacs-lisp/timer-tests.el 
b/test/lisp/emacs-lisp/timer-tests.el
index 7856c21..0f5b1a7 100644
--- a/test/lisp/emacs-lisp/timer-tests.el
+++ b/test/lisp/emacs-lisp/timer-tests.el
@@ -37,7 +37,8 @@
 (ert-deftest timer-tests-debug-timer-check ()
   ;; This function exists only if --enable-checking.
   (skip-unless (fboundp 'debug-timer-check))
-  (should (debug-timer-check)))
+  (when (fboundp 'debug-timer-check)    ; silence byte-compiler
+    (should (debug-timer-check))))
 
 (ert-deftest timer-test-multiple-of-time ()
   (should (time-equal-p
diff --git a/test/lisp/format-spec-tests.el b/test/lisp/format-spec-tests.el
index ff2abde..3c6fa54 100644
--- a/test/lisp/format-spec-tests.el
+++ b/test/lisp/format-spec-tests.el
@@ -56,7 +56,7 @@
 
 (ert-deftest format-spec-do-flags-truncate ()
   "Test `format-spec--do-flags' truncation."
-  (let (flags)
+  (let ((flags nil))
     (should (equal (format-spec--do-flags "" flags nil 0) ""))
     (should (equal (format-spec--do-flags "" flags nil 1) ""))
     (should (equal (format-spec--do-flags "a" flags nil 0) ""))
@@ -75,7 +75,7 @@
 
 (ert-deftest format-spec-do-flags-pad ()
   "Test `format-spec--do-flags' padding."
-  (let (flags)
+  (let ((flags nil))
     (should (equal (format-spec--do-flags "" flags 0 nil) ""))
     (should (equal (format-spec--do-flags "" flags 1 nil) " "))
     (should (equal (format-spec--do-flags "a" flags 0 nil) "a"))
diff --git a/test/lisp/ls-lisp-tests.el b/test/lisp/ls-lisp-tests.el
index e3a75be..9f2c632 100644
--- a/test/lisp/ls-lisp-tests.el
+++ b/test/lisp/ls-lisp-tests.el
@@ -54,7 +54,8 @@
           (kill-buffer buf)
           (setq buf (dired (nconc (list dir) files)))
           (should (looking-at "src"))
-          (next-line) ; File names must be aligned.
+          (with-suppressed-warnings ((interactive-only next-line))
+            (next-line)) ; File names must be aligned.
           (should (looking-at "src")))
       (when (buffer-live-p buf) (kill-buffer buf)))))
 
diff --git a/test/lisp/obsolete/cl-tests.el b/test/lisp/obsolete/cl-tests.el
index 0e02e1c..0b8c117 100644
--- a/test/lisp/obsolete/cl-tests.el
+++ b/test/lisp/obsolete/cl-tests.el
@@ -27,10 +27,15 @@
 
 
 
+;; Hack to work around the ERT limitation that we can't reliably use
+;; `with-suppressed-warnings' inside an `ert-deftest'.  (Bug#36568)
+(defun cl-tests-labels-test ()
+  (with-suppressed-warnings ((obsolete labels))
+    (funcall (labels ((foo () t))
+                     #'foo))))
+
 (ert-deftest labels-function-quoting ()
   "Test that #'foo does the right thing in `labels'." ; Bug#31792.
-  (should (eq (funcall (labels ((foo () t))
-                         #'foo))
-              t)))
+  (should (eq (cl-tests-labels-test) t)))
 
 ;;; cl-tests.el ends here
diff --git a/test/lisp/progmodes/elisp-mode-tests.el 
b/test/lisp/progmodes/elisp-mode-tests.el
index 63bae79..9dc5e8c 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -438,7 +438,8 @@ to (xref-elisp-test-descr-to-target xref)."
 ;; track down the problem.
 (cl-defmethod xref-elisp-generic-no-default ((this xref-elisp-root-type) arg2)
   "Doc string generic no-default xref-elisp-root-type."
-  "non-default for no-default")
+  "non-default for no-default"
+  (list this arg2)) ; silence byte-compiler
 
 ;; defgeneric after defmethod in file to ensure the fallback search
 ;; method of just looking for the function name will fail.
@@ -463,19 +464,23 @@ to (xref-elisp-test-descr-to-target xref)."
 
 (cl-defmethod xref-elisp-generic-separate-default (arg1 arg2)
   "Doc string generic separate-default default."
-  "separate default")
+  "separate default"
+  (list arg1 arg2)) ; silence byte-compiler
 
 (cl-defmethod xref-elisp-generic-separate-default ((this xref-elisp-root-type) 
arg2)
   "Doc string generic separate-default xref-elisp-root-type."
-  "non-default for separate-default")
+  "non-default for separate-default"
+  (list this arg2)) ; silence byte-compiler
 
 (cl-defmethod xref-elisp-generic-implicit-generic (arg1 arg2)
   "Doc string generic implicit-generic default."
-  "default for implicit generic")
+  "default for implicit generic"
+  (list arg1 arg2)) ; silence byte-compiler
 
 (cl-defmethod xref-elisp-generic-implicit-generic ((this xref-elisp-root-type) 
arg2)
   "Doc string generic implicit-generic xref-elisp-root-type."
-  "non-default for implicit generic")
+  "non-default for implicit generic"
+  (list this arg2)) ; silence byte-compiler
 
 
 (xref-elisp-deftest find-defs-defgeneric-no-methods
@@ -845,7 +850,8 @@ to (xref-elisp-test-descr-to-target xref)."
     (if (stringp form)
         (insert form)
       (pp form (current-buffer)))
-    (font-lock-debug-fontify)
+    (with-suppressed-warnings ((interactive-only font-lock-debug-fontify))
+      (font-lock-debug-fontify))
     (goto-char (point-min))
     (and (re-search-forward search nil t)
          (get-text-property (match-beginning 1) 'face))))
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index 7f62a41..dcd5ebb 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -599,11 +599,12 @@ bound to HIGHLIGHT-LOCUS."
     (with-temp-buffer
       (insert before)
       (goto-char (point-min))
-      (replace-regexp
-       "\\(\\(L\\)\\|\\(R\\)\\)"
-       '(replace-eval-replacement
-         replace-quote
-         (if (match-string 2) "R" "L")))
+      (with-suppressed-warnings ((interactive-only replace-regexp))
+        (replace-regexp
+         "\\(\\(L\\)\\|\\(R\\)\\)"
+         '(replace-eval-replacement
+           replace-quote
+           (if (match-string 2) "R" "L"))))
       (should (equal (buffer-string) after)))))
 
 (ert-deftest test-count-matches ()
diff --git a/test/lisp/ses-tests.el b/test/lisp/ses-tests.el
index 9a7fb50..932291a 100644
--- a/test/lisp/ses-tests.el
+++ b/test/lisp/ses-tests.el
@@ -24,6 +24,10 @@
 (require 'ert)
 (require 'ses)
 
+;; Silence byte-compiler.
+(with-suppressed-warnings ((lexical A2) (lexical A3))
+  (defvar A2)
+  (defvar A3))
 
 ;; PLAIN FORMULA TESTS
 ;; ======================================================================
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index e02de95..063c6fe 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -926,6 +926,7 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350.";
   (should-not (apropos-internal "^next-line$" #'keymapp)))
 
 
+(defvar test-global-boundp)
 (ert-deftest test-buffer-local-boundp ()
   (let ((buf (generate-new-buffer "boundp")))
     (with-current-buffer buf
diff --git a/test/lisp/tar-mode-tests.el b/test/lisp/tar-mode-tests.el
index 6964d42..dd430ca 100644
--- a/test/lisp/tar-mode-tests.el
+++ b/test/lisp/tar-mode-tests.el
@@ -24,6 +24,12 @@
 (defvar tar-mode-tests-data-directory
   (expand-file-name "test/data/decompress" source-directory))
 
+;; Hack to work around the ERT limitation that we can't reliably use
+;; `with-suppressed-warnings' inside an `ert-deftest'.  (Bug#36568)
+(defun tar-mode-tests--tar-grind-file-mode (&rest args)
+  (with-suppressed-warnings ((obsolete tar-grind-file-mode))
+    (apply #'tar-grind-file-mode args)))
+
 (ert-deftest tar-mode-test-tar-grind-file-mode ()
   (let ((alist (list (cons 448 "rwx------")
                      (cons 420 "rw-r--r--")
@@ -32,7 +38,7 @@
                      (cons 1024 "-----S---")
                      (cons 2048 "--S------"))))
     (dolist (x alist)
-      (should (equal (cdr x) (tar-grind-file-mode (car x)))))))
+      (should (equal (cdr x) (tar-mode-tests--tar-grind-file-mode (car x)))))))
 
 (ert-deftest tar-mode-test-tar-extract-gz ()
   (skip-unless (executable-find "gzip"))
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index dfc1273..8cc271b 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -433,26 +433,27 @@ comparing the subr with a much slower Lisp 
implementation."
   ;; More specifically, test the problem seen in bug#41029 where setting
   ;; the default value of a variable takes time proportional to the
   ;; number of buffers.
-  (let* ((fun #'error)
-         (test (lambda ()
-                 (with-temp-buffer
-                   (let ((st (car (current-cpu-time))))
-                     (dotimes (_ 1000)
-                       (let ((case-fold-search 'data-test))
-                         ;; Use an indirection through a mutable var
-                         ;; to try and make sure the byte-compiler
-                         ;; doesn't optimize away the let bindings.
-                         (funcall fun)))
-                     ;; FIXME: Handle the wraparound, if any.
-                     (- (car (current-cpu-time)) st)))))
-         (_ (setq fun #'ignore))
-         (time1 (funcall test))
-         (bufs (mapcar (lambda (_) (generate-new-buffer " data-test"))
-                       (make-list 1000 nil)))
-         (time2 (funcall test)))
-    (mapc #'kill-buffer bufs)
-    ;; Don't divide one time by the other since they may be 0.
-    (should (< time2 (* time1 5)))))
+  (when (fboundp 'current-cpu-time)     ; silence byte-compiler
+    (let* ((fun #'error)
+           (test (lambda ()
+                   (with-temp-buffer
+                     (let ((st (car (current-cpu-time))))
+                       (dotimes (_ 1000)
+                         (let ((case-fold-search 'data-test))
+                           ;; Use an indirection through a mutable var
+                           ;; to try and make sure the byte-compiler
+                           ;; doesn't optimize away the let bindings.
+                           (funcall fun)))
+                       ;; FIXME: Handle the wraparound, if any.
+                       (- (car (current-cpu-time)) st)))))
+           (_ (setq fun #'ignore))
+           (time1 (funcall test))
+           (bufs (mapcar (lambda (_) (generate-new-buffer " data-test"))
+                         (make-list 1000 nil)))
+           (time2 (funcall test)))
+      (mapc #'kill-buffer bufs)
+      ;; Don't divide one time by the other since they may be 0.
+      (should (< time2 (* time1 5))))))
 
 ;; More tests to write -
 ;; kill-local-variable
diff --git a/test/src/search-tests.el b/test/src/search-tests.el
index b7b4ab9..b5f4730 100644
--- a/test/src/search-tests.el
+++ b/test/src/search-tests.el
@@ -28,7 +28,7 @@
       (setq ov-set (make-overlay 3 5))
       (overlay-put
        ov-set 'modification-hooks
-       (list (lambda (o after &rest _args)
+       (list (lambda (_o after &rest _args)
               (when after
                 (let ((inhibit-modification-hooks t))
                   (save-excursion



reply via email to

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