GNU bug report logs - #62152
29.0.60; `erts-run-test' does not properly set match data for `ert-test--erts-test'

Previous Next

Package: emacs;

Reported by: Troy Brown <brownts <at> troybrown.dev>

Date: Sun, 12 Mar 2023 21:32:02 UTC

Severity: normal

Found in version 29.0.60

To reply to this bug, email your comments to 62152 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62152; Package emacs. (Sun, 12 Mar 2023 21:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Troy Brown <brownts <at> troybrown.dev>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 12 Mar 2023 21:32:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Troy Brown <brownts <at> troybrown.dev>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.60; `erts-run-test' does not properly set match data for
 `ert-test--erts-test'
Date: Sun, 12 Mar 2023 13:31:25 -0400
`ert-test--erts-test' is expecting match data to exist (i.e., set by the
caller) for the beginning of the test.  This is used to locate the test
specification data (e.g., 'Name').  However, when this function is
invoked via `erts-run-test', it appears this match data (established by
the call to `erts-mode--goto-start-of-test') is overwritten by the call
to `erts-mode--preceding-spec' to locate "Point-Char".  In this
situation, if "Point-Char" exists in the test specification and appears
prior to "Name" in the test specification, the "Name" specification will
not be able to be located (due to the expected match location having
been moved higher in the buffer).  As a result a "No name for test case"
error will be raised.

Here is an ERTS test which can be used to reproduce this problem.
Pressing C-c C-c when in `erts-mode' with the following will exhibit the
problem.

Code:
  (lambda ()
    (fundamental-mode)
    (newline))

Point-Char: |

Name: Simple Test

=-=
Hi| there
=-=
Hi
| there
=-=-=

This particular issue can be fixed by wrapping the call to
`erts-mode--preceding-spec` with `save-match-data', but it might be even
better to incorporate that into `erts-mode--preceding-spec' itself.

   (save-excursion
     (erts-mode--goto-start-of-test)
     (condition-case arg
         (ert-test--erts-test
          (list (cons 'dummy t)
                (cons 'code (car (read-from-string test-function)))
-               (cons 'point-char (erts-mode--preceding-spec "Point-Char")))
+               (cons 'point-char
+                     (save-match-data
+                       (erts-mode--preceding-spec "Point-Char"))))
          (buffer-file-name))
       (:success (message "Test successful"))




This bug report was last modified 1 year and 53 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.