Subject: Re: bug#76446: 0001-tests-Move-helper-and-wrapper-functions-into-their-o.patch

From: Michael Albinus <[email-masked]>
Date: Fri, 21 Feb 2025 12:52:17 +0100

Morgan Smith <[email-masked]> writes:

> --- a/Makefile
> +++ b/Makefile
> @@ -24,7 +24,7 @@ doc: $(INFOMANUALS)
>  build: $(TARGET)
>
>  check: build $(TESTTARGET)
> -	@$(EMACS) -Q --batch -L . -l $(TESTSOURCE) -f ert-run-tests-batch-and-exit
> +	@$(EMACS) -Q --batch -L . $(foreach file,$(TESTSOURCE), -l $(file)) -f ert-run-tests-batch-and-exit

We might be better with

--8<---------------cut here---------------start------------->8---
@$(EMACS) -Q --batch -L . -L ./test -l $(TESTSOURCE) -f ert-run-tests-batch-and-exit
--8<---------------cut here---------------end--------------->8---

> --- /dev/null
> +++ b/test/debbugs-test-helpers.el
> @@ -0,0 +1,146 @@
> +(defconst debbugs-test--bug-status-soap-return
> +(defconst debbugs-test--bug-status

Perhaps we should move these data into an ert-resource file (or two).

> +(defmacro ert-deftest--debbugs (name args docstring &rest body)
> +  "The same as `ert-deftest' but runs setup and teardown functions."
> +  (declare
> +   (doc-string 3)
> +   (indent 2))
> +  `(ert-deftest ,name ,args ,docstring
> +                (debbugs-test--setup)
> +                ,@body
> +                (debbugs-test--teardown)))

In order to ensure that debbugs-test--teardown is called even in case of
errors, we could use

(unwind-protect
    (progn
      (debbugs-test--setup)
      ,@body)
  (debbugs-test--teardown))

> --- a/test/debbugs-tests.el
> +++ b/test/debbugs-tests.el
> @@ -27,118 +27,7 @@
>  ;;; Code:
>
>  (require 'debbugs)
> +(require 'debbugs-test-helpers "./test/debbugs-test-helpers")

(require 'debbugs-test-helpers) should be sufficient with the proposed
change in the Makefile.

Best regards, Michael.