diff options
| author | dickmao | 2021-11-07 01:28:47 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-11-07 01:28:47 +0100 |
| commit | 9dfd945a2c2055b1af869a685eb2a667daf4daca (patch) | |
| tree | ccfe862dca7223dafd9921c5743686f623c0e41b /test | |
| parent | 55fa6a2655972017c692b515b8c476bb9705747d (diff) | |
| download | emacs-9dfd945a2c2055b1af869a685eb2a667daf4daca.tar.gz emacs-9dfd945a2c2055b1af869a685eb2a667daf4daca.zip | |
Fix byte compilation of package built-ins
* lisp/emacs-lisp/package.el
(package--activate-autoloads-and-load-path):
(package--load-files-for-activation): Remove.
(package--library-stem): New function, because
file-name-sans-extension is insufficient.
(package--reload-previously-loaded): New function.
(package-activate-1): Reload directly.
(package--files-load-history):
(package--list-of-conflicts):
(package--list-loaded-files): Remove
(package-unpack): Adjust call.
* test/lisp/emacs-lisp/package-tests.el (macro-builtin-func): Test.
(macro-builtin-10-and-90): Test.
(package-test-macro-compilation): Test.
(package-test-macro-compilation-gz): Test (bug#49708).
Diffstat (limited to 'test')
5 files changed, 110 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/package-resources/macro-builtin-package-1.0/macro-builtin-aux.el b/test/lisp/emacs-lisp/package-resources/macro-builtin-package-1.0/macro-builtin-aux.el new file mode 100644 index 00000000000..724f88ec9ea --- /dev/null +++ b/test/lisp/emacs-lisp/package-resources/macro-builtin-package-1.0/macro-builtin-aux.el | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | ;;; macro-builtin-aux.el --- laksd -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Author: Artur Malabarba <emacs@endlessparentheses.com> | ||
| 4 | |||
| 5 | ;;; Code: | ||
| 6 | |||
| 7 | (defun macro-builtin-aux-1 ( &rest forms) | ||
| 8 | "Description" | ||
| 9 | `(progn ,@forms)) | ||
| 10 | |||
| 11 | (provide 'macro-builtin-aux) | ||
| 12 | ;;; macro-builtin-aux.el ends here | ||
diff --git a/test/lisp/emacs-lisp/package-resources/macro-builtin-package-1.0/macro-builtin.el b/test/lisp/emacs-lisp/package-resources/macro-builtin-package-1.0/macro-builtin.el new file mode 100644 index 00000000000..828968a0576 --- /dev/null +++ b/test/lisp/emacs-lisp/package-resources/macro-builtin-package-1.0/macro-builtin.el | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | ;;; macro-builtin.el --- laksd -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Author: Artur Malabarba <emacs@endlessparentheses.com> | ||
| 4 | ;; Keywords: tools | ||
| 5 | ;; Version: 1.0 | ||
| 6 | |||
| 7 | ;;; Code: | ||
| 8 | |||
| 9 | (require 'macro-builtin-aux) | ||
| 10 | |||
| 11 | (defmacro macro-builtin-1 ( &rest forms) | ||
| 12 | "Description" | ||
| 13 | `(progn ,@forms)) | ||
| 14 | |||
| 15 | (defun macro-builtin-func () | ||
| 16 | "" | ||
| 17 | (macro-builtin-1 'a 'b) | ||
| 18 | (macro-builtin-aux-1 'a 'b)) | ||
| 19 | |||
| 20 | (provide 'macro-builtin) | ||
| 21 | ;;; macro-builtin.el ends here | ||
diff --git a/test/lisp/emacs-lisp/package-resources/macro-builtin-package-2.0/macro-builtin-aux.el b/test/lisp/emacs-lisp/package-resources/macro-builtin-package-2.0/macro-builtin-aux.el new file mode 100644 index 00000000000..9f257d9d22c --- /dev/null +++ b/test/lisp/emacs-lisp/package-resources/macro-builtin-package-2.0/macro-builtin-aux.el | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | ;;; macro-builtin-aux.el --- laksd -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Author: Artur Malabarba <emacs@endlessparentheses.com> | ||
| 4 | |||
| 5 | ;;; Code: | ||
| 6 | |||
| 7 | (defmacro macro-builtin-aux-1 ( &rest forms) | ||
| 8 | "Description" | ||
| 9 | `(progn ,@forms)) | ||
| 10 | |||
| 11 | (defmacro macro-builtin-aux-3 ( &rest _) | ||
| 12 | "Description" | ||
| 13 | 90) | ||
| 14 | |||
| 15 | (provide 'macro-builtin-aux) | ||
| 16 | ;;; macro-builtin-aux.el ends here | ||
diff --git a/test/lisp/emacs-lisp/package-resources/macro-builtin-package-2.0/macro-builtin.el b/test/lisp/emacs-lisp/package-resources/macro-builtin-package-2.0/macro-builtin.el new file mode 100644 index 00000000000..5d241c082d0 --- /dev/null +++ b/test/lisp/emacs-lisp/package-resources/macro-builtin-package-2.0/macro-builtin.el | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | ;;; macro-builtin.el --- laksd -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Author: Artur Malabarba <emacs@endlessparentheses.com> | ||
| 4 | ;; Keywords: tools | ||
| 5 | ;; Version: 2.0 | ||
| 6 | |||
| 7 | ;;; Code: | ||
| 8 | |||
| 9 | (require 'macro-builtin-aux) | ||
| 10 | |||
| 11 | (defmacro macro-builtin-1 ( &rest forms) | ||
| 12 | "Description" | ||
| 13 | `(progn ,(cadr (car forms)))) | ||
| 14 | |||
| 15 | |||
| 16 | (defun macro-builtin-func () | ||
| 17 | "" | ||
| 18 | (list (macro-builtin-1 '1 'b) | ||
| 19 | (macro-builtin-aux-1 'a 'b))) | ||
| 20 | |||
| 21 | (defmacro macro-builtin-3 (&rest _) | ||
| 22 | "Description" | ||
| 23 | 10) | ||
| 24 | |||
| 25 | (defun macro-builtin-10-and-90 () | ||
| 26 | "" | ||
| 27 | (list (macro-builtin-3 haha) (macro-builtin-aux-3 hehe))) | ||
| 28 | |||
| 29 | (provide 'macro-builtin) | ||
| 30 | ;;; macro-builtin.el ends here | ||
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el index 1fd93bc1be7..c038c91e6a9 100644 --- a/test/lisp/emacs-lisp/package-tests.el +++ b/test/lisp/emacs-lisp/package-tests.el | |||
| @@ -342,9 +342,13 @@ but with a different end of line convention (bug#48137)." | |||
| 342 | 342 | ||
| 343 | (declare-function macro-problem-func "macro-problem" ()) | 343 | (declare-function macro-problem-func "macro-problem" ()) |
| 344 | (declare-function macro-problem-10-and-90 "macro-problem" ()) | 344 | (declare-function macro-problem-10-and-90 "macro-problem" ()) |
| 345 | (declare-function macro-builtin-func "macro-builtin" ()) | ||
| 346 | (declare-function macro-builtin-10-and-90 "macro-builtin" ()) | ||
| 345 | 347 | ||
| 346 | (ert-deftest package-test-macro-compilation () | 348 | (ert-deftest package-test-macro-compilation () |
| 347 | "Install a package which includes a dependency." | 349 | "\"Activation has to be done before compilation, so that if we're |
| 350 | upgrading and macros have changed we load the new definitions | ||
| 351 | before compiling.\" -- package.el" | ||
| 348 | (with-package-test (:basedir (ert-resource-directory)) | 352 | (with-package-test (:basedir (ert-resource-directory)) |
| 349 | (package-install-file (expand-file-name "macro-problem-package-1.0/")) | 353 | (package-install-file (expand-file-name "macro-problem-package-1.0/")) |
| 350 | (require 'macro-problem) | 354 | (require 'macro-problem) |
| @@ -357,6 +361,32 @@ but with a different end of line convention (bug#48137)." | |||
| 357 | ;; `macro-problem-10-and-90' depends on an entirely new macro from `macro-aux'. | 361 | ;; `macro-problem-10-and-90' depends on an entirely new macro from `macro-aux'. |
| 358 | (should (equal (macro-problem-10-and-90) '(10 90))))) | 362 | (should (equal (macro-problem-10-and-90) '(10 90))))) |
| 359 | 363 | ||
| 364 | (ert-deftest package-test-macro-compilation-gz () | ||
| 365 | "Built-in's can be superseded as well." | ||
| 366 | (with-package-test (:basedir (ert-resource-directory)) | ||
| 367 | (let ((dir (expand-file-name "macro-builtin-package-1.0"))) | ||
| 368 | (unwind-protect | ||
| 369 | (let ((load-path load-path)) | ||
| 370 | (add-to-list 'load-path (directory-file-name dir)) | ||
| 371 | (byte-recompile-directory dir 0 t) | ||
| 372 | (mapc (lambda (f) (rename-file f (concat f ".gz"))) | ||
| 373 | (directory-files-recursively dir "\\`[^\\.].*\\.el\\'")) | ||
| 374 | (require 'macro-builtin) | ||
| 375 | (should (member (expand-file-name "macro-builtin-aux.elc" dir) | ||
| 376 | (mapcar #'car load-history))) | ||
| 377 | ;; `macro-builtin-func' uses a macro from `macro-aux'. | ||
| 378 | (should (equal (macro-builtin-func) '(progn a b))) | ||
| 379 | (package-install-file (expand-file-name "macro-builtin-package-2.0/")) | ||
| 380 | ;; After upgrading, `macro-builtin-func' depends on a new version | ||
| 381 | ;; of the macro from `macro-builtin-aux'. | ||
| 382 | (should (equal (macro-builtin-func) '(1 b))) | ||
| 383 | ;; `macro-builtin-10-and-90' depends on an entirely new macro from `macro-aux'. | ||
| 384 | (should (equal (macro-builtin-10-and-90) '(10 90)))) | ||
| 385 | (mapc #'delete-file | ||
| 386 | (directory-files-recursively dir "\\`[^\\.].*\\.elc\\'")) | ||
| 387 | (mapc (lambda (f) (rename-file f (file-name-sans-extension f))) | ||
| 388 | (directory-files-recursively dir "\\`[^\\.].*\\.el.gz\\'")))))) | ||
| 389 | |||
| 360 | (ert-deftest package-test-install-two-dependencies () | 390 | (ert-deftest package-test-install-two-dependencies () |
| 361 | "Install a package which includes a dependency." | 391 | "Install a package which includes a dependency." |
| 362 | (with-package-test () | 392 | (with-package-test () |