X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f0398ec17f8a00d6c6d828c3d04522d94337d156..acbadd0046cb1643eeaf8595ede1a69cc25d3158:/test/automated/package-test.el diff --git a/test/automated/package-test.el b/test/automated/package-test.el old mode 100755 new mode 100644 index a5f0ebb1f9..ec85432b63 --- a/test/automated/package-test.el +++ b/test/automated/package-test.el @@ -47,16 +47,10 @@ (package-desc-create :name 'simple-single :version '(1 3) :summary "A single-file package with no dependencies" - :kind 'single) + :kind 'single + :extras '((:url . "http://doodles.au"))) "Expected `package-desc' parsed from simple-single-1.3.el.") -(defvar simple-single-desc-1-4 - (package-desc-create :name 'simple-single - :version '(1 4) - :summary "A single-file package with no dependencies" - :kind 'single) - "Expected `package-desc' parsed from simple-single-1.4.el.") - (defvar simple-depend-desc (package-desc-create :name 'simple-depend :version '(1 0) @@ -69,7 +63,8 @@ (package-desc-create :name 'multi-file :version '(0 2 3) :summary "Example of a multi-file tar package" - :kind 'tar) + :kind 'tar + :extras '((:url . "http://puddles.li"))) "Expected `package-desc' from \"multi-file-0.2.3.tar\".") (defvar new-pkg-desc @@ -85,9 +80,6 @@ (expand-file-name "archive-contents" package-test-data-dir) "Path to a static copy of \"archive-contents\".") -(defvar package-test-built-file-suffixes '(".tar" "/dir" "/*.info") - "Remove these files when cleaning up a built package.") - (cl-defmacro with-package-test ((&optional &key file basedir install @@ -100,7 +92,7 @@ (package-user-dir package-test-user-dir) (package-archives `(("gnu" . ,package-test-data-dir))) (old-yes-no-defn (symbol-function 'yes-or-no-p)) - (old-pwd default-directory) + (default-directory package-test-file-dir) package--initialized package-alist ,@(if update-news @@ -131,8 +123,7 @@ (when (and (boundp 'package-test-archive-upload-base) (file-directory-p package-test-archive-upload-base)) (delete-directory package-test-archive-upload-base t)) - (setf (symbol-function 'yes-or-no-p) old-yes-no-defn) - (cd old-pwd)))) + (setf (symbol-function 'yes-or-no-p) old-yes-no-defn)))) (defmacro with-fake-help-buffer (&rest body) "Execute BODY in a temp buffer which is treated as the \"*Help*\" buffer." @@ -142,33 +133,6 @@ (let ((help-xref-following t)) ,@body))) -(autoload 'makeinfo-buffer "makeinfo") -(defvar compilation-in-progress) - -(defun package-test-install-texinfo (file) - "Install from texinfo FILE. - -FILE should be a .texinfo file relative to the current -`default-directory'" - (require 'info) - (let* ((full-file (expand-file-name file)) - (info-file (replace-regexp-in-string "\\.texi\\'" ".info" full-file)) - (old-info-defn (symbol-function 'Info-revert-find-node))) - (require 'info) - (setf (symbol-function 'Info-revert-find-node) #'ignore) - (with-current-buffer (find-file-literally full-file) - (unwind-protect - (progn - (makeinfo-buffer) - ;; Give `makeinfo-buffer' a chance to finish - (while compilation-in-progress - (sit-for 0.1)) - (call-process "ginstall-info" nil nil nil - (format "--info-dir=%s" default-directory) - (format "%s" info-file))) - (kill-buffer) - (setf (symbol-function 'Info-revert-find-node) old-info-defn))))) - (defun package-test-strip-version (dir) (replace-regexp-in-string "-pkg\\.el\\'" "" (package--description-file dir))) @@ -178,14 +142,6 @@ FILE should be a .texinfo file relative to the current '(lambda (item) (file-expand-wildcards (concat base item))) suffix-list)) -(defun package-test-cleanup-built-files (dir) - "Remove files which were the result of creating a tar archive. - -DIR is the base name of the package directory, without the trailing slash" - (let* ((pkg-dirname (file-name-nondirectory dir))) - (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes)) - (delete-file file)))) - (defvar tar-parse-info) (declare-function tar-header-name "tar-mode" (cl-x) t) ; defstruct @@ -232,7 +188,9 @@ Must called from within a `tar-mode' buffer." (should (string= (buffer-string) (concat "(define-package \"simple-single\" \"1.3\" " "\"A single-file package " - "with no dependencies\" 'nil)\n")))) + "with no dependencies\" 'nil " + ":url \"http://doodles.au\"" + ")\n")))) (should (file-exists-p autoloads-file)) (should-not (get-file-buffer autoloads-file))))) @@ -296,7 +254,7 @@ Must called from within a `tar-mode' buffer." (should (package-installed-p 'simple-single)) (switch-to-buffer "*Packages*") (goto-char (point-min)) - (should (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+installed" nil t)) + (should (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+unsigned" nil t)) (goto-char (point-min)) (should-not (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+\\(available\\|new\\)" nil t)) (kill-buffer buf)))) @@ -318,7 +276,7 @@ Must called from within a `tar-mode' buffer." ;; New version should be available and old version should be installed (goto-char (point-min)) (should (re-search-forward "^\\s-+simple-single\\s-+1.4\\s-+new" nil t)) - (should (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+installed" nil t)) + (should (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+unsigned" nil t)) (goto-char (point-min)) (should (re-search-forward "^\\s-+new-pkg\\s-+1.0\\s-+\\(available\\|new\\)" nil t)) @@ -349,31 +307,20 @@ Must called from within a `tar-mode' buffer." (with-fake-help-buffer (describe-package 'simple-single) (goto-char (point-min)) - (should (search-forward "simple-single is an installed package." nil t)) + (should (search-forward "simple-single is an unsigned package." nil t)) (should (search-forward - (format "Status: Installed in `%s/'." + (format "Status: Installed in `%s/' (unsigned)." (expand-file-name "simple-single-1.3" package-user-dir)) 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)) ;; 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. ))) -(ert-deftest package-test-describe-not-installed-package () - "Test displaying of the readme for not-installed package." - - (with-package-test () - (package-initialize) - (package-refresh-contents) - (with-fake-help-buffer - (describe-package 'simple-single) - (goto-char (point-min)) - (should (search-forward "This package provides a minor mode to frobnicate" - nil t))))) - (ert-deftest package-test-describe-non-installed-package () "Test displaying of the readme for non-installed package." @@ -383,6 +330,7 @@ Must called from within a `tar-mode' buffer." (with-fake-help-buffer (describe-package 'simple-single) (goto-char (point-min)) + (should (search-forward "Homepage: http://doodles.au" nil t)) (should (search-forward "This package provides a minor mode to frobnicate" nil t))))) @@ -395,9 +343,41 @@ Must called from within a `tar-mode' buffer." (with-fake-help-buffer (describe-package 'multi-file) (goto-char (point-min)) + (should (search-forward "Homepage: http://puddles.li" nil t)) (should (search-forward "This is a bare-bones readme file for the multi-file" nil t))))) +(ert-deftest package-test-signed () + "Test verifying package signature." + :expected-result (condition-case nil + (progn + (epg-check-configuration (epg-configuration)) + :passed) + (error :failed)) + (let* ((keyring (expand-file-name "key.pub" package-test-data-dir)) + (package-test-data-dir + (expand-file-name "data/package/signed" package-test-file-dir))) + (with-package-test () + (package-initialize) + (package-import-keyring keyring) + (package-refresh-contents) + (should (package-install 'signed-good)) + (should-error (package-install 'signed-bad)) + ;; Check if the installed package status is updated. + (let ((buf (package-list-packages))) + (package-menu-refresh) + (should (re-search-forward "^\\s-+signed-good\\s-+1\\.0\\s-+installed" + nil t))) + ;; Check if the package description is updated. + (with-fake-help-buffer + (describe-package 'signed-good) + (goto-char (point-min)) + (should (search-forward "signed-good is an installed package." nil t)) + (should (search-forward + (format "Status: Installed in `%s/'." + (expand-file-name "signed-good-1.0" package-user-dir)) + nil t)))))) + (provide 'package-test) ;;; package-test.el ends here