;;; package-test.el --- Tests for the Emacs package system
-;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;; Author: Daniel Hackney <dan@haxney.org>
;; Version: 1.0
:version '(1 3)
:summary "A single-file package with no dependencies"
:kind 'single
- :extras '((:url . "http://doodles.au")))
+ :extras '((:authors ("J. R. Hacker" . "jrh@example.com"))
+ (:maintainer "J. R. Hacker" . "jrh@example.com")
+ (:url . "http://doodles.au")))
"Expected `package-desc' parsed from simple-single-1.3.el.")
(defvar simple-depend-desc
:version '(1 0)
:summary "A single-file package with a dependency."
:kind 'single
- :reqs '((simple-single (1 3))))
+ :reqs '((simple-single (1 3)))
+ :extras '((:authors ("J. R. Hacker" . "jrh@example.com"))
+ (:maintainer "J. R. Hacker" . "jrh@example.com")))
"Expected `package-desc' parsed from simple-depend-1.0.el.")
(defvar multi-file-desc
(should (package-install-from-buffer))
(package-initialize)
(should (package-installed-p 'simple-single))
+ ;; Check if we properly report an "already installed".
+ (package-install 'simple-single)
+ (with-current-buffer "*Messages*"
+ (should (string-match "^[`‘']simple-single[’'] is already installed\n?\\'"
+ (buffer-string))))
+ (should (package-installed-p 'simple-single))
(let* ((simple-pkg-dir (file-name-as-directory
(expand-file-name
"simple-single-1.3"
"(define-package \"simple-single\" \"1.3\" "
"\"A single-file package "
"with no dependencies\" 'nil "
+ ":authors '((\"J. R. Hacker\" . \"jrh@example.com\")) "
+ ":maintainer '(\"J. R. Hacker\" . \"jrh@example.com\") "
":url \"http://doodles.au\""
")\n"))))
(should (file-exists-p autoloads-file))
(should (package-installed-p 'simple-single))
(should (package-installed-p 'simple-depend))))
+(ert-deftest package-test-macro-compilation ()
+ "Install a package which includes a dependency."
+ (with-package-test (:basedir "data/package")
+ (package-install-file (expand-file-name "macro-problem-package-1.0/"))
+ (require 'macro-problem)
+ ;; `macro-problem-func' uses a macro from `macro-aux'.
+ (should (equal (macro-problem-func) '(progn a b)))
+ (package-install-file (expand-file-name "macro-problem-package-2.0/"))
+ ;; After upgrading, `macro-problem-func' depends on a new version
+ ;; of the macro from `macro-aux'.
+ (should (equal (macro-problem-func) '(1 b)))
+ ;; `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-install-two-dependencies ()
"Install a package which includes a dependency."
(with-package-test ()
(describe-package '5x5)
(goto-char (point-min))
(should (search-forward "5x5 is a built-in package." nil t))
- (should (search-forward "Status: Built-in." nil t))
- (should (search-forward "Summary: simple little puzzle game" nil t))
+ ;; Don't assume the descriptions are in any particular order.
+ (save-excursion (should (search-forward "Status: Built-in." nil t)))
+ (save-excursion (should (search-forward "Summary: simple little puzzle game" nil t)))
(should (search-forward "The aim of 5x5" nil t)))
;; Installed
(describe-package 'simple-single)
(goto-char (point-min))
(should (search-forward "simple-single is an installed package." nil t))
- (should (re-search-forward
- "Status: Installed in ['`‘]~/simple-single-1.3/['’] (unsigned)."
- nil t))
- (should (search-forward "Version: 1.3" nil t))
- (should (search-forward "Summary: A single-file package with no dependencies"
- nil t))
- (should (search-forward "Homepage: http://doodles.au" nil t))
- (should (re-search-forward "Keywords: \\[?frobnicate\\]?" nil t))
+ (save-excursion (should (re-search-forward "Status: Installed in ['`‘]simple-single-1.3/['’] (unsigned)." nil t)))
+ (save-excursion (should (search-forward "Version: 1.3" nil t)))
+ (save-excursion (should (search-forward "Summary: A single-file package with no dependencies" nil t)))
+ (save-excursion (should (search-forward "Homepage: http://doodles.au" nil t)))
+ (save-excursion (should (re-search-forward "Keywords: \\[?frobnicate\\]?" nil t)))
;; No description, though. Because at this point we don't know
;; what archive the package originated from, and we don't have
;; its readme file saved.
(cons (format "HOME=%s" homedir)
process-environment)))
(epg-check-configuration (epg-configuration))
- t)
+ (epg-find-configuration 'OpenPGP))
(delete-directory homedir t)))))
(let* ((keyring (expand-file-name "key.pub" package-test-data-dir))
(package-test-data-dir
(package-initialize)
(package-import-keyring keyring)
(package-refresh-contents)
- (should (package-install 'signed-good))
- (should-error (package-install 'signed-bad))
+ (let ((package-check-signature 'allow-unsigned))
+ (should (package-install 'signed-good))
+ (should-error (package-install 'signed-bad)))
+ (let ((package-check-signature t))
+ (should (package-install 'signed-good))
+ (should-error (package-install 'signed-bad)))
+ (let ((package-check-signature nil))
+ (should (package-install 'signed-good))
+ (should (package-install 'signed-bad)))
;; Check if the installed package status is updated.
(let ((buf (package-list-packages)))
(package-menu-refresh)
(should (re-search-forward "signed-good is an? \\(\\S-+\\) package." nil t))
(should (string-equal (match-string-no-properties 1) "installed"))
(should (re-search-forward
- "Status: Installed in ['`‘]~/signed-good-1.0/['’]."
+ "Status: Installed in ['`‘]signed-good-1.0/['’]."
nil t))))))
(package-make-ac-desc '(1 3) nil
"A single-file package with no dependencies"
'single
- '((:url . "http://doodles.au"))))
+ '((:authors ("J. R. Hacker" . "jrh@example.com"))
+ (:maintainer "J. R. Hacker" . "jrh@example.com")
+ (:url . "http://doodles.au"))))
"Expected contents of the archive entry from the \"simple-single\" package.")
(defvar package-x-test--single-archive-entry-1-4
(package-make-ac-desc '(1 4) nil
"A single-file package with no dependencies"
'single
- nil))
+ '((:authors ("J. R. Hacker" . "jrh@example.com"))
+ (:maintainer "J. R. Hacker" . "jrh@example.com"))))
"Expected contents of the archive entry from the updated \"simple-single\" package.")
(ert-deftest package-x-test-upload-buffer ()