Function: ert-font-lock-deftest-file

ert-font-lock-deftest-file is an autoloaded macro defined in ert-font-lock.el.gz.

Signature

(ert-font-lock-deftest-file NAME [DOCSTRING] [:expected-result RESULT-TYPE] [:tags '(TAG...)] MAJOR-MODE FILE)

Documentation

Define test NAME (a symbol) using assertions from FILE.

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.

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.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/ert-font-lock.el.gz
;;;###autoload
(defmacro ert-font-lock-deftest-file (name &rest docstring-keys-mode-and-file)
  "Define test NAME (a symbol) using assertions from FILE.

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.

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] \
[:tags \\='(TAG...)] MAJOR-MODE FILE)"
  (declare (debug (&define [&name "test@" symbolp]
                           [&optional stringp]
                           [&rest keywordp sexp]
                           symbolp
                           stringp))
           (doc-string 2)
           (indent 1))

  (pcase-let ((`(,documentation
                 ,documentation-supplied-p
                 ,keys ,mode ,arg)
               (ert-font-lock--parse-macro-args docstring-keys-mode-and-file)))

    `(ert-set-test ',name
                   (make-ert-test
                    :name ',name
                    ,@(when documentation-supplied-p
                        `(:documentation ,documentation))
                    ,@(when (map-contains-key keys :expected-result)
                        `(:expected-result-type ,(map-elt keys :expected-result)))
                    ,@(when (map-contains-key keys :tags)
                        `(:tags ,(map-elt keys :tags)))
                    :body (lambda () (ert-font-lock--test-body-file
                                 ',mode (ert-resource-file ,arg) ',name))
                    :file-name ,(or (macroexp-file-name) buffer-file-name)))))