diff options
author | Philip Kaludercic <philipk@posteo.net> | 2022-10-18 21:53:25 +0200 |
---|---|---|
committer | Philip Kaludercic <philipk@posteo.net> | 2022-10-18 21:53:25 +0200 |
commit | 65fa87329ce577d1ee907c0716b48aac8c0d7d27 (patch) | |
tree | 9593429442e7e4fa4f522a9b62a102d9c1cf3fed /test/lisp/emacs-lisp | |
parent | 5ceb88e6ebf14cee3f97b0c7b8557e4b1e23de5b (diff) | |
parent | ab1b491f8373742a051aaf554c4604f2b976b414 (diff) | |
download | emacs-65fa87329ce577d1ee907c0716b48aac8c0d7d27.tar.gz emacs-65fa87329ce577d1ee907c0716b48aac8c0d7d27.tar.bz2 emacs-65fa87329ce577d1ee907c0716b48aac8c0d7d27.zip |
Merge remote-tracking branch 'origin/master' into feature/package+vc
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/cl-generic-tests.el | 22 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/comp-tests.el | 77 |
2 files changed, 99 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/cl-generic-tests.el b/test/lisp/emacs-lisp/cl-generic-tests.el index 56b766769ea..8e807b15915 100644 --- a/test/lisp/emacs-lisp/cl-generic-tests.el +++ b/test/lisp/emacs-lisp/cl-generic-tests.el @@ -297,5 +297,27 @@ Edebug symbols (Bug#42672)." (intern "cl-defgeneric/edebug/method/2 (number)") 'cl-defgeneric/edebug/method/2)))))) +(cl-defgeneric cl-generic-tests--acc (x &optional y) + (declare (advertised-calling-convention (x) "671.2"))) + +(cl-defmethod cl-generic-tests--acc ((x float)) (+ x 5.0)) + +(ert-deftest cl-generic-tests--advertised-calling-convention-bug58563 () + (should (equal (get-advertised-calling-convention + (indirect-function 'cl-generic-tests--acc)) + '(x))) + (should + (condition-case err + (let ((lexical-binding t) + (byte-compile-debug t) + (byte-compile-error-on-warn t)) + (byte-compile '(cl-defmethod cl-generic-tests--acc ((x list)) + (declare (advertised-calling-convention (y) "1.1")) + (cons x '(5 5 5 5 5)))) + nil) + (error + (and (eq 'error (car err)) + (string-match "Stray.*declare" (cadr err))))))) + (provide 'cl-generic-tests) ;;; cl-generic-tests.el ends here diff --git a/test/lisp/emacs-lisp/comp-tests.el b/test/lisp/emacs-lisp/comp-tests.el new file mode 100644 index 00000000000..082b641fe30 --- /dev/null +++ b/test/lisp/emacs-lisp/comp-tests.el @@ -0,0 +1,77 @@ +;;; comp-tests.el --- Tests for comp.el -*- lexical-binding:t -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'ert-x) +(require 'comp) + +(defvar comp-native-version-dir) +(defvar native-comp-eln-load-path) + +(defmacro with-test-native-compile-prune-cache (&rest body) + (declare (indent 0) (debug t)) + `(ert-with-temp-directory testdir + (setq testdir (expand-file-name "eln-cache" testdir)) + (make-directory testdir) + (let* ((c1 (expand-file-name "29.0.50-cur" testdir)) + (c2 (expand-file-name "29.0.50-old" testdir)) + (native-comp-eln-load-path (list testdir)) + (comp-native-version-dir "29.0.50-cur")) + (dolist (d (list c1 c2)) + (make-directory d) + (with-temp-file (expand-file-name "some.eln" d) (insert "foo")) + (with-temp-file (expand-file-name "some.eln.tmp" d) (insert "foo"))) + ,@body))) + +(ert-deftest test-native-compile-prune-cache () + (skip-unless (featurep 'native-compile)) + (with-test-native-compile-prune-cache + (native-compile-prune-cache) + (should (file-directory-p c1)) + (should (file-regular-p (expand-file-name "some.eln" c1))) + (should (file-regular-p (expand-file-name "some.eln.tmp" c1))) + (should-not (file-directory-p c2)) + (should-not (file-regular-p (expand-file-name "some.eln" c2))) + (should-not (file-regular-p (expand-file-name "some.eln.tmp" c2))))) + +(ert-deftest test-native-compile-prune-cache/delete-only-eln () + (skip-unless (featurep 'native-compile)) + (with-test-native-compile-prune-cache + (with-temp-file (expand-file-name "keep1.txt" c1) (insert "foo")) + (with-temp-file (expand-file-name "keep2.txt" c2) (insert "foo")) + (native-compile-prune-cache) + (should (file-regular-p (expand-file-name "keep1.txt" c1))) + (should (file-regular-p (expand-file-name "keep2.txt" c2))))) + +(ert-deftest test-native-compile-prune-cache/dont-delete-in-parent-of-cache () + (skip-unless (featurep 'native-compile)) + (with-test-native-compile-prune-cache + (let ((f1 (expand-file-name "../some.eln" testdir)) + (f2 (expand-file-name "some.eln" testdir))) + (with-temp-file f1 (insert "foo")) + (with-temp-file f2 (insert "foo")) + (native-compile-prune-cache) + (should (file-regular-p f1)) + (should (file-regular-p f2))))) + +;;; comp-tests.el ends here |