1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Fix ert-font-lock macro signatures

* doc/misc/ert.texi (Syntax Highlighting Tests):
* test/lisp/emacs-lisp/ert-font-lock-tests.el
(test-line-comment-p--emacs-lisp, test-line-comment-p--shell-script)
(test-line-comment-p--javascript, test-line-comment-p--python)
(test-line-comment-p--c, test-macro-test--correct-highlighting)
(test-macro-test--docstring, test-macro-test--failing)
(test-macro-test--file, test-macro-test--file-no-asserts)
(test-macro-test--file-failing): Reindent macro calls.
(with-temp-buffer-str-mode): Evaluate macro arguments left-to-right.
(ert-font-lock--wrap-begin-end): Use rx for more robust composition.
(test-line-comment-p--php): Require that php-mode is callable, not
already loaded.

* lisp/emacs-lisp/ert-font-lock.el (ert-font-lock-deftest)
(ert-font-lock-deftest-file): NAME is not followed by an empty list
like in ert-deftest, so the optional DOCSTRING is actually the
second argument.  Adapt calling convention in docstring, and debug,
doc-string, and indent properties accordingly (bug#76372).  Fix
docstring grammar, document MAJOR-MODE, and avoid referring to a
file name as a path.
This commit is contained in:
Basil L. Contovounesios 2025-02-20 10:29:54 +01:00
parent 0c6b8643ae
commit 02c830ba22
3 changed files with 73 additions and 70 deletions

View file

@ -27,8 +27,8 @@
;; highlighting provided by font-lock.
;;
;; ert-font-lock entry points are functions
;; `ert-font-lock-test-string' and `ert-font-lock-test-file' and
;; convenience macros: `ert-font-lock-deftest' and
;; `ert-font-lock-test-string' and `ert-font-lock-test-file', and
;; convenience macros `ert-font-lock-deftest' and
;; `ert-font-lock-deftest-file'.
;;
;; See unit tests in ert-font-lock-tests.el for usage examples.
@ -124,19 +124,21 @@ Argument TEST-NAME - name of the currently running ert test."
(defmacro ert-font-lock-deftest (name &rest docstring-keys-mode-and-str)
"Define test NAME (a symbol) using assertions from TEST-STR.
Other than MAJOR-MODE and TEST-STR parameters, this macro accepts
the same parameters and keywords as `ert-deftest' and is intended
to be used through `ert'.
The MAJOR-MODE symbol determines the syntax and font lock of TEST-STR.
\(fn NAME () [DOCSTRING] [:expected-result RESULT-TYPE] \
Except for the MAJOR-MODE and TEST-STR parameters, this macro accepts
the same arguments and keywords as `ert-deftest' and is intended to be
used through `ert'.
\(fn NAME [DOCSTRING] [:expected-result RESULT-TYPE] \
[:tags \\='(TAG...)] MAJOR-MODE TEST-STR)"
(declare (debug (&define [&name "test@" symbolp]
sexp [&optional stringp]
[&optional stringp]
[&rest keywordp sexp]
symbolp
stringp))
(doc-string 3)
(indent 2))
(doc-string 2)
(indent 1))
(pcase-let ((`(,documentation
,documentation-supplied-p
,keys ,mode ,arg)
@ -159,22 +161,23 @@ to be used through `ert'.
(defmacro ert-font-lock-deftest-file (name &rest docstring-keys-mode-and-file)
"Define test NAME (a symbol) using assertions from FILE.
FILE - path to a file with assertions in ERT resource director as
return by `ert-resource-directory'.
FILE names a file with assertions in the ERT resource directory, as
returned by `ert-resource-directory'. The MAJOR-MODE symbol determines
the syntax and font lock of FILE's contents.
Other than MAJOR-MODE and FILE parameters, this macro accepts the
same parameters and keywords as `ert-deftest' and is intended to
be used through `ert'.
Except for the MAJOR-MODE and FILE parameters, this macro accepts the
same arguments and keywords as `ert-deftest' and is intended to be used
through `ert'.
\(fn NAME () [DOCSTRING] [:expected-result RESULT-TYPE] \
\(fn NAME [DOCSTRING] [:expected-result RESULT-TYPE] \
[:tags \\='(TAG...)] MAJOR-MODE FILE)"
(declare (debug (&define [&name "test@" symbolp]
sexp [&optional stringp]
[&optional stringp]
[&rest keywordp sexp]
symbolp
stringp))
(doc-string 3)
(indent 2))
(doc-string 2)
(indent 1))
(pcase-let ((`(,documentation
,documentation-supplied-p