((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))
(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
#'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))
(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 ()
;; Check that generic-p works
(should (generic-p 'generic1))
- (defmethod generic1 ((c class-a))
+ (defmethod generic1 ((_c class-a))
"Method on generic1."
'monkey)
(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)
;; 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."
;; 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))
(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)
;;
(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))
(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)
(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)
(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
(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))
(1+ it)))))))
-2)))
+(defun generator-tests-edebug ()) ; silence byte-compiler
(ert-deftest generator-tests-edebug ()
"Check that Bug#40434 is fixed."
(with-temp-buffer
(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
(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))
(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))
(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))
"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"))
(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))
"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)
"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)))))
"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)))
(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)
"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))
"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))
(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
(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) ""))
(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"))
(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)))))
\f
+;; 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
;; 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.
(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
(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))))
(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 ()
(require 'ert)
(require 'ses)
+;; Silence byte-compiler.
+(with-suppressed-warnings ((lexical A2) (lexical A3))
+ (defvar A2)
+ (defvar A3))
;; PLAIN FORMULA TESTS
;; ======================================================================
(should-not (apropos-internal "^next-line$" #'keymapp)))
\f
+(defvar test-global-boundp)
(ert-deftest test-buffer-local-boundp ()
(let ((buf (generate-new-buffer "boundp")))
(with-current-buffer buf
(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--")
(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"))
;; 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
(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