bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65475: 29.1; package-selected-packages variable is not updated when


From: Stefan Kangas
Subject: bug#65475: 29.1; package-selected-packages variable is not updated when the last package is deleted
Date: Thu, 14 Sep 2023 07:27:52 -0700

Philip Kaludercic <philipk@posteo.net> writes:

> How does this look like:

Thanks, some comments below:

> From e865604c6a9d06cb986752e28b9ae88d7bc8011e Mon Sep 17 00:00:00 2001
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Thu, 14 Sep 2023 15:09:19 +0200
> Subject: [PATCH] package-tests.el: Add test Bug#65475
>
> * test/lisp/emacs-lisp/package-tests.el (with-package-test): Bind
> package-selected-packages.
> (package-test-bug65475): Add test.
> ---
>  test/lisp/emacs-lisp/package-tests.el | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/test/lisp/emacs-lisp/package-tests.el 
> b/test/lisp/emacs-lisp/package-tests.el
> index 113b4ec12a8..b55254bc036 100644
> --- a/test/lisp/emacs-lisp/package-tests.el
> +++ b/test/lisp/emacs-lisp/package-tests.el
> @@ -125,6 +125,7 @@ with-package-test
>              abbreviated-home-dir
>              package--initialized
>              package-alist
> +            package-selected-packages
>              ,@(if update-news
>                    '(package-update-news-on-upload t)
>                  (list (cl-gensym)))
> @@ -307,6 +308,23 @@ package-test-bug58367
>        (package-delete (cadr (assq 'v7-withsub package-alist))))
>      ))
>
> +(ert-deftest package-test-bug65475 ()
> +  "Ensure deleting a package clears `package-selected-packages'."
      ^^^^^^ (1)      ^^^^^^^^^ (2)

1. Is this word redundant?
2. Maybe: "the last package"?

> +  (with-package-test (:basedir (ert-resource-directory))
> +    (package-initialize)
> +    (let* ((pkg-el "simple-single-1.3.el")
> +           (source-file (expand-file-name pkg-el (ert-resource-directory))))
> +      (should-not package-alist)
> +      (should-not package-selected-packages)
> +      (package-install-file source-file)
> +      (should package-alist)
> +      (should package-selected-packages)
> +      (let ((desc (cadr (assq 'simple-single package-alist))))
> +        (should desc)
> +        (package-delete desc))

I'm not sure that the `should's and `should-not's above help, because
they make the intention of this test case less clear.  For example, the
test fails if installing the package fails, but don't we already have a
separate test for that?  Do we really need this test to fail in that
case also?

If we want to check that, as a precondition, `package-alist' and
`package-selected-packages' are empty, perhaps that should be some
`cl-assert's in the `with-package-test' macro?  OTOH, we already know
it's nil because of the let in the macro, so wouldn't that just be
verifying that let-binding a variable works correctly?

It seems like the relevant `should's for this particular test are the
two below:

> +      (should-not package-alist)
> +      (should-not package-selected-packages))))
> +
>  (ert-deftest package-test-install-file-EOLs ()
>    "Install same file multiple time with `package-install-file'
>  but with a different end of line convention (bug#48137)."
> --
> 2.39.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]