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).
This commit is contained in:
dickmao 2021-11-07 01:28:47 +01:00 committed by Lars Ingebrigtsen
parent 55fa6a2655
commit 9dfd945a2c
6 changed files with 151 additions and 80 deletions

View file

@ -342,9 +342,13 @@ but with a different end of line convention (bug#48137)."
(declare-function macro-problem-func "macro-problem" ())
(declare-function macro-problem-10-and-90 "macro-problem" ())
(declare-function macro-builtin-func "macro-builtin" ())
(declare-function macro-builtin-10-and-90 "macro-builtin" ())
(ert-deftest package-test-macro-compilation ()
"Install a package which includes a dependency."
"\"Activation has to be done before compilation, so that if we're
upgrading and macros have changed we load the new definitions
before compiling.\" -- package.el"
(with-package-test (:basedir (ert-resource-directory))
(package-install-file (expand-file-name "macro-problem-package-1.0/"))
(require 'macro-problem)
@ -357,6 +361,32 @@ but with a different end of line convention (bug#48137)."
;; `macro-problem-10-and-90' depends on an entirely new macro from `macro-aux'.
(should (equal (macro-problem-10-and-90) '(10 90)))))
(ert-deftest package-test-macro-compilation-gz ()
"Built-in's can be superseded as well."
(with-package-test (:basedir (ert-resource-directory))
(let ((dir (expand-file-name "macro-builtin-package-1.0")))
(unwind-protect
(let ((load-path load-path))
(add-to-list 'load-path (directory-file-name dir))
(byte-recompile-directory dir 0 t)
(mapc (lambda (f) (rename-file f (concat f ".gz")))
(directory-files-recursively dir "\\`[^\\.].*\\.el\\'"))
(require 'macro-builtin)
(should (member (expand-file-name "macro-builtin-aux.elc" dir)
(mapcar #'car load-history)))
;; `macro-builtin-func' uses a macro from `macro-aux'.
(should (equal (macro-builtin-func) '(progn a b)))
(package-install-file (expand-file-name "macro-builtin-package-2.0/"))
;; After upgrading, `macro-builtin-func' depends on a new version
;; of the macro from `macro-builtin-aux'.
(should (equal (macro-builtin-func) '(1 b)))
;; `macro-builtin-10-and-90' depends on an entirely new macro from `macro-aux'.
(should (equal (macro-builtin-10-and-90) '(10 90))))
(mapc #'delete-file
(directory-files-recursively dir "\\`[^\\.].*\\.elc\\'"))
(mapc (lambda (f) (rename-file f (file-name-sans-extension f)))
(directory-files-recursively dir "\\`[^\\.].*\\.el.gz\\'"))))))
(ert-deftest package-test-install-two-dependencies ()
"Install a package which includes a dependency."
(with-package-test ()