From e1902ac6182b156efaaf93013a707abb4b627765 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sat, 23 Jan 2021 23:31:13 +0000 Subject: [PATCH] Fix recently uncovered 'make check' failures For discussion, see the following thread: https://lists.gnu.org/r/emacs-devel/2021-01/msg01111.html * test/lisp/autorevert-tests.el (auto-revert-test07-auto-revert-several-buffers): * test/lisp/emacs-lisp/seq-tests.el (test-seq-do-indexed) (test-seq-random-elt-take-all): Fix errors from using add-to-list on lexical variables. * test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-defstruct-record): Expect test to succeed when byte-compiled following change of 2021-01-23 'Fix missing file&line info in "Unknown defun property" warnings'. (cl-lib-tests--dummy-function): Remove; no longer needed. (old-struct): Silence byte-compiler warning about unused lexical variable. --- test/lisp/autorevert-tests.el | 19 ++++++++++--------- test/lisp/emacs-lisp/cl-lib-tests.el | 9 +-------- test/lisp/emacs-lisp/seq-tests.el | 23 ++++++++++------------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el index 683e3ea30d4..45cf6353960 100644 --- a/test/lisp/autorevert-tests.el +++ b/test/lisp/autorevert-tests.el @@ -609,11 +609,12 @@ This expects `auto-revert--messages' to be bound by (should auto-revert-mode)) (dotimes (i num-buffers) - (add-to-list - 'buffers - (make-indirect-buffer - (car buffers) (format "%s-%d" (buffer-file-name (car buffers)) i) 'clone) - 'append)) + (push (make-indirect-buffer + (car buffers) + (format "%s-%d" (buffer-file-name (car buffers)) i) + 'clone) + buffers)) + (setq buffers (nreverse buffers)) (dolist (buf buffers) (with-current-buffer buf (should (string-equal (buffer-string) "any text")) @@ -640,10 +641,10 @@ This expects `auto-revert--messages' to be bound by (auto-revert-tests--write-file "any text" tmpfile (pop times)) (dotimes (i num-buffers) - (add-to-list - 'buffers - (generate-new-buffer (format "%s-%d" (file-name-nondirectory tmpfile) i)) - 'append)) + (push (generate-new-buffer + (format "%s-%d" (file-name-nondirectory tmpfile) i)) + buffers)) + (setq buffers (nreverse buffers)) (dolist (buf buffers) (with-current-buffer buf (insert-file-contents tmpfile 'visit) diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index 97a44c43ef7..065ca4fa651 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -543,15 +543,7 @@ (apply (lambda (x) (+ x 1)) (list 8))))) '(5 (6 5) (6 6) 9)))) -(defun cl-lib-tests--dummy-function () - ;; Dummy function to see if the file is compiled. - t) - (ert-deftest cl-lib-defstruct-record () - ;; This test fails when compiled, see Bug#24402/27718. - :expected-result (if (byte-code-function-p - (symbol-function 'cl-lib-tests--dummy-function)) - :failed :passed) (cl-defstruct foo x) (let ((x (make-foo :x 42))) (should (recordp x)) @@ -566,6 +558,7 @@ (should (eq (type-of x) 'vector)) (cl-old-struct-compat-mode 1) + (defvar cl-struct-foo) (let ((cl-struct-foo (cl--struct-get-class 'foo))) (setf (symbol-function 'cl-struct-foo) :quick-object-witness-check) (should (eq (type-of x) 'foo)) diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index 670398354a6..05c7fbe781e 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -29,6 +29,9 @@ (require 'ert) (require 'seq) +(eval-when-compile + (require 'cl-lib)) + (defmacro with-test-sequences (spec &rest body) "Successively bind VAR to a list, vector, and string built from SEQ. Evaluate BODY for each created sequence. @@ -108,16 +111,12 @@ Evaluate BODY for each created sequence. '((a 0) (b 1) (c 2) (d 3))))) (ert-deftest test-seq-do-indexed () - (let ((result nil)) - (seq-do-indexed (lambda (elt i) - (add-to-list 'result (list elt i))) - nil) - (should (equal result nil))) + (let (result) + (seq-do-indexed (lambda (elt i) (push (list elt i) result)) ()) + (should-not result)) (with-test-sequences (seq '(4 5 6)) - (let ((result nil)) - (seq-do-indexed (lambda (elt i) - (add-to-list 'result (list elt i))) - seq) + (let (result) + (seq-do-indexed (lambda (elt i) (push (list elt i) result)) seq) (should (equal (seq-elt result 0) '(6 2))) (should (equal (seq-elt result 1) '(5 1))) (should (equal (seq-elt result 2) '(4 0)))))) @@ -410,12 +409,10 @@ Evaluate BODY for each created sequence. (ert-deftest test-seq-random-elt-take-all () (let ((seq '(a b c d e)) - (elts '())) - (should (= 0 (length elts))) + elts) (dotimes (_ 1000) (let ((random-elt (seq-random-elt seq))) - (add-to-list 'elts - random-elt))) + (cl-pushnew random-elt elts))) (should (= 5 (length elts))))) (ert-deftest test-seq-random-elt-signal-on-empty () -- 2.39.2