]> git.eshelyaron.com Git - emacs.git/commitdiff
Consider built-in packages to be installed
authorMatt Armstrong <matt@rfc20.org>
Tue, 2 Aug 2022 10:14:09 +0000 (12:14 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 2 Aug 2022 10:14:09 +0000 (12:14 +0200)
* lisp/emacs-lisp/package.el (package-installed-p): Check for built-in
packages before initialization. (bug#56877).

lisp/emacs-lisp/package.el
test/lisp/emacs-lisp/package-tests.el

index df70f908dafb9fef38804a276e2b859b89621d92..482de52f856361d88430d208c81abcc20238fb14 100644 (file)
@@ -2085,7 +2085,10 @@ If PACKAGE is a `package-desc' object, MIN-VERSION is ignored."
          package-activated-list)
     ;; We used the quickstart: make it possible to use package-installed-p
     ;; even before package is fully initialized.
-    (memq package package-activated-list))
+    (or
+     (memq package package-activated-list)
+     ;; Also check built-in packages.
+     (package-built-in-p package min-version)))
    (t
     (or
      (let ((pkg-descs (cdr (assq package (package--alist)))))
index d7a55998c2000d995cb66747ae5a174b86ef0417..b903cd781ba08a1ee80886581c56910f52f3cd58 100644 (file)
@@ -638,6 +638,21 @@ but with a different end of line convention (bug#48137)."
       (package-refresh-contents)
       (should (equal (length package-archive-contents) 2)))))
 
+(ert-deftest package-test-package-installed-p ()
+  "Test package-installed-p before and after package initialization."
+  (with-package-test ()
+    ;; Verify that `package-installed-p' evaluates true for a built-in
+    ;; package, in this case `project', before package initialization.
+    (should (not package--initialized))
+    (should (package-installed-p 'project nil))
+    (should (not (package-installed-p 'imaginary-package nil)))
+
+    ;; The results don't change after package initialization.
+    (package-initialize)
+    (should package--initialized)
+    (should (package-installed-p 'project nil))
+    (should (not (package-installed-p 'imaginary-package nil)))))
+
 (ert-deftest package-test-describe-package ()
   "Test displaying help for a package."