]> git.eshelyaron.com Git - emacs.git/commitdiff
Add tests for some byte-compiler warnings
authorStefan Kangas <stefan@marxist.se>
Tue, 1 Dec 2020 03:46:33 +0000 (04:46 +0100)
committerStefan Kangas <stefan@marxist.se>
Tue, 1 Dec 2020 03:49:10 +0000 (04:49 +0100)
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-warn/warn-interactive-only\.el)
(bytecomp-warn/warn-obsolete-defun\.el)
(bytecomp-warn/warn-obsolete-hook\.el)
(bytecomp-warn/warn-obsolete-variable-same-file\.el)
(bytecomp-warn/warn-obsolete-variable\.el): New tests.
* test/lisp/emacs-lisp/bytecomp-resources/warn-interactive-only.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-defun.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-hook.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-same-file.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable.el:
New files.

test/lisp/emacs-lisp/bytecomp-resources/warn-interactive-only.el [new file with mode: 0644]
test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-defun.el [new file with mode: 0644]
test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-hook.el [new file with mode: 0644]
test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-same-file.el [new file with mode: 0644]
test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable.el [new file with mode: 0644]
test/lisp/emacs-lisp/bytecomp-tests.el

diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-interactive-only.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-interactive-only.el
new file mode 100644 (file)
index 0000000..9e0c99b
--- /dev/null
@@ -0,0 +1,3 @@
+;;; -*- lexical-binding: t -*-
+(defun foo ()
+  (next-line))
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-defun.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-defun.el
new file mode 100644 (file)
index 0000000..2a7af61
--- /dev/null
@@ -0,0 +1,8 @@
+;;; -*- lexical-binding: t -*-
+
+(defun foo-obsolete ()
+  (declare (obsolete nil "99.99"))
+  nil)
+
+(defun foo ()
+  (foo-obsolete))
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-hook.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-hook.el
new file mode 100644 (file)
index 0000000..078e6e4
--- /dev/null
@@ -0,0 +1,3 @@
+;;; -*- lexical-binding: t -*-
+(defun foo ()
+  (add-hook 'bytecomp--tests-obsolete-var #'next-line))
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-same-file.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-same-file.el
new file mode 100644 (file)
index 0000000..31deb61
--- /dev/null
@@ -0,0 +1,13 @@
+;;; -*- lexical-binding: t -*-
+
+(defvar foo-obsolete nil)
+(make-obsolete-variable 'foo-obsolete nil "99.99")
+
+;; From bytecomp.el:
+;; If foo.el declares `toto' as obsolete, it is likely that foo.el will
+;; actually use `toto' in order for this obsolete variable to still work
+;; correctly, so paradoxically, while byte-compiling foo.el, the presence
+;; of a make-obsolete-variable call for `toto' is an indication that `toto'
+;; should not trigger obsolete-warnings in foo.el.
+(defun foo ()
+  foo-obsolete)
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable.el
new file mode 100644 (file)
index 0000000..9a517cc
--- /dev/null
@@ -0,0 +1,4 @@
+;;; -*- lexical-binding: t -*-
+
+(defun foo ()
+  bytecomp--tests-obsolete-var)
index c9070c03b3fdde308f6fe0e8268b0d5b9706c18c..bea9663d24112f843b62fb44f70676243a27ebb2 100644 (file)
@@ -560,6 +560,24 @@ Subtests signal errors if something goes wrong."
 
 (bytecomp--define-warning-file-test "warn-free-variable-reference.el" "free.*bar")
 
+(bytecomp--define-warning-file-test "warn-obsolete-defun.el"
+                            "foo-obsolete.*obsolete function.*99.99")
+
+(defvar bytecomp--tests-obsolete-var nil)
+(make-obsolete-variable 'bytecomp--tests-obsolete-var nil "99.99")
+
+(bytecomp--define-warning-file-test "warn-obsolete-hook.el"
+                            "bytecomp--tests-obs.*obsolete.*99.99")
+
+(bytecomp--define-warning-file-test "warn-obsolete-variable-same-file.el"
+                            "foo-obs.*obsolete.*99.99" t)
+
+(bytecomp--define-warning-file-test "warn-obsolete-variable.el"
+                            "bytecomp--tests-obs.*obsolete.*99.99")
+
+(bytecomp--define-warning-file-test "warn-interactive-only.el"
+                            "next-line.*interactive use only.*forward-line")
+
 (ert-deftest test-eager-load-macro-expansion-eval-when-compile ()
   ;; Make sure we interpret eval-when-compile forms properly.  CLISP
   ;; and SBCL interpreter eval-when-compile (well, the CL equivalent)