diff options
| author | Przemysław Kryger | 2026-01-23 16:36:37 +0000 |
|---|---|---|
| committer | Mattias Engdegård | 2026-01-27 15:32:28 +0100 |
| commit | 4fae092e2d8b20471ee1b30bf7d30d26feef0bd0 (patch) | |
| tree | cc2ac71043dec3fe2cfd6606fcd109328d6449f1 | |
| parent | 19cd6972faab7f63388359a87b11d00b9e718855 (diff) | |
| download | emacs-4fae092e2d8b20471ee1b30bf7d30d26feef0bd0.tar.gz emacs-4fae092e2d8b20471ee1b30bf7d30d26feef0bd0.zip | |
Ensure skipped package-vc-tests are not installed (bug#80235)
* test/lisp/emacs-lisp/package-vc-tests.el
(package-vc-tests-packages): Add argument `full'. When `full'
is non-nil, then return full entries.
(package-vc-test-deftest): Use `pkg-arg' for the name of
argument `in-body'. Call `skip-when' and `skip-unless' before
`packgage-vc-tests-with-installed'.
| -rw-r--r-- | test/lisp/emacs-lisp/package-vc-tests.el | 148 |
1 files changed, 79 insertions, 69 deletions
diff --git a/test/lisp/emacs-lisp/package-vc-tests.el b/test/lisp/emacs-lisp/package-vc-tests.el index 150d5c4a6e0..01c08ca7d3f 100644 --- a/test/lisp/emacs-lisp/package-vc-tests.el +++ b/test/lisp/emacs-lisp/package-vc-tests.el | |||
| @@ -70,20 +70,21 @@ preserve all temporary directories.") | |||
| 70 | (defvar package-vc-tests-repository) | 70 | (defvar package-vc-tests-repository) |
| 71 | 71 | ||
| 72 | (eval-and-compile | 72 | (eval-and-compile |
| 73 | (defun package-vc-tests-packages () | 73 | (defun package-vc-tests-packages (&optional full) |
| 74 | "Return a list of package definitions to test. | 74 | "Return a list of package definitions to test. |
| 75 | When variable `package-vc-tests-packages' is bound then return its | 75 | When variable `package-vc-tests-packages' is bound then return its |
| 76 | value. If `package-vc-tests-dir' is bound then each entry is in a form | 76 | value. If `package-vc-tests-dir' is bound or FULL is non nil then each |
| 77 | of (PKG CHECKOUT-DIR LISP-DIR INSTALL-FUN), where PKG is a package | 77 | entry is in a form of (PKG CHECKOUT-DIR LISP-DIR INSTALL-FUN), where PKG |
| 78 | name (a symbol), CHECKOUT-DIR is an expected checkout directory, | 78 | is a package name (a symbol), CHECKOUT-DIR either is nil when |
| 79 | LISP-DIR is a directory with package's sources (relative to | 79 | `package-vc-tests-dir' is not bound or is an expected checkout |
| 80 | directory, LISP-DIR is a directory with package's sources (relative to | ||
| 80 | CHECKOUT-DIR), and INSTALL-FUN is a function that checkouts and install | 81 | CHECKOUT-DIR), and INSTALL-FUN is a function that checkouts and install |
| 81 | the package. Otherwise each entry is in a form of PKG." | 82 | the package. Otherwise each entry is in a form of PKG." |
| 82 | (if (boundp 'package-vc-tests-packages) | 83 | (if (boundp 'package-vc-tests-packages) |
| 83 | package-vc-tests-packages | 84 | package-vc-tests-packages |
| 84 | (cl-macrolet ((test-package-def | 85 | (cl-macrolet ((test-package-def |
| 85 | (pkg checkout-dir-exp lisp-dir install-fun) | 86 | (pkg checkout-dir-exp lisp-dir install-fun) |
| 86 | `(if (boundp 'package-vc-tests-dir) | 87 | `(if (or (boundp 'package-vc-tests-dir) full) |
| 87 | (list | 88 | (list |
| 88 | ',pkg | 89 | ',pkg |
| 89 | (expand-file-name (symbol-name ',pkg) | 90 | (expand-file-name (symbol-name ',pkg) |
| @@ -91,51 +92,54 @@ the package. Otherwise each entry is in a form of PKG." | |||
| 91 | ,lisp-dir | 92 | ,lisp-dir |
| 92 | #',install-fun) | 93 | #',install-fun) |
| 93 | ',pkg))) | 94 | ',pkg))) |
| 94 | (list | 95 | (let* ((tests-dir (bound-and-true-p package-vc-tests-dir)) |
| 95 | ;; checkout and install with `package-vc-install' (on ELPA) | 96 | (user-dir (and tests-dir package-user-dir))) |
| 96 | (test-package-def | 97 | (list |
| 97 | test-package-one package-user-dir nil | 98 | ;; checkout and install with `package-vc-install' (on ELPA) |
| 98 | package-vc-tests-install-from-elpa) | 99 | (test-package-def |
| 99 | ;; checkout and install with `package-vc-install' (not on ELPA) | 100 | test-package-one user-dir nil |
| 100 | (test-package-def | 101 | package-vc-tests-install-from-elpa) |
| 101 | test-package-two package-user-dir nil | 102 | ;; checkout and install with `package-vc-install' (not on |
| 102 | package-vc-tests-install-from-spec) | 103 | ;; ELPA) |
| 103 | ;; checkout with `package-vc-checktout' and install with | 104 | (test-package-def |
| 104 | ;; `package-vc-install-from-checkout' (on ELPA) | 105 | test-package-two user-dir nil |
| 105 | (test-package-def | 106 | package-vc-tests-install-from-spec) |
| 106 | test-package-three package-vc-tests-dir nil | 107 | ;; checkout with `package-vc-checktout' and install with |
| 107 | package-vc-tests-checkout-from-elpa-install-from-checkout) | 108 | ;; `package-vc-install-from-checkout' (on ELPA) |
| 108 | ;; checkout with git and install with | 109 | (test-package-def |
| 109 | ;; `package-vc-install-from-checkout' | 110 | test-package-three tests-dir nil |
| 110 | (test-package-def | 111 | package-vc-tests-checkout-from-elpa-install-from-checkout) |
| 111 | test-package-four package-vc-tests-dir nil | 112 | ;; checkout with git and install with |
| 112 | package-vc-tests-checkout-with-git-install-from-checkout) | 113 | ;; `package-vc-install-from-checkout' |
| 113 | ;; sources in "lisp" sub directory, checkout and install with | 114 | (test-package-def |
| 114 | ;; `package-vc-install' (not on ELPA) | 115 | test-package-four tests-dir nil |
| 115 | (test-package-def | 116 | package-vc-tests-checkout-with-git-install-from-checkout) |
| 116 | test-package-five package-user-dir "lisp" | 117 | ;; sources in "lisp" sub directory, checkout and install with |
| 117 | package-vc-tests-install-from-spec) | 118 | ;; `package-vc-install' (not on ELPA) |
| 118 | ;; sources in "lisp" sub directory, checkout with git and | 119 | (test-package-def |
| 119 | ;; install with `package-vc-install-from-checkout' | 120 | test-package-five user-dir "lisp" |
| 120 | (test-package-def | 121 | package-vc-tests-install-from-spec) |
| 121 | test-package-six package-vc-tests-dir "lisp" | 122 | ;; sources in "lisp" sub directory, checkout with git and |
| 122 | package-vc-tests-checkout-with-git-install-from-checkout) | 123 | ;; install with `package-vc-install-from-checkout' |
| 123 | ;; sources in "src" sub directory, checkout and install with | 124 | (test-package-def |
| 124 | ;; `package-vc-install' (on ELPA) | 125 | test-package-six tests-dir "lisp" |
| 125 | (test-package-def | 126 | package-vc-tests-checkout-with-git-install-from-checkout) |
| 126 | test-package-seven package-user-dir "src" | 127 | ;; sources in "src" sub directory, checkout and install with |
| 127 | package-vc-tests-install-from-elpa) | 128 | ;; `package-vc-install' (on ELPA) |
| 128 | ;; sources in "src" sub directory, checkout with | 129 | (test-package-def |
| 129 | ;; `package-vc-checktout' and install with | 130 | test-package-seven user-dir "src" |
| 130 | ;; `package-vc-install-from-checkout' (on ELPA) | 131 | package-vc-tests-install-from-elpa) |
| 131 | (test-package-def | 132 | ;; sources in "src" sub directory, checkout with |
| 132 | test-package-eight package-vc-tests-dir nil | 133 | ;; `package-vc-checktout' and install with |
| 133 | package-vc-tests-checkout-from-elpa-install-from-checkout) | 134 | ;; `package-vc-install-from-checkout' (on ELPA) |
| 134 | ;; sources in "custom-dir" sub directory, checkout and install | 135 | (test-package-def |
| 135 | ;; with `package-vc-install' (on ELPA) | 136 | test-package-eight tests-dir nil |
| 136 | (test-package-def | 137 | package-vc-tests-checkout-from-elpa-install-from-checkout) |
| 137 | test-package-nine package-user-dir "custom-dir" | 138 | ;; sources in "custom-dir" sub directory, checkout and |
| 138 | package-vc-tests-install-from-elpa)))))) | 139 | ;; install with `package-vc-install' (on ELPA) |
| 140 | (test-package-def | ||
| 141 | test-package-nine user-dir "custom-dir" | ||
| 142 | package-vc-tests-install-from-elpa))))))) | ||
| 139 | 143 | ||
| 140 | ;; TODO: add test for deleting packages, with asserting | 144 | ;; TODO: add test for deleting packages, with asserting |
| 141 | ;; `package-vc-selected-packages' | 145 | ;; `package-vc-selected-packages' |
| @@ -678,27 +682,33 @@ contains key `:tags' use its value as tests tags." | |||
| 678 | (error "`package-vc' tests first argument has to be a symbol")) | 682 | (error "`package-vc' tests first argument has to be a symbol")) |
| 679 | (let ((file (or (macroexp-file-name) buffer-file-name)) | 683 | (let ((file (or (macroexp-file-name) buffer-file-name)) |
| 680 | (tests '()) (fn (gensym)) | 684 | (tests '()) (fn (gensym)) |
| 685 | (pkg-arg (car args)) | ||
| 686 | (skip-forms (take-while (lambda (form) | ||
| 687 | (memq (car-safe form) '(skip-when | ||
| 688 | skip-unless))) | ||
| 689 | body)) | ||
| 681 | (tags (plist-get (cdr-safe args) :tags))) | 690 | (tags (plist-get (cdr-safe args) :tags))) |
| 691 | (setq body (nthcdr (length skip-forms) body)) | ||
| 682 | (dolist (pkg (package-vc-tests-packages)) | 692 | (dolist (pkg (package-vc-tests-packages)) |
| 683 | (let ((name (intern (format "package-vc-tests-%s/%s" name pkg)))) | 693 | (let ((name (intern (format "package-vc-tests-%s/%s" name pkg)))) |
| 684 | (push | 694 | (push |
| 685 | `(ert-set-test | 695 | `(ert-set-test ',name |
| 686 | ',name | 696 | (make-ert-test |
| 687 | (make-ert-test | 697 | :name ',name |
| 688 | :name ',name | 698 | :tags (cons 'package-vc ',tags) |
| 689 | :tags (cons 'package-vc ',tags) | 699 | :file-name ,file |
| 690 | :file-name ,file | 700 | :body |
| 691 | :body | 701 | (lambda () |
| 692 | (lambda () | 702 | (funcall ,fn ',pkg) |
| 693 | (package-vc-tests-with-installed | 703 | nil))) |
| 694 | ',pkg (funcall ,fn ',pkg)) | ||
| 695 | nil))) | ||
| 696 | tests))) | 704 | tests))) |
| 697 | `(let ((,fn (lambda (,(car args)) | 705 | `(cl-macrolet ((skip-when (form) `(ert--skip-when ,form)) |
| 698 | (cl-macrolet ((skip-when (form) `(ert--skip-when ,form)) | 706 | (skip-unless (form) `(ert--skip-unless ,form))) |
| 699 | (skip-unless (form) `(ert--skip-unless ,form))) | 707 | (let ((,fn (lambda (,pkg-arg) |
| 700 | (lambda () ,@body))))) | 708 | ,@skip-forms |
| 701 | ,@tests))) | 709 | (package-vc-tests-with-installed ,pkg-arg |
| 710 | (lambda () ,@body))))) | ||
| 711 | ,@tests)))) | ||
| 702 | 712 | ||
| 703 | (package-vc-test-deftest install-post-conditions (pkg) | 713 | (package-vc-test-deftest install-post-conditions (pkg) |
| 704 | (let ((install-begin | 714 | (let ((install-begin |
| @@ -1006,7 +1016,7 @@ contains key `:tags' use its value as tests tags." | |||
| 1006 | 1016 | ||
| 1007 | (package-vc-test-deftest pkg-spec-make-shell-command (pkg) | 1017 | (package-vc-test-deftest pkg-spec-make-shell-command (pkg) |
| 1008 | ;; Only `package-vc-install' runs make and shell command | 1018 | ;; Only `package-vc-install' runs make and shell command |
| 1009 | (skip-unless (memq (caddr (alist-get pkg package-vc-tests-packages)) | 1019 | (skip-unless (memq (caddr (alist-get pkg (package-vc-tests-packages t))) |
| 1010 | '(package-vc-tests-install-from-elpa | 1020 | '(package-vc-tests-install-from-elpa |
| 1011 | package-vc-tests-install-from-spec))) | 1021 | package-vc-tests-install-from-spec))) |
| 1012 | (let* ((desc (package-vc-tests-package-desc pkg t)) | 1022 | (let* ((desc (package-vc-tests-package-desc pkg t)) |
| @@ -1024,7 +1034,7 @@ contains key `:tags' use its value as tests tags." | |||
| 1024 | ;; Only `package-vc-install' builds info manuals, but only when | 1034 | ;; Only `package-vc-install' builds info manuals, but only when |
| 1025 | ;; executable install-info is available. | 1035 | ;; executable install-info is available. |
| 1026 | (skip-unless (and (executable-find "install-info") | 1036 | (skip-unless (and (executable-find "install-info") |
| 1027 | (memq (caddr (alist-get pkg package-vc-tests-packages)) | 1037 | (memq (caddr (alist-get pkg (package-vc-tests-packages t))) |
| 1028 | '(package-vc-tests-install-from-elpa | 1038 | '(package-vc-tests-install-from-elpa |
| 1029 | package-vc-tests-install-from-spec)))) | 1039 | package-vc-tests-install-from-spec)))) |
| 1030 | (should-not (package-vc-tests-log-buffer-exists 'doc pkg)) | 1040 | (should-not (package-vc-tests-log-buffer-exists 'doc pkg)) |