From 442afd3c365c4b960d168b1166e1dd935bde5580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Augustin=20Ch=C3=A9neau?= Date: Mon, 2 Oct 2023 21:00:44 +0200 Subject: [PATCH] Fix `erts-run-test' in erts-mode The previous behaviour depended on the result of `match-beginning' run from another function, causing an issue if another function called ert-test--erts-test. --- lisp/emacs-lisp/ert.el | 6 +++--- lisp/progmodes/erts-mode.el | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index d727bc94ec5..c57e7733138 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -2911,13 +2911,13 @@ ert-test-erts-file (cons 'code transform)))) ;; Find the start of a test. (while (re-search-forward "^=-=\n" nil t) - (setq gen-specs (ert-test--erts-test gen-specs file)) + (setq gen-specs (ert-test--erts-test gen-specs file (match-beginning 0))) ;; Search to the end of the test. (re-search-forward "^=-=-=\n"))))) -(defun ert-test--erts-test (gen-specs file) +(defun ert-test--erts-test (gen-specs file end) (let* ((file-buffer (current-buffer)) - (specs (ert--erts-specifications (match-beginning 0))) + (specs (ert--erts-specifications end)) (name (cdr (assq 'name specs))) (start-before (point)) (end-after (if (re-search-forward "^=-=-=\n" nil t) diff --git a/lisp/progmodes/erts-mode.el b/lisp/progmodes/erts-mode.el index 8dce93eae7e..b72e1df44ca 100644 --- a/lisp/progmodes/erts-mode.el +++ b/lisp/progmodes/erts-mode.el @@ -178,11 +178,13 @@ erts-run-test (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"))) - (buffer-file-name)) + (let ((end (point))) + (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"))) + (buffer-file-name) + end)) (:success (message "Test successful")) (ert-test-failed (if (not verbose) -- 2.42.0